bump 0.3.12 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.travis.yml +3 -0
- data/Gemfile.lock +1 -1
- data/bin/bump +11 -6
- data/bump.gemspec +1 -1
- data/lib/bump.rb +25 -8
- data/lib/bump/tasks.rb +12 -3
- data/spec/bump/tasks_spec.rb +7 -0
- data/spec/bump_spec.rb +50 -0
- metadata +2 -2
data/.travis.yml
CHANGED
data/Gemfile.lock
CHANGED
data/bin/bump
CHANGED
@@ -7,11 +7,12 @@ OptionParser.new do |opts|
|
|
7
7
|
Bump your gem version.
|
8
8
|
|
9
9
|
Usage:
|
10
|
-
bump current
|
11
|
-
bump pre
|
12
|
-
bump patch
|
13
|
-
bump minor
|
14
|
-
bump major
|
10
|
+
bump current # show current version
|
11
|
+
bump pre # increase prerelease version of your gem (1.0.0-X) [alpha, beta, rc, ]
|
12
|
+
bump patch # increase patch version of your gem (1.0.X)
|
13
|
+
bump minor # increase minor version of your gem (1.X.0)
|
14
|
+
bump major # increase major version of your gem (X.0.0)
|
15
|
+
bump set 1.2.3 # set the version number to the given value
|
15
16
|
|
16
17
|
Options:
|
17
18
|
BANNER
|
@@ -20,11 +21,15 @@ BANNER
|
|
20
21
|
opts.on("-h", "--help","Show this.") { puts opts; exit }
|
21
22
|
end.parse!
|
22
23
|
|
23
|
-
|
24
|
+
unless (ARGV.size == 1 && ARGV.first != "set") || (ARGV.size == 2 && ARGV.first == "set")
|
24
25
|
puts "Usage instructions: bump --help"
|
25
26
|
exit 1
|
26
27
|
end
|
27
28
|
|
29
|
+
if ARGV.first == "set"
|
30
|
+
options[:version] = ARGV[1]
|
31
|
+
end
|
32
|
+
|
28
33
|
require File.dirname(__FILE__) + '/../lib/bump'
|
29
34
|
output, status = Bump::Bump.run(ARGV.first, options)
|
30
35
|
puts output
|
data/bump.gemspec
CHANGED
data/lib/bump.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
module Bump
|
2
2
|
class InvalidOptionError < StandardError; end
|
3
|
+
class InvalidVersionError < StandardError; end
|
3
4
|
class UnfoundVersionError < StandardError; end
|
4
5
|
class TooManyVersionFilesError < StandardError; end
|
5
6
|
class UnfoundVersionFileError < StandardError; end
|
@@ -7,7 +8,7 @@ module Bump
|
|
7
8
|
class Bump
|
8
9
|
BUMPS = %w(major minor patch pre)
|
9
10
|
PRERELEASE = ["alpha","beta","rc",nil]
|
10
|
-
OPTIONS = BUMPS | ["current"]
|
11
|
+
OPTIONS = BUMPS | ["set", "current"]
|
11
12
|
VERSION_REGEX = /(\d+\.\d+\.\d+(?:-(?:#{PRERELEASE.compact.join('|')}))?)/
|
12
13
|
|
13
14
|
def self.defaults
|
@@ -22,7 +23,10 @@ module Bump
|
|
22
23
|
|
23
24
|
case bump
|
24
25
|
when *BUMPS
|
25
|
-
|
26
|
+
bump_part(bump, options)
|
27
|
+
when "set"
|
28
|
+
raise InvalidVersionError unless options[:version]
|
29
|
+
bump_set(options[:version], options)
|
26
30
|
when "current"
|
27
31
|
["Current version: #{current}", 0]
|
28
32
|
else
|
@@ -30,6 +34,8 @@ module Bump
|
|
30
34
|
end
|
31
35
|
rescue InvalidOptionError
|
32
36
|
["Invalid option. Choose between #{OPTIONS.join(',')}.", 1]
|
37
|
+
rescue InvalidVersionError
|
38
|
+
["Invalid version number given.", 1]
|
33
39
|
rescue UnfoundVersionError
|
34
40
|
["Unable to find your gem version", 1]
|
35
41
|
rescue UnfoundVersionFileError
|
@@ -46,15 +52,24 @@ module Bump
|
|
46
52
|
|
47
53
|
private
|
48
54
|
|
49
|
-
def self.bump(
|
50
|
-
current, file = current_info
|
51
|
-
next_version = next_version(current, part)
|
55
|
+
def self.bump(file, current, next_version, options)
|
52
56
|
replace(file, current, next_version)
|
53
57
|
system("bundle") if options[:bundle] and under_version_control?("Gemfile.lock")
|
54
58
|
commit(next_version, file, options) if options[:commit]
|
55
59
|
["Bump version #{current} to #{next_version}", 0]
|
56
60
|
end
|
57
61
|
|
62
|
+
def self.bump_part(part, options)
|
63
|
+
current, file = current_info
|
64
|
+
next_version = next_version(current, part)
|
65
|
+
bump(file, current, next_version, options)
|
66
|
+
end
|
67
|
+
|
68
|
+
def self.bump_set(next_version, options)
|
69
|
+
current, file = current_info
|
70
|
+
bump(file, current, next_version, options)
|
71
|
+
end
|
72
|
+
|
58
73
|
def self.commit(version, file, options)
|
59
74
|
return unless File.directory?(".git")
|
60
75
|
system("git add --update Gemfile.lock") if options[:bundle]
|
@@ -97,9 +112,11 @@ module Bump
|
|
97
112
|
end
|
98
113
|
|
99
114
|
def self.version_from_lib_rb
|
100
|
-
|
101
|
-
|
102
|
-
|
115
|
+
files = Dir.glob("lib/**/*.rb")
|
116
|
+
file = files.detect do |file|
|
117
|
+
File.read(file) =~ /^\s+VERSION = ['"](#{VERSION_REGEX})['"]/i
|
118
|
+
end
|
119
|
+
[$1, file] if file
|
103
120
|
end
|
104
121
|
|
105
122
|
def self.version_from_chef
|
data/lib/bump/tasks.rb
CHANGED
@@ -1,6 +1,12 @@
|
|
1
1
|
require "bump"
|
2
2
|
|
3
3
|
namespace :bump do
|
4
|
+
run_bump = lambda do |bump, options|
|
5
|
+
output, status = Bump::Bump.run(bump, options)
|
6
|
+
puts output
|
7
|
+
abort unless status == 0
|
8
|
+
end
|
9
|
+
|
4
10
|
(Bump::Bump::BUMPS + ["current"]).each do |bump|
|
5
11
|
if bump == "current"
|
6
12
|
desc "Show current gem version"
|
@@ -9,9 +15,12 @@ namespace :bump do
|
|
9
15
|
end
|
10
16
|
|
11
17
|
task bump do
|
12
|
-
|
13
|
-
puts output
|
14
|
-
abort unless status == 0
|
18
|
+
run_bump.call(bump, {})
|
15
19
|
end
|
16
20
|
end
|
21
|
+
|
22
|
+
desc "Sets the version number using the VERSION environment variable"
|
23
|
+
task :set do
|
24
|
+
run_bump.call("set", :version => ENV['VERSION'])
|
25
|
+
end
|
17
26
|
end
|
data/spec/bump/tasks_spec.rb
CHANGED
@@ -16,6 +16,13 @@ describe "rake bump" do
|
|
16
16
|
`git log -1 --pretty=format:'%s'`.should == "v1.3.0"
|
17
17
|
end
|
18
18
|
|
19
|
+
it "sets a version" do
|
20
|
+
output = run "VERSION=1.3.0 rake bump:set"
|
21
|
+
output.should include("1.3.0")
|
22
|
+
read("VERSION").should == "1.3.0\n"
|
23
|
+
`git log -1 --pretty=format:'%s'`.should == "v1.3.0"
|
24
|
+
end
|
25
|
+
|
19
26
|
it "fails when it cannot bump" do
|
20
27
|
write "VERSION", "AAA"
|
21
28
|
run "rake bump:minor", :fail => true
|
data/spec/bump_spec.rb
CHANGED
@@ -90,6 +90,11 @@ describe Bump do
|
|
90
90
|
read(gemspec).should include('s.version = "5.0.0"')
|
91
91
|
end
|
92
92
|
|
93
|
+
it "should set the version" do
|
94
|
+
bump("set 1.2.3").should include("1.2.3")
|
95
|
+
read(gemspec).should include('s.version = "1.2.3"')
|
96
|
+
end
|
97
|
+
|
93
98
|
it "should bump more then 10" do
|
94
99
|
bump("patch").should include("4.2.4")
|
95
100
|
bump("patch").should include("4.2.5")
|
@@ -115,6 +120,11 @@ describe Bump do
|
|
115
120
|
bump("patch").should include("4.2.4")
|
116
121
|
read(gemspec).should include('"4.2.4"')
|
117
122
|
end
|
123
|
+
|
124
|
+
it "should set the version" do
|
125
|
+
bump("set 1.2.3").should include("1.2.3")
|
126
|
+
read(gemspec).should include('"1.2.3"')
|
127
|
+
end
|
118
128
|
end
|
119
129
|
|
120
130
|
context "VERSION in version.rb" do
|
@@ -134,6 +144,11 @@ describe Bump do
|
|
134
144
|
read(version_file).should include(' VERSION = "1.3.0"')
|
135
145
|
end
|
136
146
|
|
147
|
+
it "should set the version" do
|
148
|
+
bump("set 1.2.3").should include("1.2.3")
|
149
|
+
read(version_file).should include('"1.2.3"')
|
150
|
+
end
|
151
|
+
|
137
152
|
it "should bump Version" do
|
138
153
|
write version_file, <<-RUBY.sub(" "*8, "")
|
139
154
|
module Foo
|
@@ -144,6 +159,16 @@ describe Bump do
|
|
144
159
|
read(version_file).should include(' Version = "1.3.0"')
|
145
160
|
end
|
146
161
|
|
162
|
+
it "should set Version" do
|
163
|
+
write version_file, <<-RUBY.sub(" "*8, "")
|
164
|
+
module Foo
|
165
|
+
Version = "1.2.3"
|
166
|
+
end
|
167
|
+
RUBY
|
168
|
+
bump("set 1.3.0").should include("1.3.0")
|
169
|
+
read(version_file).should include(' Version = "1.3.0"')
|
170
|
+
end
|
171
|
+
|
147
172
|
it "should bump if a gemspec exists and leave it alone" do
|
148
173
|
write_gemspec "'1.'+'2.3'"
|
149
174
|
bump("minor").should include("1.3.0")
|
@@ -169,6 +194,11 @@ describe Bump do
|
|
169
194
|
read("VERSION").should include("1.3.0")
|
170
195
|
end
|
171
196
|
|
197
|
+
it "should set the version" do
|
198
|
+
bump("set 1.3.0").should include("1.3.0")
|
199
|
+
read("VERSION").should include("1.3.0")
|
200
|
+
end
|
201
|
+
|
172
202
|
it "should bump if a gemspec & version.rb exists and leave it alone" do
|
173
203
|
write_gemspec "File.read('VERSION')"
|
174
204
|
write_version_file "File.read('VERSION')"
|
@@ -294,6 +324,11 @@ describe Bump do
|
|
294
324
|
read(version_file).should include(' VERSION = "1.3.0"')
|
295
325
|
end
|
296
326
|
|
327
|
+
it "should set VERSION" do
|
328
|
+
bump("set 1.3.0").should include("1.3.0")
|
329
|
+
read(version_file).should include(' VERSION = "1.3.0"')
|
330
|
+
end
|
331
|
+
|
297
332
|
it "should bump Version" do
|
298
333
|
write version_file, <<-RUBY.sub(" "*8, "")
|
299
334
|
module Foo
|
@@ -304,6 +339,16 @@ describe Bump do
|
|
304
339
|
read(version_file).should include(' Version = "1.3.0"')
|
305
340
|
end
|
306
341
|
|
342
|
+
it "should set Version" do
|
343
|
+
write version_file, <<-RUBY.sub(" "*8, "")
|
344
|
+
module Foo
|
345
|
+
Version = "1.2.3"
|
346
|
+
end
|
347
|
+
RUBY
|
348
|
+
bump("set 1.3.0").should include("1.3.0")
|
349
|
+
read(version_file).should include(' Version = "1.3.0"')
|
350
|
+
end
|
351
|
+
|
307
352
|
it "should bump if a gemspec exists and leave it alone" do
|
308
353
|
write_gemspec "'1.'+'2.3'"
|
309
354
|
bump("minor").should include("1.3.0")
|
@@ -332,6 +377,11 @@ describe Bump do
|
|
332
377
|
bump("minor").should include("1.3.0")
|
333
378
|
read(version_file).should include("1.3.0")
|
334
379
|
end
|
380
|
+
|
381
|
+
it "should set the version" do
|
382
|
+
bump("set 1.3.0").should include("1.3.0")
|
383
|
+
read(version_file).should include("1.3.0")
|
384
|
+
end
|
335
385
|
end
|
336
386
|
|
337
387
|
private
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bump
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-03-
|
12
|
+
date: 2013-03-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|