2 ($:.unshift File.expand_path(File.join( File.dirname(__FILE__), 'lib' ))).uniq!
6 default_tasks = Array.new
8 # =======================
9 # = Gem packaging tasks =
10 # =======================
14 default_tasks << :'package:manifest' unless ENV['CI']
15 default_tasks << :'package:verify'
17 task :install => :'package:install'
18 task :package => :'package:package'
19 task :manifest => :'package:manifest'
21 Echoe.new(LibName, Lib::Version) do |g|
22 g.author = ['elliottcable']
23 g.email = ["#{LibName}@elliottcable.com"]
24 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.'
25 g.url = 'http://github.com/elliottcable/' + LibName
26 g.runtime_dependencies = []
27 g.development_dependencies = ['echoe >= 3.0.2', 'rspec', 'rcov', 'yard']
28 g.manifest_name = '.manifest'
29 g.retain_gemspec = true
30 g.rakefile_name = 'Rakefile.rb'
31 g.ignore_pattern = /^\.git\/|^meta\/|\.gemspec/
34 desc 'Tests packaged files to ensure they are all present'
35 task :verify => :package do
36 # An error message will be displayed if files are missing
37 if system %(ruby -e "require 'rubygems'; require 'pkg/#{LibName}-#{Lib::Version}/lib/#{LibName}'")
38 puts "\nThe library files are present."
43 rescue LoadError => exception
44 raise exception unless exception.message =~ /(echoe)$/
45 desc '!! You need the `echoe` gem to package or install this project!'
49 # =======================
50 # = Spec/Coverage tasks =
51 # =======================
55 require 'spec/rake/spectask'
57 default_tasks << :'coverage:run'
58 default_tasks << :'coverage:open' unless ENV['CI']
60 task :coverage => :'coverage:run'
61 namespace :coverage do
62 Spec::Rake::SpecTask.new(:run) do |t|
63 t.spec_opts = ["--format", "specdoc"]
64 t.spec_opts << "--colour" unless ENV['CI']
65 t.spec_files = Dir[File.join('spec', '**', '*_spec.rb')].sort
68 t.rcov_opts = ['--exclude-only', '".*"', '--include-file', '"^lib"',
69 '--sort', 'loc', '--sort-reverse',
70 '--comments', '--profile', '--text-report', '-w' ]
71 t.rcov_dir = File.join('meta', 'coverage')
75 system 'open ' + File.join('meta', 'coverage', 'index.html')
76 end if RUBY_PLATFORM =~ /darwin/
79 rescue LoadError => exception
80 raise exception unless exception.message =~ /(rcov|spec)$/
81 desc '!! You need the `rcov` and `rspec` gems to run specs or coverage!'
85 # =======================
86 # = Documentation tasks =
87 # =======================
90 require 'yard/rake/yardoc_task'
92 default_tasks << :'documentation:generate'
93 default_tasks << :'documentation:open' unless ENV['CI']
95 task :documentation => :'documentation:generate'
96 namespace :documentation do
97 YARD::Rake::YardocTask.new :generate do |t|
98 t.files = [File.join('lib', '**', '*.rb')]
99 t.options = ['--output-dir', File.join('meta', 'documentation'),
100 '--readme', 'README.markdown']
103 YARD::Rake::YardocTask.new :yardoc do |t|
104 t.files = [File.join('lib', '**', '*.rb')]
105 t.options = ['--no-output',
106 '--readme', 'README.markdown']
110 system 'open ' + File.join('meta', 'documentation', 'index.html')
111 end if RUBY_PLATFORM =~ /darwin/
114 rescue LoadError => exception
115 raise exception unless exception.message =~ /(yard)$/
116 desc '!! You need the `yard` gem to generate documentation!'
123 desc 'Removes all meta producs'
125 `rm -rf #{File.expand_path(File.join( File.dirname(__FILE__), 'meta' ))} #{File.expand_path(File.join( File.dirname(__FILE__), 'pkg' ))}`
128 desc 'Run all default tasks'
129 task :default => default_tasks do
130 puts "** Successfully ran the following tasks:"
131 puts "** #{Rake.application.tasks.select {|t| t.name == 'default' }.first.prerequisites.join(', ')}"