bump 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/bin/bump +1 -0
- data/bump.gemspec +1 -1
- data/lib/bump.rb +14 -7
- data/spec/bump_spec.rb +64 -5
- metadata +1 -1
data/Gemfile.lock
CHANGED
data/bin/bump
CHANGED
@@ -11,6 +11,7 @@ Bump your gem version.
|
|
11
11
|
|
12
12
|
Usage:
|
13
13
|
bump current # show current version
|
14
|
+
bump pre # increase prerelease version of your gem (1.0.0-X) [alpha, beta, rc, ]
|
14
15
|
bump patch # increase patch version of your gem (1.0.X)
|
15
16
|
bump minor # increase minor version of your gem (1.X.0)
|
16
17
|
bump major # increase major version of your gem (X.0.0)
|
data/bump.gemspec
CHANGED
data/lib/bump.rb
CHANGED
@@ -5,13 +5,14 @@ module Bump
|
|
5
5
|
class UnfoundVersionFileError < StandardError; end
|
6
6
|
|
7
7
|
class Bump
|
8
|
-
BUMPS = %w(major minor patch)
|
8
|
+
BUMPS = %w(major minor patch pre)
|
9
|
+
PRERELEASE = ["alpha","beta","rc",nil]
|
9
10
|
OPTIONS = BUMPS | ["current"]
|
10
|
-
VERSION_REGEX = /(\d+\.\d+\.\d+)/
|
11
|
+
VERSION_REGEX = /(\d+\.\d+\.\d+(?:-(?:#{PRERELEASE.compact.join('|')}))?)/
|
11
12
|
|
12
13
|
def self.run(bump, options)
|
13
14
|
case bump
|
14
|
-
when
|
15
|
+
when *BUMPS
|
15
16
|
bump(bump, options)
|
16
17
|
when "current"
|
17
18
|
current
|
@@ -96,17 +97,23 @@ module Bump
|
|
96
97
|
end
|
97
98
|
|
98
99
|
def self.next_version(current, part)
|
99
|
-
|
100
|
+
current, prerelease = current.split('-')
|
101
|
+
major, minor, patch, *other = current.split('.')
|
100
102
|
case part
|
101
103
|
when "major"
|
102
|
-
|
104
|
+
major, minor, patch, prerelease = major.succ, 0, 0, nil
|
103
105
|
when "minor"
|
104
|
-
|
106
|
+
minor, patch, prerelease = minor.succ, 0, nil
|
105
107
|
when "patch"
|
106
|
-
|
108
|
+
patch = patch.succ
|
109
|
+
when "pre"
|
110
|
+
prerelease.strip! if prerelease.respond_to? :strip
|
111
|
+
prerelease = PRERELEASE[PRERELEASE.index(prerelease).succ % PRERELEASE.length]
|
107
112
|
else
|
108
113
|
raise "unknown part #{part.inspect}"
|
109
114
|
end
|
115
|
+
version = [major, minor, patch, *other].compact.join('.')
|
116
|
+
[version, prerelease].compact.join('-')
|
110
117
|
end
|
111
118
|
end
|
112
119
|
end
|
data/spec/bump_spec.rb
CHANGED
@@ -145,28 +145,87 @@ describe Bump do
|
|
145
145
|
end
|
146
146
|
|
147
147
|
context "version in VERSION" do
|
148
|
+
let(:version) { "1.2.3" }
|
149
|
+
|
148
150
|
before do
|
149
|
-
write "VERSION", "
|
151
|
+
write "VERSION", "#{version}\n"
|
150
152
|
end
|
151
153
|
|
152
154
|
it "show current" do
|
153
|
-
bump("current").should include("
|
154
|
-
read("VERSION").should
|
155
|
+
bump("current").should include("#{version}")
|
156
|
+
read("VERSION").should include("#{version}")
|
155
157
|
end
|
156
158
|
|
157
159
|
it "should bump version" do
|
158
160
|
bump("minor").should include("1.3.0")
|
159
|
-
read("VERSION").should
|
161
|
+
read("VERSION").should include("1.3.0")
|
160
162
|
end
|
161
163
|
|
162
164
|
it "should bump if a gemspec & version.rb exists and leave it alone" do
|
163
165
|
write_gemspec "File.read('VERSION')"
|
164
166
|
write_version_rb "File.read('VERSION')"
|
165
167
|
bump("minor").should include("1.3.0")
|
166
|
-
read("VERSION").should
|
168
|
+
read("VERSION").should include("1.3.0")
|
167
169
|
read(version_rb_file).should include("VERSION = File.read('VERSION')")
|
168
170
|
read(gemspec).should include("version = File.read('VERSION')")
|
169
171
|
end
|
172
|
+
|
173
|
+
context "with pre-release identifier" do
|
174
|
+
let(:version) { "1.2.3-alpha" }
|
175
|
+
before do
|
176
|
+
write "VERSION", "#{version}\n"
|
177
|
+
end
|
178
|
+
|
179
|
+
it "show current" do
|
180
|
+
bump("current").should include(version)
|
181
|
+
read("VERSION").should include(version)
|
182
|
+
end
|
183
|
+
|
184
|
+
it "minor should drop prerelease" do
|
185
|
+
bump("minor").should include("1.3.0")
|
186
|
+
read("VERSION").should include("1.3.0")
|
187
|
+
bump("minor").should_not include("alpha")
|
188
|
+
read("VERSION").should_not include("alpha")
|
189
|
+
end
|
190
|
+
|
191
|
+
it "major should drop prerelease" do
|
192
|
+
bump("major").should include("2.0.0")
|
193
|
+
read("VERSION").should include("2.0.0")
|
194
|
+
bump("major").should_not include("alpha")
|
195
|
+
read("VERSION").should_not include("alpha")
|
196
|
+
end
|
197
|
+
|
198
|
+
context "alpha" do
|
199
|
+
it "should bump to beta" do
|
200
|
+
bump("pre").should include("1.2.3-beta")
|
201
|
+
read("VERSION").should include("1.2.3-beta")
|
202
|
+
end
|
203
|
+
end
|
204
|
+
|
205
|
+
context "beta" do
|
206
|
+
let(:version) { "1.2.3-beta" }
|
207
|
+
it "should bump to rc" do
|
208
|
+
bump("pre").should include("1.2.3-rc")
|
209
|
+
read("VERSION").should include("1.2.3-rc")
|
210
|
+
end
|
211
|
+
end
|
212
|
+
|
213
|
+
context "rc" do
|
214
|
+
let(:version) { "1.2.3-rc" }
|
215
|
+
it "should bump to final" do
|
216
|
+
bump("pre").should include("1.2.3")
|
217
|
+
read("VERSION").should include("1.2.3")
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
221
|
+
context "final" do
|
222
|
+
let(:version) { "1.2.3" }
|
223
|
+
it "should bump to alpha" do
|
224
|
+
bump("pre").should include("1.2.3-alpha")
|
225
|
+
read("VERSION").should include("1.2.3-alpha")
|
226
|
+
end
|
227
|
+
end
|
228
|
+
end
|
170
229
|
end
|
171
230
|
|
172
231
|
context "with a Gemfile" do
|