|
1 |
| -Dir.glob('lib/tasks/*.rake').each { |r| import r } |
| 1 | +require 'rubygems' |
| 2 | +require 'bundler' |
| 3 | +begin |
| 4 | + Bundler.setup(:default, :development) |
| 5 | +rescue Bundler::BundlerError => e |
| 6 | + $stderr.puts e.message |
| 7 | + $stderr.puts "Run `bundle install` to install missing gems" |
| 8 | + exit e.status_code |
| 9 | +end |
| 10 | + |
| 11 | +Bundler::GemHelper.install_tasks |
2 | 12 |
|
3 |
| -require 'bundler/gem_tasks' |
4 | 13 | require 'rake'
|
| 14 | +require 'rspec' |
5 | 15 | require 'rspec/core/rake_task'
|
6 | 16 |
|
7 |
| -begin |
8 |
| - if RUBY_VERSION < "1.9" |
9 |
| -require 'rcov/rcovtask' |
10 |
| -desc "Generate code coverage" |
11 |
| -RSpec::Core::RakeTask.new(:rcov) do |t| |
12 |
| - t.pattern = "./spec/**/*_spec.rb" # don't need this, it's default. |
13 |
| - t.rcov = true |
14 |
| - t.rcov_opts = ['--exclude', 'spec', '--exclude', 'gems'] |
15 |
| -end |
| 17 | +desc 'Default: run specs.' |
| 18 | +task :default => :spec |
| 19 | + |
| 20 | +RSpec::Core::RakeTask.new do |t| |
| 21 | + if ENV['COVERAGE'] and RUBY_VERSION =~ /^1.8/ |
| 22 | + t.rcov = true |
| 23 | + t.rcov_opts = ['--exclude', 'spec', '--exclude', 'gems'] |
16 | 24 | end
|
17 |
| -rescue |
18 | 25 | end
|
19 | 26 |
|
20 |
| -RSpec::Core::RakeTask.new(:spec) |
| 27 | +# Use yard to build docs |
| 28 | +begin |
| 29 | + require 'yard' |
| 30 | + require 'yard/rake/yardoc_task' |
| 31 | + project_root = File.expand_path(File.dirname(__FILE__)) |
| 32 | + doc_destination = File.join(project_root, 'doc') |
21 | 33 |
|
22 |
| -task :clean do |
23 |
| - puts 'Cleaning old coverage.data' |
24 |
| - FileUtils.rm('coverage.data') if(File.exists? 'coverage.data') |
| 34 | + YARD::Rake::YardocTask.new(:doc) do |yt| |
| 35 | + yt.files = Dir.glob(File.join(project_root, 'lib', '**', '*.rb')) + |
| 36 | + [ File.join(project_root, 'README.md') ] |
| 37 | + yt.options = ['--output-dir', doc_destination, '--readme', 'README.md'] |
| 38 | + end |
| 39 | +rescue LoadError |
| 40 | + desc "Generate YARD Documentation" |
| 41 | + task :doc do |
| 42 | + abort "Please install the YARD gem to generate rdoc." |
| 43 | + end |
25 | 44 | end
|
26 | 45 |
|
27 |
| -task :default => [:rcov, :doc] |
|
0 commit comments