forked from hallison/sinatra-mapping
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
70 lines (60 loc) · 2 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
begin
require 'hanna/rdoctask'
rescue LoadError
require 'rdoc'
require 'rake/rdoctask'
end
require 'rake/testtask'
require 'rake/gempackagetask'
load 'sinatra-mapping.gemspec'
def current_version(file = "VERSION")
@current_value ||= YAML.load_file(file) || {}
end
desc "Generate version for release and tagging."
task :version, [:major, :minor, :patch, :release, :date, :cycle] do |taskspec, version|
require 'parsedate'
version_date = Date.new(*ParseDate.parsedate(version[:date] || current_version[:date].to_s).compact) unless version or current_version
newer = {
:major => version[:major].to_i || current_version[:major].to_i,
:minor => version[:minor].to_i || current_version[:minor].to_i,
:patch => version[:patch].to_i || current_version[:patch].to_i,
:release => version[:release].to_s.empty? ? nil : version[:release].to_i,
:date => version_date || Date.today,
:cycle => version[:cycle] || current_version[:cycle]
}
newer.merge(current_version) do |key, new_value, current_value|
new_value || current_value
end
File.open(taskspec.name.upcase, "w") do |version_file|
version_file << newer.to_yaml
end
end
namespace :version do
desc "Show the current version."
task :show do
version = [:major, :minor, :patch, :release].map do |info|
current_version[info]
end.compact.join('.')
puts "#{@spec.name} v#{version} released at #{current_version[:date]} (#{current_version[:cycle]})"
end
end
Rake::TestTask.new :test do |spec|
spec.test_files = FileList["test/*_test.rb"]
end
Rake::GemPackageTask.new(@spec) do |pkg|
pkg.need_tar_bz2 = true
end
desc "Generate RDoc API documentation."
Rake::RDocTask.new("doc:api") do |rdoc|
rdoc.title = %q{Sinatra::Mapping - API Documentation}
rdoc.main = %q{README.rdoc}
rdoc.options = %w{--line-numbers --show-hash}
rdoc.rdoc_dir = %q{doc/api}
rdoc.rdoc_files.include %w{
CHANGES
LICENSE
README.rdoc
lib/**/*.rb
}
end
task :default => :test