Getting rid of a ton of spec cruft, and starting over. Also making StringRay a class.
[stringray.git] / Rakefile.rb
blob0aa50258fd08e594d334f544519a6a06596dbb69
1 ($:.unshift File.expand_path(File.join( File.dirname(__FILE__), 'lib' ))).uniq!
2 require 'stringray'
3 require 'extlib/string' # String#/, because I'm a lazy fuck.
4 require 'rake'
5 require 'yard'
6 require 'yard/rake/yardoc_task'
7 require 'spec/rake/spectask'
8 require 'spec/rake/verify_rcov'
9 require 'stringray/core_ext/spec/rake/verify_rcov'
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('stringray', StringRay::Version) do |g|
19       g.project = 'stringray'
20       g.author = ['elliottcable']
21       g.email = ['StringRay@elliottcable.com']
22       g.summary = 'Combining many of the benefits of Arrays and Strings, StringRay allows you to treat a String as an Array of words in many cases.'
23       g.url = 'http://github.com/elliottcable/stringray'
24       g.dependencies = []
25       g.development_dependencies = ['elliottcable-echoe >= 3.0.2', 'rspec', 'rcov', 'yard']
26       g.manifest_name = '.manifest'
27       g.retain_gemspec = true
28       g.rakefile_name = 'Rakefile.rb'
29       g.ignore_pattern = /(^\.git$|^\.yardoc$|^meta\/|\.gemspec$)/
30     end
31   
32     desc 'tests packaged files to ensure they are all present'
33     task :verify => :package do
34       # An error message will be displayed if files are missing
35       if system %(ruby -e "require 'rubygems'; require 'pkg/stringray-#{StringRay::VERSION}/lib/stringray'")
36         puts "\nThe library files are present"
37       end
38     end
39   end
40   
41 rescue LoadError => boom
42   puts "You are missing a dependency required for meta-operations on this gem."
43   puts "#{boom.to_s.capitalize}."
44 ensure
45   task :default # No effect # Invisible
47   # Runs specs, generates rcov, and opens rcov in your browser.
48   namespace :rcov do
49     Spec::Rake::SpecTask.new(:run) do |t|
50       t.spec_opts = ["--format", "specdoc", "--colour"]
51       t.spec_files = Dir['spec/**/*_spec.rb'].sort
52       t.libs = ['lib']
53       t.rcov = true
54       t.rcov_opts = ['--exclude-only', '".*"', '--include-file', '^lib']
55       t.rcov_dir = 'meta' / 'coverage'
56     end
58     Spec::Rake::SpecTask.new(:plain) do |t|
59       t.spec_opts = ["--format", "specdoc"]
60       t.spec_files = Dir['spec/**/*_spec.rb'].sort
61       t.libs = ['lib']
62       t.rcov = true
63       t.rcov_opts = ['--exclude-only', '".*"', '--include-file', '^lib']
64       t.rcov_dir = 'meta' / 'coverage'
65     end
67     RCov::VerifyTask.new(:verify) do |t|
68       t.threshold = 98.7
69       t.index_html = 'meta' / 'coverage' / 'index.html'
70       t.require_exact_threshold = false
71     end
73     task :open do
74       system 'open ' + 'meta' / 'coverage' / 'index.html' if PLATFORM['darwin']
75     end
76   end
77   
78   namespace :yard do
79     YARD::Rake::YardocTask.new :generate do |t|
80       t.files   = ['lib/**/*.rb']
81       t.options = ['--output-dir', "meta/documentation", '--readme', 'README.markdown']
82     end
83     
84     YARD::Rake::YardocTask.new :dot_yardoc do |t|
85       t.files   = ['lib/**/*.rb']
86       t.options = ['--no-output', '--readme', 'README.markdown']
87     end
88     
89     task :open do
90       system 'open ' + 'meta' / 'documentation' / 'index.html' if PLATFORM['darwin']
91     end
92   end
93   
94   namespace :git do
95     task :status do
96       `git status`
97     end
98     
99     task :commit => [:'echoe:manifest', :'yard:dot_yardoc'] do
100       `git commit`
101     end
102   end
103   
104   task :clobber => [:'echoe:clobber_package', :'echoe:clobber_docs', :'echoe:clobber_coverage'] do
105     rm_f 'meta'
106   end
108   desc 'Check everything over before commiting'
109   task :aok => [:'yard:generate', :'yard:open',
110                 :'package:manifest', :'package:package',
111                 :'rcov:run', :'rcov:verify', :'rcov:open',
112                 :'git:status']
114   # desc 'Task run during continuous integration' # Invisible
115   task :ci => [:'yard:generate', :'rcov:plain', :'rcov:verify']