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