-
Notifications
You must be signed in to change notification settings - Fork 9
/
Rakefile
82 lines (71 loc) · 1.84 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
80
81
82
require 'bundler'
Bundler::GemHelper.install_tasks
Bundler.setup
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
require 'cucumber'
require 'cucumber/rake/task'
Cucumber::Rake::Task.new(:features) do |t|
t.cucumber_opts = "features --format pretty"
end
def read_version
@version = File.read(File.join(File.dirname(__FILE__), 'lib', 'version.rb'))[/^\s*VERSION\s+=\s+'([^']+)'$/, 1]
end
def write_version(v)
file = File.join(File.dirname(__FILE__), 'lib', 'version.rb')
contents = File.read(file).gsub(/^\s*VERSION\s+=\s+'([^']+)'/) do |m|
m.sub($1, v)
end
File.open(file, 'w') do |f|
f.write contents
end
end
desc 'Display the current version number'
task :version do
puts read_version
end
namespace :version do
desc 'Explicitly write a new version number'
task :write do
write_version ENV['VERSION']
end
namespace :bump do
desc 'Bump version number to new major'
task :major do
major, minor, patch = read_version.split('.')
major = major.to_i + 1
minor = 0
patch = 0
write_version [major, minor, patch].join('.')
end
desc 'Bump version number to new minor'
task :minor do
major, minor, patch = read_version.split('.')
minor = minor.to_i + 1
patch = 0
write_version [major, minor, patch].join('.')
end
desc 'Bump version number to new patch'
task :patch do
major, minor, patch = read_version.split('.')
patch = patch.to_i + 1
write_version [major, minor, patch].join('.')
end
end
end
begin
require 'yard'
YARD::Rake::YardocTask.new do |t|
t.options = [
'--files', 'LICENSE',
'--files', 'HISTORY.md',
'--title', 'Typogruby API documentation'
]
end
rescue LoadError
end