Ignoring the 'logs' folder.
[nfoiled.git] / Rakefile.rb
blob9f11d6b3bbcd34bcf4ee96d3470435e2338ed786
1 ($:.unshift File.expand_path(File.join( File.dirname(__FILE__), 'lib' ))).uniq!
2 require 'nfoiled'
4 require 'fileutils'
6 # =======================
7 # = Gem packaging tasks =
8 # =======================
9 begin
10   require 'echoe'
11   
12   task :install => :'package:install'
13   task :package => :'package:package'
14   task :manifest => :'package:manifest'
15   namespace :package do
16     Echoe.new('nfoiled', Nfoiled::Version) do |g|
17       g.project = 'nfoiled'
18       g.author = ['elliottcable']
19       g.email = ['Nfoiled@elliottcable.com']
20       g.summary = 'The Rubyist\'s interface to Ncurses.'
21       g.url = 'http://github.com/elliottcable/nfoiled'
22       g.runtime_dependencies = ['ncurses'] #, 'yard >=0.2.3'
23       g.development_dependencies = ['echoe >= 3.0.2', 'rspec', 'rcov', 'yard', 'stringray']
24       g.manifest_name = '.manifest'
25       g.retain_gemspec = true
26       g.rakefile_name = 'Rakefile.rb'
27       g.ignore_pattern = /^\.git\/|^meta\/|\.gemspec/
28     end
29   
30     desc 'tests packaged files to ensure they are all present'
31     task :verify => :package do
32       # An error message will be displayed if files are missing
33       if system %(ruby -e "require 'rubygems'; require 'pkg/nfoiled-#{Nfoiled::Version}/lib/nfoiled'")
34         puts "\nThe library files are present"
35       end
36     end
37   end
38   
39 rescue LoadError
40   desc 'You need the `echoe` gem to package Nfoiled'
41   task :package
42 end
44 # =======================
45 # = Spec/Coverage tasks =
46 # =======================
47 begin
48   require 'spec'
49   require 'rcov'
50   require 'spec/rake/spectask'
51   
52   task :default => :'coverage:run'
53   task :coverage => :'coverage:run'
54   namespace :coverage do
55     Spec::Rake::SpecTask.new(:run) do |t|
56       t.spec_opts = ["--format", "specdoc"]
57       t.spec_opts << "--colour" unless ENV['CI']
58       t.spec_files = Dir['spec/**/*_spec.rb'].sort
59       t.libs = ['lib']
60       t.rcov = true
61       t.rcov_opts = ['--exclude-only', '".*"', '--include-file', '"^lib"']
62       t.rcov_dir = File.join('meta', 'coverage')
63     end
64     
65     begin
66       require 'spec/rake/verify_rcov'
67       # For the moment, this is the only way I know of to fix RCov. I may
68       # release the fix as it's own gem at some point in the near future.
69       require 'stringray/core_ext/spec/rake/verify_rcov'
70       RCov::VerifyTask.new(:verify) do |t|
71         t.threshold = 50
72         t.index_html = File.join('meta', 'coverage', 'index.html')
73         t.require_exact_threshold = false
74       end
75     rescue LoadError
76       desc 'You need the `stringray` gem to verify coverage'
77       task :verify
78     end
79     
80     task :open do
81       system 'open ' + File.join('meta', 'coverage', 'index.html') if PLATFORM['darwin']
82     end
83   end
84   
85 rescue LoadError
86   desc 'You need the `rcov` and `rspec` gems to run specs/coverage'
87   task :coverage
88 end
90 # =======================
91 # = Documentation tasks =
92 # =======================
93 begin
94   require 'yard'
95   require 'yard/rake/yardoc_task'
96   
97   task :documentation => :'documentation:generate'
98   namespace :documentation do
99     YARD::Rake::YardocTask.new :generate do |t|
100       t.files   = ['lib/**/*.rb']
101       t.options = ['--output-dir', File.join('meta', 'documentation'),
102                    '--readme', 'README.markdown']
103     end
104     
105     YARD::Rake::YardocTask.new :dotyardoc do |t|
106       t.files   = ['lib/**/*.rb']
107       t.options = ['--no-output',
108                    '--readme', 'README.markdown']
109     end
110     
111     task :open do
112       system 'open ' + File.join('meta', 'documentation', 'index.html') if PLATFORM['darwin']
113     end
114   end
115   
116 rescue LoadError
117   desc 'You need the `yard` gem to generate documentation'
118   task :documentation
121 # =========
122 # = Other =
123 # =========
124 desc 'Removes all meta producs'
125 task :clobber do
126   `rm -rf #{File.expand_path(File.join( File.dirname(__FILE__), 'meta' ))}`
129 desc 'Check everything over before commiting'
130 task :aok => [:'documentation:generate', :'documentation:open',
131               :'package:manifest',
132               :'coverage:run', :'coverage:verify', :'coverage:open']
134 task :ci => [:'documentation:generate', :'coverage:run', :'coverage:verify']