* Switched to YARD for documentation
[rat.git] / Rakefile
blobb06be4b71d3c966b64de2821a1385a77122f4b3d
1 ($:.unshift File.expand_path(File.join( File.dirname(__FILE__), 'lib' ))).uniq!
2 require 'rat'
3 require 'rake'
4 require 'yard'
5 require 'yard/rake/yardoc_task'
6 require 'spec/rake/spectask'
7 require 'spec/rake/verify_rcov'
8 require 'stringray/core_ext/spec/rake/verify_rcov'
10 begin
11   require 'echoe'
12   
13   namespace :echoe do
14     Echoe.new('rat', Rat::VERSION) do |g|
15       g.author = ['elliottcable']
16       g.email = ['rat@elliottcable.com']
17       g.summary = 'Flexible terminal messaging (IM/IRC) client'
18       g.url = 'http://github.com/elliottcable/rat'
19       g.dependencies = ['stringray >=2', 'ncurses']
20       g.manifest_name = '.manifest'
21       g.ignore_pattern = ['.git', 'meta', 'logs', 'stringray.gemspec']
22     end
23   
24     desc 'tests packaged files to ensure they are all present'
25     task :verify => :package do
26       # An error message will be displayed if files are missing
27       if system %(ruby -e "require 'rubygems'; require 'merb-core'; require 'pkg/merb_strokedb-#{Rat::VERSION}/lib/merb_strokedb'")
28         puts "\nThe library files are present"
29       end
30     end
32     task :copy_gemspec => [:package] do
33       pkg = Dir['pkg/*'].select {|dir| File.directory? dir}.last
34       mv File.join(pkg, pkg.gsub(/^pkg\//,'').gsub(/\-\d+$/,'.gemspec')), './'
35     end
37     desc 'builds a gemspec as GitHub wants it'
38     task :gemspec => [:package, :copy_gemspec, :clobber_package]
40     # desc 'Run specs, clean tree, update manifest, run coverage, and install gem!'
41     desc 'Clean tree, update manifest, and install gem!'
42     task :magic => [:clean, :manifest, :install]
43   end
44   
45   task :manifest => [:'echoe:manifest']
46   
47 rescue LoadError => boom
48   puts "You are missing a dependency required for meta-operations on this gem."
49   puts "#{boom.to_s.capitalize}."
50 ensure
51   task :default # No effect # Invisible
53   # Runs specs, generates rcov, and opens rcov in your browser.
54   namespace :rcov do
55     Spec::Rake::SpecTask.new(:run) do |t|
56       t.spec_opts = ["--format", "specdoc", "--colour"]
57       t.spec_files = Dir['spec/**/*_spec.rb'].sort
58       t.libs = ['lib']
59       t.rcov = true
60       t.rcov_opts = ['--exclude-only', '".*"', '--include-file', '^lib']
61       t.rcov_dir = 'meta' / 'coverage'
62     end
64     Spec::Rake::SpecTask.new(:plain) do |t|
65       t.spec_opts = ["--format", "specdoc"]
66       t.spec_files = Dir['spec/**/*_spec.rb'].sort
67       t.libs = ['lib']
68       t.rcov = true
69       t.rcov_opts = ['--exclude-only', '".*"', '--include-file', '^lib']
70       t.rcov_dir = 'meta' / 'coverage'
71     end
73     RCov::VerifyTask.new(:verify) do |t|
74       t.threshold = 50
75       t.index_html = 'meta' / 'coverage' / 'index.html'
76       t.require_exact_threshold = false
77     end
79     task :open do
80       system 'open ' + 'meta' / 'coverage' / 'index.html' if PLATFORM['darwin']
81     end
82   end
83   
84   namespace :yard do
85     YARD::Rake::YardocTask.new :generate do |t|
86       t.files   = ['lib/**/*.rb']
87       t.options = ['--output-dir', "meta/documentation", '--readme', 'README.mkdn']
88     end
89     
90     YARD::Rake::YardocTask.new :dot_yardoc do |t|
91       t.files   = ['lib/**/*.rb']
92       t.options = ['--no-output', '--readme', 'README.mkdn']
93     end
94     
95     task :open do
96       system 'open ' + 'meta' / 'documentation' / 'index.html' if PLATFORM['darwin']
97     end
98   end
99   
100   namespace :git do
101     task :status do
102       `git status`
103     end
104   end
105   
106   desc 'Check everything over before commiting'
107   task :aok => [:'yard:generate', :'yard:open',
108                 :'echoe:manifest',
109                 :'rcov:run', :'rcov:verify', :'rcov:open',
110                 :'git:status']
112   # desc 'Task run during continuous integration' # Invisible
113   task :ci => [:'yard:generate', :'rcov:plain', :'rcov:verify']