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