-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
70 lines (51 loc) · 1.47 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
## Author: Daniel Sperl
## Copyright: Copyright 2014 Gamua
## License: Simplified BSD
require 'rake/testtask'
require 'fileutils'
require 'yard'
desc 'Run tests'
task :default => :test
Rake::TestTask.new do |t|
t.libs << 'test'
t.verbose = true
end
YARD::Rake::YardocTask.new do |t|
t.options = ["--markup=markdown", "--no-private"]
end
desc 'Remove all files generated by Yard'
task :clobber_yard do
FileUtils.rm_rf('doc', :verbose=>true)
FileUtils.rm_rf('.yardoc', :verbose=>true)
end
namespace "bump" do
desc 'Raises the major version'
task(:major) { bump_version(:major) }
desc 'Raises the minor version'
task(:minor) { bump_version(:minor) }
desc 'Raises the patch version'
task(:patch) { bump_version(:patch) }
end
## Helpers
def bump_version(part)
filename = "lib/flox/version.rb"
new_version = nil
all_lines = ""
File.readlines(filename).each do |line|
matches = /VERSION\s?=\s?[\"'](\d+\.\d+\.\d+)[\"']/.match(line)
if matches
major, minor, patch = *matches[0].split('.').map { |v| v.to_i }
if part == :major then major += 1; minor = 0; patch = 0 end
if part == :minor then minor += 1; patch = 0 end
if part == :patch then patch += 1; end
new_version = "#{major}.#{minor}.#{patch}"
all_lines += " VERSION = '#{new_version}'\n"
else
all_lines += line
end
end
if new_version
File.open(filename, 'w') { |f| f.write all_lines }
puts "New Version: #{new_version}"
end
end