bump 0.1.2 → 0.1.3
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/bump.gemspec +6 -1
- data/lib/bump.rb +29 -26
- data/test/bump_spec.rb +33 -0
- data/test/fixture/fixture.gemspec +21 -0
- metadata +11 -8
data/bump.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "bump"
|
3
|
-
s.version = "0.1.
|
3
|
+
s.version = "0.1.3"
|
4
4
|
s.author = "Gregory Marcilhacy"
|
5
5
|
s.email = "g.marcilhacy@gmail.com"
|
6
6
|
s.homepage = "http://github.com/gregorymp/bump"
|
@@ -13,6 +13,11 @@ Gem::Specification.new do |s|
|
|
13
13
|
lib/bump.rb
|
14
14
|
)
|
15
15
|
|
16
|
+
s.test_files = %w(
|
17
|
+
test/bump_spec.rb
|
18
|
+
test/fixture/fixture.gemspec
|
19
|
+
)
|
20
|
+
|
16
21
|
s.require_path = "lib"
|
17
22
|
s.executables = ["bump"]
|
18
23
|
|
data/lib/bump.rb
CHANGED
@@ -1,16 +1,18 @@
|
|
1
1
|
module Bump
|
2
2
|
|
3
|
+
class InvalidOptionError < StandardError; end
|
4
|
+
class UnfoundVersionError < StandardError; end
|
5
|
+
class TooManyGemspecsFoundError < StandardError; end
|
6
|
+
class UnfoundGemspecError < StandardError; end
|
7
|
+
|
3
8
|
class Bump
|
4
9
|
|
10
|
+
attr_accessor :bump, :output, :gemspec_path, :version, :next_version
|
11
|
+
|
5
12
|
BUMPS = %w(major minor tiny)
|
6
13
|
OPTIONS = BUMPS | ["current"]
|
7
14
|
VERSION_REGEX = /version\s*=\s*["|'](\d.\d.\d)["|']/
|
8
15
|
|
9
|
-
class InvalidOptionError < StandardError; end
|
10
|
-
class UnfoundVersionError < StandardError; end
|
11
|
-
class TooManyGemspecsFoundError < StandardError; end
|
12
|
-
class UnfoundGemspecError < StandardError; end
|
13
|
-
|
14
16
|
def initialize(bump)
|
15
17
|
@bump = bump.is_a?(Array) ? bump.first : bump
|
16
18
|
end
|
@@ -19,45 +21,47 @@ module Bump
|
|
19
21
|
begin
|
20
22
|
raise InvalidOptionError unless OPTIONS.include?(@bump)
|
21
23
|
|
22
|
-
|
23
|
-
|
24
|
+
@gemspec_path = find_gemspec_file if @gemspec_path.nil?
|
25
|
+
@version = find_current_version
|
24
26
|
|
25
27
|
case @bump
|
26
28
|
when "major", "minor", "tiny"
|
27
|
-
bump
|
29
|
+
bump
|
28
30
|
when "current"
|
29
|
-
current
|
31
|
+
current
|
30
32
|
else
|
31
33
|
raise Exception
|
32
34
|
end
|
33
35
|
|
34
36
|
rescue InvalidOptionError
|
35
|
-
|
37
|
+
@output = "Invalid option. Choose between #{OPTIONS.join(',')}."
|
36
38
|
rescue UnfoundVersionError
|
37
|
-
|
39
|
+
@output = "Unable to find your gem version"
|
38
40
|
rescue UnfoundGemspecError
|
39
|
-
|
41
|
+
@output = "Unable to find gemspec file"
|
40
42
|
rescue TooManyGemspecsFoundError
|
41
|
-
|
43
|
+
@output = "More than one gemspec file"
|
42
44
|
rescue Exception => e
|
43
|
-
|
44
|
-
end
|
45
|
+
@output = "Something wrong happened: #{e.message}"
|
46
|
+
end
|
47
|
+
puts @output
|
48
|
+
return @output
|
45
49
|
end
|
46
50
|
|
47
51
|
private
|
48
52
|
|
49
|
-
def bump
|
50
|
-
next_version = find_next_version
|
51
|
-
system(%(ruby -i -pe "gsub(/#{
|
52
|
-
|
53
|
+
def bump
|
54
|
+
@next_version = find_next_version
|
55
|
+
system(%(ruby -i -pe "gsub(/#{@version}/, '#{@next_version}')" #{@gemspec_path}))
|
56
|
+
@output = "Bump version #{@version} to #{@next_version}"
|
53
57
|
end
|
54
58
|
|
55
|
-
def current
|
56
|
-
|
59
|
+
def current
|
60
|
+
@output = "Current version: #{@version}"
|
57
61
|
end
|
58
62
|
|
59
|
-
def find_current_version
|
60
|
-
match = File.read(
|
63
|
+
def find_current_version
|
64
|
+
match = File.read(@gemspec_path).match VERSION_REGEX
|
61
65
|
if match.nil?
|
62
66
|
raise UnfoundVersionError
|
63
67
|
else
|
@@ -72,8 +76,8 @@ module Bump
|
|
72
76
|
gemspecs.first
|
73
77
|
end
|
74
78
|
|
75
|
-
def find_next_version
|
76
|
-
match =
|
79
|
+
def find_next_version
|
80
|
+
match = @version.match /(\d).(\d).(\d)/
|
77
81
|
case @bump
|
78
82
|
when "major"
|
79
83
|
"#{match[1].to_i + 1}.0.0"
|
@@ -85,5 +89,4 @@ module Bump
|
|
85
89
|
end
|
86
90
|
|
87
91
|
end
|
88
|
-
|
89
92
|
end
|
data/test/bump_spec.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/../lib/bump.rb"
|
2
|
+
|
3
|
+
describe Bump do
|
4
|
+
|
5
|
+
it "should find current version" do
|
6
|
+
bump = Bump::Bump.new("current")
|
7
|
+
bump.gemspec_path = File.dirname(__FILE__) + "/fixture/fixture.gemspec"
|
8
|
+
output = bump.run
|
9
|
+
output.include?("1.0.0").should be_true
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should bump a tiny version" do
|
13
|
+
bump = Bump::Bump.new("tiny")
|
14
|
+
bump.gemspec_path = File.dirname(__FILE__) + "/fixture/fixture.gemspec"
|
15
|
+
output = bump.run
|
16
|
+
output.include?("1.0.1").should be_true
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should bump a minor version" do
|
20
|
+
bump = Bump::Bump.new("minor")
|
21
|
+
bump.gemspec_path = File.dirname(__FILE__) + "/fixture/fixture.gemspec"
|
22
|
+
output = bump.run
|
23
|
+
output.include?("1.1.0").should be_true
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should bump a major version" do
|
27
|
+
bump = Bump::Bump.new("major")
|
28
|
+
bump.gemspec_path = File.dirname(__FILE__) + "/fixture/fixture.gemspec"
|
29
|
+
output = bump.run
|
30
|
+
output.include?("2.0.0").should be_true
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = "fixture"
|
3
|
+
s.version = "2.0.0"
|
4
|
+
s.author = "Gregory Marcilhacy"
|
5
|
+
s.email = "g.marcilhacy@gmail.com"
|
6
|
+
s.homepage = "http://github.com/gregorymp/bump"
|
7
|
+
s.summary = "Bump your gem version file"
|
8
|
+
|
9
|
+
s.files = %w(
|
10
|
+
README.textile
|
11
|
+
bump.gemspec
|
12
|
+
bin/bump
|
13
|
+
lib/bump.rb
|
14
|
+
)
|
15
|
+
|
16
|
+
s.require_path = "lib"
|
17
|
+
s.executables = ["bump"]
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bump
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 29
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 3
|
10
|
+
version: 0.1.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Gregory Marcilhacy
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-07-
|
18
|
+
date: 2011-07-23 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|
@@ -32,6 +32,8 @@ files:
|
|
32
32
|
- bump.gemspec
|
33
33
|
- bin/bump
|
34
34
|
- lib/bump.rb
|
35
|
+
- test/bump_spec.rb
|
36
|
+
- test/fixture/fixture.gemspec
|
35
37
|
has_rdoc: true
|
36
38
|
homepage: http://github.com/gregorymp/bump
|
37
39
|
licenses: []
|
@@ -62,9 +64,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
62
64
|
requirements: []
|
63
65
|
|
64
66
|
rubyforge_project:
|
65
|
-
rubygems_version: 1.
|
67
|
+
rubygems_version: 1.6.2
|
66
68
|
signing_key:
|
67
69
|
specification_version: 3
|
68
70
|
summary: Bump your gem version file
|
69
|
-
test_files:
|
70
|
-
|
71
|
+
test_files:
|
72
|
+
- test/bump_spec.rb
|
73
|
+
- test/fixture/fixture.gemspec
|