bmp 0.9.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.bmp.yml +1 -1
- data/Gemfile +1 -1
- data/Gemfile.lock +47 -32
- data/README.md +5 -7
- data/TODO.md +6 -6
- data/bump.gemspec +1 -1
- data/lib/bump/application.rb +60 -29
- data/lib/bump/cli.rb +17 -10
- data/lib/bump/command.rb +4 -0
- data/lib/bump/domain/bump_info.rb +25 -10
- data/lib/bump/domain/bump_info_repository.rb +5 -0
- data/lib/bump/domain/file_update_rule.rb +18 -14
- data/lib/bump/domain/file_update_rule_factory.rb +2 -0
- data/lib/bump/domain/version_number.rb +29 -21
- data/lib/bump/domain/version_number_factory.rb +8 -2
- data/lib/bump/logger.rb +29 -20
- data/lib/bump/version.rb +2 -1
- data/spec/bump/domain/version_number_factory_spec.rb +9 -9
- data/spec/bump/domain/version_number_spec.rb +18 -18
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 24a5ad9d70519459e9a419e38aac65e60216c5a9
|
4
|
+
data.tar.gz: e6e3af2a6f6b3220be1823025a56c8e337e3796e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ad03ddcf95b9d97ea1d941f2b5482fb3a961daebfd87295b4653ef5dfa719c21013adfde11b1e4b50bbd9120ad2536df6cb1e386913f565eec35a3d8e72467c
|
7
|
+
data.tar.gz: 5b37da514e05a141bae4c09a32d54accec6633f49e62bf47390413034e982f2c6c073caacd24cb52f1450376b21c26f28e71c77b91b8679768ea19d8367be994
|
data/.bmp.yml
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,43 +1,58 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
bmp (0.
|
5
|
-
slop (~>
|
4
|
+
bmp (1.0.0)
|
5
|
+
slop (~> 4.2.0)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
coveralls (0.
|
11
|
-
|
12
|
-
rest-client
|
13
|
-
simplecov (
|
14
|
-
term-ansicolor
|
15
|
-
thor
|
10
|
+
coveralls (0.8.3)
|
11
|
+
json (~> 1.8)
|
12
|
+
rest-client (>= 1.6.8, < 2)
|
13
|
+
simplecov (~> 0.10.0)
|
14
|
+
term-ansicolor (~> 1.3)
|
15
|
+
thor (~> 0.19.1)
|
16
16
|
diff-lcs (1.2.5)
|
17
|
-
docile (1.1.
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
rspec
|
31
|
-
|
17
|
+
docile (1.1.5)
|
18
|
+
domain_name (0.5.25)
|
19
|
+
unf (>= 0.0.5, < 1.0.0)
|
20
|
+
http-cookie (1.0.2)
|
21
|
+
domain_name (~> 0.5)
|
22
|
+
json (1.8.3)
|
23
|
+
mime-types (2.6.2)
|
24
|
+
netrc (0.10.3)
|
25
|
+
rake (10.4.2)
|
26
|
+
rest-client (1.8.0)
|
27
|
+
http-cookie (>= 1.0.2, < 2.0)
|
28
|
+
mime-types (>= 1.16, < 3.0)
|
29
|
+
netrc (~> 0.7)
|
30
|
+
rspec (3.3.0)
|
31
|
+
rspec-core (~> 3.3.0)
|
32
|
+
rspec-expectations (~> 3.3.0)
|
33
|
+
rspec-mocks (~> 3.3.0)
|
34
|
+
rspec-core (3.3.2)
|
35
|
+
rspec-support (~> 3.3.0)
|
36
|
+
rspec-expectations (3.3.1)
|
37
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
38
|
+
rspec-support (~> 3.3.0)
|
39
|
+
rspec-mocks (3.3.2)
|
40
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
41
|
+
rspec-support (~> 3.3.0)
|
42
|
+
rspec-support (3.3.0)
|
43
|
+
simplecov (0.10.0)
|
32
44
|
docile (~> 1.1.0)
|
33
|
-
|
34
|
-
simplecov-html (~> 0.
|
35
|
-
simplecov-html (0.
|
36
|
-
slop (
|
37
|
-
term-ansicolor (1.
|
38
|
-
tins (~> 0
|
39
|
-
thor (0.
|
40
|
-
tins (
|
45
|
+
json (~> 1.8)
|
46
|
+
simplecov-html (~> 0.10.0)
|
47
|
+
simplecov-html (0.10.0)
|
48
|
+
slop (4.2.0)
|
49
|
+
term-ansicolor (1.3.2)
|
50
|
+
tins (~> 1.0)
|
51
|
+
thor (0.19.1)
|
52
|
+
tins (1.6.0)
|
53
|
+
unf (0.1.4)
|
54
|
+
unf_ext
|
55
|
+
unf_ext (0.0.7.1)
|
41
56
|
|
42
57
|
PLATFORMS
|
43
58
|
ruby
|
@@ -49,4 +64,4 @@ DEPENDENCIES
|
|
49
64
|
rake
|
50
65
|
rspec
|
51
66
|
simplecov
|
52
|
-
slop
|
67
|
+
slop (~> 4.2.0)
|
data/README.md
CHANGED
@@ -1,11 +1,9 @@
|
|
1
|
-
# Bmp
|
1
|
+
# Bmp v1.0.0
|
2
2
|
|
3
|
-
[![Gem Version](https://
|
4
|
-
[![Build Status](https://
|
5
|
-
[![Coverage Status](https://
|
6
|
-
[![Code Climate](https://
|
7
|
-
|
8
|
-
[ ![Codeship Status for kt3k/bmp](https://www.codeship.io/projects/fc1c56c0-fa28-0131-0224-76431a64aeb5/status)](https://www.codeship.io/projects/29009)
|
3
|
+
[![Gem Version](https://img.shields.io/gem/v/bmp.svg)](http://badge.fury.io/rb/bmp)
|
4
|
+
[![Build Status](https://img.shields.io/travis/kt3k/bmp.svg)](https://travis-ci.org/kt3k/bmp)
|
5
|
+
[![Coverage Status](https://img.shields.io/coveralls/kt3k/bmp.svg)](https://coveralls.io/r/kt3k/bmp)
|
6
|
+
[![Code Climate](https://img.shields.io/codeclimate/github/kt3k/bmp.svg)](https://codeclimate.com/github/kt3k/bmp)
|
9
7
|
|
10
8
|
> No hassle on bumping
|
11
9
|
|
data/TODO.md
CHANGED
@@ -1,15 +1,13 @@
|
|
1
1
|
# TODO
|
2
2
|
|
3
|
-
-
|
4
|
-
-
|
5
|
-
- support build version number (of semver)
|
3
|
+
- gh-pages yardoc
|
4
|
+
- bmp -t|--touch -> create empty .bmp.yml
|
6
5
|
|
7
6
|
- yaml parse error handling
|
8
7
|
- no `version` case handling
|
9
8
|
- no `files` case handling
|
10
9
|
|
11
|
-
-
|
12
|
-
- interactive init command
|
10
|
+
- interactive init, bump --init
|
13
11
|
|
14
12
|
- test FileRewriteRule
|
15
13
|
- test FileRewriteRuleFactory
|
@@ -21,7 +19,9 @@
|
|
21
19
|
- test Command
|
22
20
|
|
23
21
|
# DONE
|
24
|
-
|
22
|
+
- support pre-release version number (of semver)
|
23
|
+
- support build version number (of semver) - pending
|
24
|
+
- Generate documentaion
|
25
25
|
- Rename file_rewrite_rule to file_update_rule
|
26
26
|
- Rename version_descriptor to bump_info
|
27
27
|
- Refactor application
|
data/bump.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_runtime_dependency "slop", "~>
|
21
|
+
spec.add_runtime_dependency "slop", "~> 4.2.0"
|
22
22
|
|
23
23
|
spec.add_development_dependency "bundler", "~> 1.3"
|
24
24
|
spec.add_development_dependency "rake"
|
data/lib/bump/application.rb
CHANGED
@@ -4,6 +4,7 @@ require 'bump/command'
|
|
4
4
|
|
5
5
|
module Bump
|
6
6
|
|
7
|
+
# The application
|
7
8
|
class Application
|
8
9
|
|
9
10
|
# @param [Hash] options The cli options
|
@@ -19,7 +20,7 @@ module Bump
|
|
19
20
|
@logger = logger
|
20
21
|
end
|
21
22
|
|
22
|
-
#
|
23
|
+
# Returns a symbol which represents the action to perform.
|
23
24
|
#
|
24
25
|
# @return [Symbol]
|
25
26
|
def selectAction
|
@@ -35,7 +36,7 @@ module Bump
|
|
35
36
|
return :info
|
36
37
|
end
|
37
38
|
|
38
|
-
if @options[:major] || @options[:minor] || @options[:patch] || @options[:commit]
|
39
|
+
if @options[:major] || @options[:minor] || @options[:patch] || @options[:commit] || @options[:preid]
|
39
40
|
return :bump
|
40
41
|
end
|
41
42
|
|
@@ -44,11 +45,15 @@ module Bump
|
|
44
45
|
end
|
45
46
|
|
46
47
|
# handler of `bmp --version`
|
48
|
+
#
|
49
|
+
# @return [void]
|
47
50
|
def actionVersion
|
48
51
|
log @version
|
49
52
|
end
|
50
53
|
|
51
54
|
# handler of `bmp --help`
|
55
|
+
#
|
56
|
+
# @return [void]
|
52
57
|
def actionHelp
|
53
58
|
log @help
|
54
59
|
end
|
@@ -74,6 +79,7 @@ module Bump
|
|
74
79
|
# Saves the bump info
|
75
80
|
#
|
76
81
|
# @param [Bump::BumpInfo] bumpInfo
|
82
|
+
# @return [void]
|
77
83
|
def saveBumpInfo bumpInfo
|
78
84
|
repo = BumpInfoRepository.new @file
|
79
85
|
|
@@ -83,6 +89,7 @@ module Bump
|
|
83
89
|
# Shows the version patterns.
|
84
90
|
#
|
85
91
|
# @param [Bump::BumpInfo] bumpInfo
|
92
|
+
# @return [void]
|
86
93
|
def showVersionPatterns bumpInfo
|
87
94
|
|
88
95
|
log "Current Version:", false
|
@@ -103,6 +110,8 @@ module Bump
|
|
103
110
|
end
|
104
111
|
|
105
112
|
# handler of `bmp [--info]`
|
113
|
+
#
|
114
|
+
# @return [void]
|
106
115
|
def actionInfo
|
107
116
|
|
108
117
|
bumpInfo = getBumpInfo
|
@@ -117,33 +126,12 @@ module Bump
|
|
117
126
|
|
118
127
|
end
|
119
128
|
|
120
|
-
# handler of `bmp --patch|--minor|--major|--commit`
|
121
|
-
def actionBump
|
122
|
-
|
123
|
-
bumpInfo = getBumpInfo
|
124
|
-
|
125
|
-
if @options[:patch]
|
126
|
-
bumpInfo.patchBump
|
127
|
-
|
128
|
-
log 'Bump patch level'
|
129
|
-
log_green " #{bumpInfo.beforeVersion} => #{bumpInfo.afterVersion}"
|
130
|
-
end
|
131
|
-
|
132
|
-
if @options[:minor]
|
133
|
-
bumpInfo.minorBump
|
134
129
|
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
bumpInfo.majorBump
|
141
|
-
|
142
|
-
log 'Bump major level'
|
143
|
-
log_green " #{bumpInfo.beforeVersion} => #{bumpInfo.afterVersion}"
|
144
|
-
end
|
145
|
-
|
146
|
-
log
|
130
|
+
# Checks the bumping is possible.
|
131
|
+
#
|
132
|
+
# @param [Bump::BumpInfo] bumpInfo
|
133
|
+
# @return [void]
|
134
|
+
def checkBumpInfo bumpInfo
|
147
135
|
|
148
136
|
if not bumpInfo.check
|
149
137
|
log_red "Some patterns are invalid!"
|
@@ -155,8 +143,13 @@ module Bump
|
|
155
143
|
exit 1
|
156
144
|
end
|
157
145
|
|
158
|
-
|
146
|
+
end
|
159
147
|
|
148
|
+
# Reports the bumping details.
|
149
|
+
#
|
150
|
+
# @param [Bump::BumpInfo] bumpInfo
|
151
|
+
# @return [void]
|
152
|
+
def report bumpInfo
|
160
153
|
bumpInfo.updateRules.each do |rule|
|
161
154
|
|
162
155
|
log "#{rule.file}"
|
@@ -165,6 +158,39 @@ module Bump
|
|
165
158
|
log
|
166
159
|
|
167
160
|
end
|
161
|
+
end
|
162
|
+
|
163
|
+
# handler of `bmp --patch|--minor|--major|--commit`
|
164
|
+
#
|
165
|
+
# @return [void]
|
166
|
+
def actionBump
|
167
|
+
|
168
|
+
bumpInfo = getBumpInfo
|
169
|
+
|
170
|
+
[:major, :minor, :patch].each do |level|
|
171
|
+
if @options[level]
|
172
|
+
bumpInfo.bump level
|
173
|
+
log "Bump #{level} level"
|
174
|
+
log_green " #{bumpInfo.beforeVersion} => #{bumpInfo.afterVersion}"
|
175
|
+
break
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
if @options[:preid]
|
180
|
+
preid = @options[:preid]
|
181
|
+
bumpInfo.setPreid preid
|
182
|
+
log "Set pre-release version id: ", false
|
183
|
+
log_green preid
|
184
|
+
log_green " #{bumpInfo.beforeVersion} => #{bumpInfo.afterVersion}"
|
185
|
+
end
|
186
|
+
|
187
|
+
log
|
188
|
+
|
189
|
+
checkBumpInfo bumpInfo
|
190
|
+
|
191
|
+
bumpInfo.performUpdate
|
192
|
+
|
193
|
+
report bumpInfo
|
168
194
|
|
169
195
|
saveBumpInfo bumpInfo
|
170
196
|
|
@@ -178,6 +204,8 @@ module Bump
|
|
178
204
|
end
|
179
205
|
|
180
206
|
# The entry point
|
207
|
+
#
|
208
|
+
# @return [void]
|
181
209
|
def main
|
182
210
|
|
183
211
|
action = selectAction
|
@@ -199,6 +227,7 @@ module Bump
|
|
199
227
|
#
|
200
228
|
# @param [String] message
|
201
229
|
# @param [Boolean] newline
|
230
|
+
# @return [void]
|
202
231
|
def log message = '', newline = true
|
203
232
|
|
204
233
|
@logger.log message, newline
|
@@ -209,6 +238,7 @@ module Bump
|
|
209
238
|
#
|
210
239
|
# @param [String] message
|
211
240
|
# @param [Boolean] newline
|
241
|
+
# @return [void]
|
212
242
|
def log_red message, newline = true
|
213
243
|
|
214
244
|
@logger.log_red message, newline
|
@@ -219,6 +249,7 @@ module Bump
|
|
219
249
|
#
|
220
250
|
# @param [String] message
|
221
251
|
# @param [Boolean] newline
|
252
|
+
# @return [void]
|
222
253
|
def log_green message, newline = true
|
223
254
|
|
224
255
|
@logger.log_green message, newline
|
data/lib/bump/cli.rb
CHANGED
@@ -5,24 +5,31 @@ require 'slop'
|
|
5
5
|
|
6
6
|
module Bump
|
7
7
|
|
8
|
+
# The command line interface
|
8
9
|
class CLI
|
9
10
|
|
11
|
+
# The bump info filename
|
10
12
|
VERSION_FILE = '.bmp.yml'
|
11
13
|
|
14
|
+
# The cli name
|
12
15
|
CLI_NAME = 'bmp'
|
13
16
|
|
17
|
+
# The main routine
|
18
|
+
#
|
19
|
+
# @return [void]
|
14
20
|
def main
|
15
21
|
|
16
|
-
opts = Slop.parse do
|
17
|
-
banner "Usage: #{CLI_NAME} [-p|-m|-j] [-c]"
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
22
|
+
opts = Slop.parse do |o|
|
23
|
+
o.banner = "Usage: #{CLI_NAME} [-p|-m|-j] [-c]"
|
24
|
+
|
25
|
+
o.bool '-i', '--info', 'show current version info'
|
26
|
+
o.bool '-p', '--patch', 'bump patch (0.0.1) level'
|
27
|
+
o.bool '-m', '--minor', 'bump minor (0.1.0) level'
|
28
|
+
o.bool '-j', '--major', 'bump major (1.0.0) level'
|
29
|
+
o.bool '-c', '--commit', 'commit bump changes (git required)'
|
30
|
+
o.bool '-h', '--help', 'show this help and exit'
|
31
|
+
o.bool '-v', '--version', 'show version and exit'
|
32
|
+
o.string '-s', '--preid', 'set pre release version id (e.g. alpha, beta.1)'
|
26
33
|
end
|
27
34
|
|
28
35
|
app = Application.new opts.to_hash, opts.to_s, "#{CLI_NAME} v#{Bump::VERSION}", VERSION_FILE, Logger.new
|
data/lib/bump/command.rb
CHANGED
@@ -2,12 +2,16 @@
|
|
2
2
|
|
3
3
|
module Bump
|
4
4
|
|
5
|
+
# Command class executes shell command
|
5
6
|
class Command
|
6
7
|
|
8
|
+
# @param [Bump::Logger] logger
|
7
9
|
def initialize logger
|
8
10
|
@logger = logger
|
9
11
|
end
|
10
12
|
|
13
|
+
# @param [String] command
|
14
|
+
# @return [void]
|
11
15
|
def exec command
|
12
16
|
@logger.log "===> " + command
|
13
17
|
@logger.log `#{command}`
|
@@ -3,6 +3,7 @@ require 'yaml'
|
|
3
3
|
|
4
4
|
module Bump
|
5
5
|
|
6
|
+
# The bump information model
|
6
7
|
class BumpInfo
|
7
8
|
|
8
9
|
# @param [Bump::VersionNumber] version
|
@@ -16,36 +17,48 @@ module Bump
|
|
16
17
|
|
17
18
|
end
|
18
19
|
|
20
|
+
# Returns the version number object
|
21
|
+
#
|
22
|
+
# @return [Bump::VersionNumber]
|
19
23
|
def version
|
20
24
|
@version
|
21
25
|
end
|
22
26
|
|
27
|
+
# Returns files setting list
|
28
|
+
#
|
29
|
+
# @return [Array]
|
23
30
|
def files
|
24
31
|
@files
|
25
32
|
end
|
26
33
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
@version.bump 'minor'
|
34
|
+
# Performs bumping version
|
35
|
+
#
|
36
|
+
# @param [Symbol] level
|
37
|
+
# @return [void]
|
38
|
+
def bump level
|
39
|
+
@version.bump level
|
34
40
|
@after_version = @version.to_s
|
35
41
|
end
|
36
42
|
|
37
|
-
|
38
|
-
|
43
|
+
# Sets the preid
|
44
|
+
#
|
45
|
+
# @return [void]
|
46
|
+
def setPreid preid
|
47
|
+
@version.setPreid preid
|
39
48
|
@after_version = @version.to_s
|
40
49
|
end
|
41
50
|
|
51
|
+
# Gets the file update rules
|
52
|
+
#
|
53
|
+
# @return [Array<Bump::FileUpdateRules>]
|
42
54
|
def updateRules
|
43
55
|
createUpdateRules
|
44
56
|
end
|
45
57
|
|
46
58
|
# Creates file update rules according to the current settings.
|
47
59
|
#
|
48
|
-
# @
|
60
|
+
# @private
|
61
|
+
# @return [Array<Bump::FileUpdateRule>]
|
49
62
|
def createUpdateRules
|
50
63
|
@files.map { |file, pattern|
|
51
64
|
FileUpdateRuleFactory.create(file, pattern, @before_version, @after_version)
|
@@ -53,6 +66,8 @@ module Bump
|
|
53
66
|
end
|
54
67
|
|
55
68
|
# Performs all updates.
|
69
|
+
#
|
70
|
+
# @return [void]
|
56
71
|
def performUpdate
|
57
72
|
|
58
73
|
createUpdateRules.each do |rule|
|
@@ -4,8 +4,11 @@ require 'yaml'
|
|
4
4
|
|
5
5
|
module Bump
|
6
6
|
|
7
|
+
# The repository class for the bump info
|
8
|
+
# persistence in file as yaml string
|
7
9
|
class BumpInfoRepository
|
8
10
|
|
11
|
+
# @param [String] file
|
9
12
|
def initialize file
|
10
13
|
@file = file
|
11
14
|
end
|
@@ -13,6 +16,7 @@ module Bump
|
|
13
16
|
# Gets the bump info from the given file
|
14
17
|
#
|
15
18
|
# @param [String] file
|
19
|
+
# @return [Bump::BumpInfo]
|
16
20
|
def fromFile
|
17
21
|
|
18
22
|
config = YAML.load_file @file
|
@@ -26,6 +30,7 @@ module Bump
|
|
26
30
|
# Saves the bump info
|
27
31
|
#
|
28
32
|
# @param [Bump::BumpInfo] bumpInfo
|
33
|
+
# @return [void]
|
29
34
|
def save bumpInfo
|
30
35
|
File.write @file, toYaml(bumpInfo)
|
31
36
|
end
|
@@ -2,8 +2,12 @@
|
|
2
2
|
|
3
3
|
module Bump
|
4
4
|
|
5
|
+
# The file update rule model
|
6
|
+
#
|
7
|
+
# is able to perform actual file update
|
5
8
|
class FileUpdateRule
|
6
9
|
|
10
|
+
# The placeholder pattern
|
7
11
|
PLACEHOLDER_PATTERN = '%.%.%'
|
8
12
|
|
9
13
|
# @param [String] file
|
@@ -19,18 +23,30 @@ module Bump
|
|
19
23
|
@after_pattern = @pattern.sub PLACEHOLDER_PATTERN, @after_version
|
20
24
|
end
|
21
25
|
|
26
|
+
# Gets the file name
|
27
|
+
#
|
28
|
+
# @return [String]
|
22
29
|
def file
|
23
30
|
@file
|
24
31
|
end
|
25
32
|
|
33
|
+
# Gets the version string before bumping
|
34
|
+
#
|
35
|
+
# @return [String]
|
26
36
|
def beforePattern
|
27
37
|
@before_pattern
|
28
38
|
end
|
29
39
|
|
40
|
+
# Gets the version string after bumping
|
41
|
+
#
|
42
|
+
# @return [String]
|
30
43
|
def afterPattern
|
31
44
|
@after_pattern
|
32
45
|
end
|
33
46
|
|
47
|
+
# Gets the contents of the file
|
48
|
+
#
|
49
|
+
# @return [String]
|
34
50
|
def fileGetContents
|
35
51
|
File.read @file, :encoding => Encoding::UTF_8
|
36
52
|
end
|
@@ -44,21 +60,9 @@ module Bump
|
|
44
60
|
|
45
61
|
# Performs file update
|
46
62
|
#
|
47
|
-
# @return [
|
63
|
+
# @return [void]
|
48
64
|
def perform
|
49
|
-
|
50
|
-
|
51
|
-
if contents.index @before_pattern
|
52
|
-
|
53
|
-
File.write @file, contents.sub(@before_pattern, @after_pattern)
|
54
|
-
|
55
|
-
return true
|
56
|
-
|
57
|
-
else
|
58
|
-
|
59
|
-
return false
|
60
|
-
|
61
|
-
end
|
65
|
+
File.write @file, fileGetContents.sub(@before_pattern, @after_pattern)
|
62
66
|
end
|
63
67
|
|
64
68
|
end
|
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
module Bump
|
4
4
|
|
5
|
+
# The factory class for the file update rule model
|
5
6
|
class FileUpdateRuleFactory
|
6
7
|
|
7
8
|
# Creates the file update rule from the given params.
|
@@ -10,6 +11,7 @@ module Bump
|
|
10
11
|
# @param [String|Array] param The version update info
|
11
12
|
# @param [String] before_version
|
12
13
|
# @param [String] after_version
|
14
|
+
# @return [Bump::FileUpdateRule, Array<Bump::FileUpdateRule>]
|
13
15
|
def self.create file, param, before_version, after_version
|
14
16
|
|
15
17
|
case param
|
@@ -2,52 +2,60 @@
|
|
2
2
|
|
3
3
|
module Bump
|
4
4
|
|
5
|
+
# The version number model
|
5
6
|
class VersionNumber
|
6
7
|
|
7
|
-
|
8
|
+
# @param [Integer] major
|
9
|
+
# @param [Integer] minor
|
10
|
+
# @param [Integer] patch
|
11
|
+
# @param [String, nil] preid
|
12
|
+
def initialize major, minor, patch, preid = nil
|
8
13
|
@major = major
|
9
14
|
@minor = minor
|
10
15
|
@patch = patch
|
11
|
-
@
|
16
|
+
@preid = preid
|
12
17
|
end
|
13
18
|
|
19
|
+
# Bumps the version at the given level
|
20
|
+
#
|
21
|
+
# @param [Symbol] level
|
22
|
+
# @return [void]
|
14
23
|
def bump level
|
15
24
|
|
16
25
|
case level
|
17
|
-
when
|
26
|
+
when :major
|
18
27
|
@major += 1
|
19
28
|
@minor = 0
|
20
29
|
@patch = 0
|
21
|
-
|
22
|
-
when 'minor'
|
30
|
+
when :minor
|
23
31
|
@minor += 1
|
24
32
|
@patch = 0
|
25
|
-
|
26
|
-
when 'patch'
|
33
|
+
when :patch
|
27
34
|
@patch += 1
|
28
|
-
@suffix = ''
|
29
35
|
end
|
36
|
+
@preid = nil
|
30
37
|
|
31
38
|
end
|
32
39
|
|
33
|
-
|
34
|
-
|
40
|
+
# Sets the preid
|
41
|
+
#
|
42
|
+
# @return [void]
|
43
|
+
def setPreid preid
|
44
|
+
@preid = preid
|
35
45
|
end
|
36
46
|
|
37
|
-
|
38
|
-
|
39
|
-
|
47
|
+
# Returns the string representation of the version
|
48
|
+
#
|
49
|
+
# @return [String]
|
50
|
+
def to_s
|
51
|
+
label = @major.to_s + '.' + @minor.to_s + '.' + @patch.to_s
|
40
52
|
|
41
|
-
|
42
|
-
|
43
|
-
|
53
|
+
if @preid
|
54
|
+
label = label + '-' + @preid
|
55
|
+
end
|
44
56
|
|
45
|
-
|
46
|
-
@suffix = suffix
|
47
|
-
end
|
57
|
+
label
|
48
58
|
|
49
|
-
def to_s
|
50
|
-
@major.to_s + '.' + @minor.to_s + '.' + @patch.to_s + @suffix
|
51
59
|
end
|
52
60
|
|
53
61
|
end
|
@@ -2,14 +2,20 @@
|
|
2
2
|
|
3
3
|
module Bump
|
4
4
|
|
5
|
+
# The factory class for the version number
|
5
6
|
class VersionNumberFactory
|
6
7
|
|
7
|
-
|
8
|
+
# Regexp for version expression
|
9
|
+
VERSION_REGEXP = /^(\d+).(\d+).(\d+)(-(\S*))?$/
|
8
10
|
|
11
|
+
# Creates the version number object from the string
|
12
|
+
#
|
13
|
+
# @param [String] version_string
|
14
|
+
# @return [Bump::VersionNumber]
|
9
15
|
def self.fromString version_string
|
10
16
|
match = VERSION_REGEXP.match version_string
|
11
17
|
|
12
|
-
return VersionNumber.new match[1].to_i, match[2].to_i, match[3].to_i, match[
|
18
|
+
return VersionNumber.new match[1].to_i, match[2].to_i, match[3].to_i, match[5]
|
13
19
|
end
|
14
20
|
|
15
21
|
end
|
data/lib/bump/logger.rb
CHANGED
@@ -2,10 +2,16 @@
|
|
2
2
|
|
3
3
|
module Bump
|
4
4
|
|
5
|
+
# The logging class
|
5
6
|
class Logger
|
6
7
|
|
7
8
|
no_color = false
|
8
9
|
|
10
|
+
# Logs the message.
|
11
|
+
#
|
12
|
+
# @param [String] message
|
13
|
+
# @param [Boolean] breakline
|
14
|
+
# @return [void]
|
9
15
|
def log message = '', breakline = true
|
10
16
|
print message
|
11
17
|
|
@@ -14,34 +20,29 @@ module Bump
|
|
14
20
|
end
|
15
21
|
end
|
16
22
|
|
23
|
+
# Logs the message in green.
|
24
|
+
#
|
25
|
+
# @param [String] message
|
26
|
+
# @param [Boolean] breakline
|
27
|
+
# @return [void]
|
17
28
|
def log_green message = '', breakline = true
|
18
29
|
log green(message), breakline
|
19
30
|
end
|
20
31
|
|
32
|
+
# Logs the message in red.
|
33
|
+
#
|
34
|
+
# @param [String] message
|
35
|
+
# @param [Boolean] breakline
|
36
|
+
# @return [void]
|
21
37
|
def log_red message = '', breakline = true
|
22
38
|
log red(message), breakline
|
23
39
|
end
|
24
40
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
puts message, breakline
|
31
|
-
end
|
32
|
-
|
33
|
-
def info message = '', breakline = true
|
34
|
-
puts message, breakline
|
35
|
-
end
|
36
|
-
|
37
|
-
def debug message = '', breakline = true
|
38
|
-
puts message, breakline
|
39
|
-
end
|
40
|
-
|
41
|
-
def verbose message = '', breakline = true
|
42
|
-
puts message, breakline
|
43
|
-
end
|
44
|
-
|
41
|
+
# Colorize the text by the color code.
|
42
|
+
#
|
43
|
+
# @param [String] text
|
44
|
+
# @param [Integer] color_code
|
45
|
+
# @return [String]
|
45
46
|
def colorize text, color_code
|
46
47
|
if @no_color
|
47
48
|
text
|
@@ -50,10 +51,18 @@ module Bump
|
|
50
51
|
end
|
51
52
|
end
|
52
53
|
|
54
|
+
# Returns a green string.
|
55
|
+
#
|
56
|
+
# @param [String] text
|
57
|
+
# @return [String]
|
53
58
|
def green text
|
54
59
|
colorize text, 32
|
55
60
|
end
|
56
61
|
|
62
|
+
# Returns a red string.
|
63
|
+
#
|
64
|
+
# @param [String] text
|
65
|
+
# @return [String]
|
57
66
|
def red text
|
58
67
|
colorize text, 31
|
59
68
|
end
|
data/lib/bump/version.rb
CHANGED
@@ -8,29 +8,29 @@ describe Bump::VersionNumberFactory do
|
|
8
8
|
|
9
9
|
it "creates version object from version string" do
|
10
10
|
|
11
|
-
version = Bump::VersionNumberFactory.fromString "1.2.
|
11
|
+
version = Bump::VersionNumberFactory.fromString "1.2.3-a"
|
12
12
|
|
13
|
-
expect(version.to_s).to eq "1.2.
|
13
|
+
expect(version.to_s).to eq "1.2.3-a"
|
14
14
|
|
15
|
-
version.
|
15
|
+
version.bump :patch
|
16
16
|
|
17
17
|
expect(version.to_s).to eq "1.2.4"
|
18
18
|
|
19
|
-
version.
|
19
|
+
version.bump :minor
|
20
20
|
|
21
21
|
expect(version.to_s).to eq "1.3.0"
|
22
22
|
|
23
|
-
version.
|
23
|
+
version.bump :major
|
24
24
|
|
25
25
|
expect(version.to_s).to eq "2.0.0"
|
26
26
|
|
27
|
-
version.
|
27
|
+
version.setPreid 'rc1'
|
28
28
|
|
29
|
-
expect(version.to_s).to eq "2.0.
|
29
|
+
expect(version.to_s).to eq "2.0.0-rc1"
|
30
30
|
|
31
|
-
version = Bump::VersionNumberFactory.fromString "1.2.
|
31
|
+
version = Bump::VersionNumberFactory.fromString "1.2.100-abc"
|
32
32
|
|
33
|
-
version.
|
33
|
+
version.bump :patch
|
34
34
|
|
35
35
|
expect(version.to_s).to eq "1.2.101"
|
36
36
|
|
@@ -17,19 +17,19 @@ describe Bump::VersionNumber do
|
|
17
17
|
# with a suffix
|
18
18
|
version = Bump::VersionNumber.new 1, 2, 3, 'rc1'
|
19
19
|
|
20
|
-
expect(version.to_s).to eq '1.2.
|
20
|
+
expect(version.to_s).to eq '1.2.3-rc1'
|
21
21
|
|
22
22
|
end
|
23
23
|
|
24
24
|
end
|
25
25
|
|
26
|
-
describe "#
|
26
|
+
describe "#bump :patch" do
|
27
27
|
|
28
28
|
it "bumps patch level" do
|
29
29
|
|
30
30
|
version = Bump::VersionNumber.new 1, 2, 3
|
31
31
|
|
32
|
-
version.
|
32
|
+
version.bump :patch
|
33
33
|
|
34
34
|
expect(version.to_s).to eq '1.2.4'
|
35
35
|
|
@@ -39,7 +39,7 @@ describe Bump::VersionNumber do
|
|
39
39
|
|
40
40
|
version = Bump::VersionNumber.new 0, 1, 10
|
41
41
|
|
42
|
-
version.
|
42
|
+
version.bump :patch
|
43
43
|
|
44
44
|
expect(version.to_s).to eq '0.1.11'
|
45
45
|
|
@@ -49,7 +49,7 @@ describe Bump::VersionNumber do
|
|
49
49
|
|
50
50
|
version = Bump::VersionNumber.new 1, 2, 3, 'rc1'
|
51
51
|
|
52
|
-
version.
|
52
|
+
version.bump :patch
|
53
53
|
|
54
54
|
expect(version.to_s).to eq '1.2.4'
|
55
55
|
|
@@ -57,13 +57,13 @@ describe Bump::VersionNumber do
|
|
57
57
|
|
58
58
|
end
|
59
59
|
|
60
|
-
describe "#
|
60
|
+
describe "#bump :minor" do
|
61
61
|
|
62
62
|
it "bumps patch level" do
|
63
63
|
|
64
64
|
version = Bump::VersionNumber.new 1, 2, 3
|
65
65
|
|
66
|
-
version.
|
66
|
+
version.bump :minor
|
67
67
|
|
68
68
|
expect(version.to_s).to eq '1.3.0'
|
69
69
|
|
@@ -73,7 +73,7 @@ describe Bump::VersionNumber do
|
|
73
73
|
|
74
74
|
version = Bump::VersionNumber.new 1, 2, 3, 'rc1'
|
75
75
|
|
76
|
-
version.
|
76
|
+
version.bump :minor
|
77
77
|
|
78
78
|
expect(version.to_s).to eq '1.3.0'
|
79
79
|
|
@@ -81,13 +81,13 @@ describe Bump::VersionNumber do
|
|
81
81
|
|
82
82
|
end
|
83
83
|
|
84
|
-
describe "#
|
84
|
+
describe "#bump :major" do
|
85
85
|
|
86
86
|
it "bumps patch level" do
|
87
87
|
|
88
88
|
version = Bump::VersionNumber.new 1, 2, 3
|
89
89
|
|
90
|
-
version.
|
90
|
+
version.bump :major
|
91
91
|
|
92
92
|
expect(version.to_s).to eq '2.0.0'
|
93
93
|
|
@@ -97,7 +97,7 @@ describe Bump::VersionNumber do
|
|
97
97
|
|
98
98
|
version = Bump::VersionNumber.new 1, 2, 3, 'rc1'
|
99
99
|
|
100
|
-
version.
|
100
|
+
version.bump :major
|
101
101
|
|
102
102
|
expect(version.to_s).to eq '2.0.0'
|
103
103
|
|
@@ -105,25 +105,25 @@ describe Bump::VersionNumber do
|
|
105
105
|
|
106
106
|
end
|
107
107
|
|
108
|
-
describe "#
|
108
|
+
describe "#setPreid" do
|
109
109
|
|
110
|
-
it "
|
110
|
+
it "sets the preid" do
|
111
111
|
|
112
112
|
version = Bump::VersionNumber.new 1, 2, 3
|
113
113
|
|
114
|
-
version.
|
114
|
+
version.setPreid 'rc1'
|
115
115
|
|
116
|
-
expect(version.to_s).to eq '1.2.
|
116
|
+
expect(version.to_s).to eq '1.2.3-rc1'
|
117
117
|
|
118
118
|
end
|
119
119
|
|
120
|
-
it "rewrite the
|
120
|
+
it "rewrite the preid if it is already set" do
|
121
121
|
|
122
122
|
version = Bump::VersionNumber.new 1, 2, 3, 'rc1'
|
123
123
|
|
124
|
-
version.
|
124
|
+
version.setPreid 'rc2'
|
125
125
|
|
126
|
-
expect(version.to_s).to eq '1.2.
|
126
|
+
expect(version.to_s).to eq '1.2.3-rc2'
|
127
127
|
|
128
128
|
end
|
129
129
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bmp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yoshiya Hinosawa
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 4.2.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 4.2.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|