-
Notifications
You must be signed in to change notification settings - Fork 37
/
Rakefile
79 lines (68 loc) · 1.71 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
require 'rubygems'
require 'bundler/gem_tasks'
require 'rake'
require 'date'
require './lib/toml/version'
#############################################################################
#
# Helper functions
#
#############################################################################
def name
@name ||= Dir['*.gemspec'].first.split('.').first
end
def version
TOML::VERSION
end
def date
Date.today.to_s
end
#############################################################################
#
# Standard tasks
#
#############################################################################
task :default => :test
# require 'rake/testtask'
# Rake::TestTask.new(:test) do |test|
# test.libs << 'lib' << 'test'
# test.pattern = 'test/**/test_*.rb'
# test.verbose = true
# end
task :test do
Dir['./test/**/test_*.rb'].each {|f| require f }
end
desc "Generate RCov test coverage and open in your browser"
task :coverage do
if RUBY_VERSION =~ /^1\./
require 'rubygems'
require 'bundler'
Bundler.setup(:test)
require 'simplecov'
require 'simplecov-gem-adapter'
sh "rm -fr coverage"
SimpleCov.command_name 'Unit Tests'
SimpleCov.start 'gem'
Rake::Task[:test].invoke
SimpleCov.at_exit do
SimpleCov.result.format!
sh "open coverage/index.html"
end
else
require 'rcov'
sh "rm -fr coverage"
sh "rcov test/test_*.rb"
sh "open coverage/index.html"
end
end
require 'rdoc/task'
Rake::RDocTask.new do |rdoc|
rdoc.rdoc_dir = 'rdoc'
rdoc.title = "#{name} #{version}"
rdoc.rdoc_files.include('README*')
rdoc.rdoc_files.include('lib/**/*.rb')
end
desc "Open an irb session preloaded with this library"
task :console do
sh "irb -rubygems -r ./lib/#{name}.rb"
end