Skip to content

Commit 583a0a6

Browse files
Update version helper
1 parent 982b102 commit 583a0a6

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

Rakefile

+13-7
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@ require 'posix/spawn'
88
def repo_name; 'appium_lib' end # ruby_lib published as appium_lib
99
def gh_name; 'ruby_lib' end # the name as used on github.com
1010
def version_file; "lib/#{repo_name}/common/version.rb" end
11-
def version_rgx; /VERSION = '([^']+)'/m end
11+
def version_rgx; /\s*VERSION\s*=\s*'([^']+)'/m end
1212

1313
def version
1414
@version = @version || File.read(version_file).match(version_rgx)[1]
1515
end
1616

17-
def bump major=false
17+
def bump value
1818
data = File.read version_file
1919

2020
v_line = data.match version_rgx
21-
d_line = data.match /DATE = '([^']+)'/m
21+
d_line = data.match /\s*DATE\s*=\s*'([^']+)'/m
2222

2323
old_v = v_line[0]
2424
old_d = d_line[0]
@@ -27,7 +27,7 @@ def bump major=false
2727
new_num = old_num.split('.')
2828
new_num[-1] = new_num[-1].to_i + 1
2929

30-
if major
30+
if value == :y
3131
new_num[-1] = 0 # x.y.Z -> x.y.0
3232
new_num[-2] = new_num[-2].to_i + 1 # x.Y -> x.Y+1
3333
end
@@ -48,16 +48,22 @@ def bump major=false
4848
File.write version_file, data
4949
end
5050

51-
desc 'Bump the version number and update the date.'
51+
desc 'Bump the z version number and update the date.'
5252
task :bump do
53-
bump
53+
bump :z
5454
end
5555

5656
desc 'Bump the y version number, set z to zero, update the date.'
5757
task :bumpy do
58-
bump true
58+
bump :y
5959
end
6060

61+
desc 'Bump the x version number, set y & z to zero, update the date.'
62+
task :bumpx do
63+
bump :x
64+
end
65+
66+
6167
desc 'Install gems required for release task'
6268
task :dev do
6369
sh 'gem install --no-rdoc --no-ri yard'

0 commit comments

Comments
 (0)