bmp 1.2.0 → 1.3.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d2c8239d42b3a23ccafc9aa63bb1d68c0b93771c
4
- data.tar.gz: 5428fb76d0951706ff3c538d12059d8931594ba9
3
+ metadata.gz: 1be786e4639ed92e94de9d5f6ccdfc5721eb7eb9
4
+ data.tar.gz: a6c6c2bc71fc02ad26b0eaa71b128b0f525d242c
5
5
  SHA512:
6
- metadata.gz: ce2e10ce24b53b7f515106ed3b3eb83f5b4332a97718e363f127d91eb20226f0ba1046724267c8f01e3c2f3c00574e146008172e174fcd33e2ddd7a8c77156f5
7
- data.tar.gz: dd40f2c484593c87a248a8ecb77531f438debb64eec606cff7c5041592859f5d5ae5826949bf45290568300304ab7dd33a8a864171c450d4f2d9c77bc80f2caf
6
+ metadata.gz: 3ef35703e36536a76674aafd79db3bdb212ef6204ee4c8b75635b3e715efc4be2eb0dd27ce00964af2fed2857084ce20ac0d68f6a42d41bfaaf6a0c201eb4a66
7
+ data.tar.gz: fc0e6a7e78866bdc86ab75999f19070f99d8b60d3e46edda313b9983abb7c2eea46209485e5ffee9bd26fdafef1ab0abc98d182426dd4dbaf205fdb6ecf62aed
data/.bmp.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  ---
2
- version: 1.2.0
3
- commit: 'chore(version): bump to v%.%.%'
2
+ version: 1.3.1
3
+ commit: 'chore(version): :arrow_heading_up: bump to v%.%.%'
4
4
  files:
5
5
  README.md: Bmp v%.%.%
6
- lib/bump/version.rb: VERSION = "%.%.%"
6
+ lib/bump/version.rb: VERSION = '%.%.%'
@@ -3,5 +3,4 @@ root = true
3
3
  trim_trailing_whitespace = true
4
4
  insert_final_newline = true
5
5
  indent_style = space
6
- [*.rb]
7
- indent_size = 4
6
+ indent_size = 2
@@ -0,0 +1,8 @@
1
+ Metrics/LineLength:
2
+ Enabled: false
3
+ Metrics/MethodLength:
4
+ Max: 50
5
+ Metrics/ClassLength:
6
+ Max: 300
7
+ Metrics/ParameterLists:
8
+ Enabled: false
data/Gemfile CHANGED
@@ -1,12 +1,12 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- # Specify your gem's dependencies in bump.gemspec
4
3
  gemspec
5
4
 
6
5
  gem 'slop', '~> 4.2.0'
7
6
  gem 'rspec'
8
7
 
9
8
  group :test do
9
+ gem 'rubocop', '~> 0.40.0', require: false
10
10
  gem 'simplecov', require: false
11
11
  gem 'coveralls', require: false
12
12
  end
@@ -1,12 +1,13 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bmp (1.2.0)
4
+ bmp (1.3.1)
5
5
  slop (~> 4.2.0)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
+ ast (2.2.0)
10
11
  coveralls (0.8.3)
11
12
  json (~> 1.8)
12
13
  rest-client (>= 1.6.8, < 2)
@@ -22,6 +23,10 @@ GEM
22
23
  json (1.8.3)
23
24
  mime-types (2.6.2)
24
25
  netrc (0.10.3)
26
+ parser (2.3.1.0)
27
+ ast (~> 2.2)
28
+ powerpack (0.1.1)
29
+ rainbow (2.1.0)
25
30
  rake (10.4.2)
26
31
  rest-client (1.8.0)
27
32
  http-cookie (>= 1.0.2, < 2.0)
@@ -40,6 +45,13 @@ GEM
40
45
  diff-lcs (>= 1.2.0, < 2.0)
41
46
  rspec-support (~> 3.3.0)
42
47
  rspec-support (3.3.0)
48
+ rubocop (0.40.0)
49
+ parser (>= 2.3.1.0, < 3.0)
50
+ powerpack (~> 0.1)
51
+ rainbow (>= 1.99.1, < 3.0)
52
+ ruby-progressbar (~> 1.7)
53
+ unicode-display_width (~> 1.0, >= 1.0.1)
54
+ ruby-progressbar (1.8.1)
43
55
  simplecov (0.10.0)
44
56
  docile (~> 1.1.0)
45
57
  json (~> 1.8)
@@ -53,6 +65,7 @@ GEM
53
65
  unf (0.1.4)
54
66
  unf_ext
55
67
  unf_ext (0.0.7.1)
68
+ unicode-display_width (1.0.5)
56
69
 
57
70
  PLATFORMS
58
71
  ruby
@@ -63,6 +76,7 @@ DEPENDENCIES
63
76
  coveralls
64
77
  rake
65
78
  rspec
79
+ rubocop (~> 0.40.0)
66
80
  simplecov
67
81
  slop (~> 4.2.0)
68
82
 
data/README.md CHANGED
@@ -1,5 +1,4 @@
1
- # Bmp v1.2.0
2
-
1
+ # Bmp v1.3.1
3
2
  [![Gem Version](https://img.shields.io/gem/v/bmp.svg)](http://badge.fury.io/rb/bmp)
4
3
  [![Build Status](https://img.shields.io/travis/kt3k/bmp.svg)](https://travis-ci.org/kt3k/bmp)
5
4
  [![Coverage Status](https://img.shields.io/coveralls/kt3k/bmp.svg)](https://coveralls.io/r/kt3k/bmp)
@@ -9,7 +8,7 @@
9
8
 
10
9
  `bmp` command bumps and updates the version numbers in a repository according to the yaml file `.bmp.yml`. This is convenient if you have written many version numbers in your repository. This command helps you consistently update the version information in your repository.
11
10
 
12
- ## Installation
11
+ ## Install
13
12
 
14
13
  ```sh
15
14
  gem install bmp
@@ -116,3 +115,43 @@ And this command also tag it as `vX.Y.Z`.
116
115
  # License
117
116
 
118
117
  MIT
118
+
119
+ # Development
120
+
121
+ ## dev commands
122
+
123
+ ### dependency download
124
+
125
+ bundle install
126
+
127
+ ### lint
128
+
129
+ rake rubocop
130
+
131
+ ### test
132
+
133
+ rake spec
134
+
135
+ ### install dev version
136
+
137
+ rake install
138
+
139
+ ### release
140
+
141
+ rake release
142
+
143
+ ## Domain models
144
+
145
+ Domain models are in `./lib/bump/domain` dir.
146
+
147
+ ### VersionNumber
148
+
149
+ `VersionNumber` model represents the version number and bumps itself with levels.
150
+
151
+ ### FileUpdateRule
152
+
153
+ `FileUpdateRule` model represents unit rule of version number replacement. A rule has a version number, a file path and a pattern for replacement.
154
+
155
+ ### BumpInfo
156
+
157
+ `BumpInfo` model represents overall bumping strategy in a project. This model loosely corresponds to the contents of `.bmp.yml`.
data/Rakefile CHANGED
@@ -1,6 +1,8 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+ require 'rubocop/rake_task'
3
4
 
4
5
  RSpec::Core::RakeTask.new(:spec)
6
+ RuboCop::RakeTask.new
5
7
 
6
- task :default => :spec
8
+ task default: :spec
data/TODO.md CHANGED
@@ -1,26 +1,24 @@
1
1
  # TODO
2
2
 
3
- - Add frontend layer between slop and application
4
- - use mock library
5
- - gh-pages yardoc
6
- - bmp -t|--touch -> create empty .bmp.yml
3
+ - upload document, gh-pages yardoc
7
4
 
8
5
  - yaml parse error handling
9
6
  - no `version` case handling
10
7
  - no `files` case handling
11
8
 
12
- - interactive init, bump --init
9
+ - feat: interactive init, bump --init
13
10
 
14
- - test FileRewriteRule
15
- - test FileRewriteRuleFactory
16
- - test VersionDescriptor
17
- - test VersionDescriptorRepository
11
+ # DONE
12
+ - refactor: application.rb returns boolean, bin/bmp exits with the returned boolean
13
+ - use mock library
18
14
  - test Application
19
15
  - test CLI
20
16
  - test Logger
21
17
  - test Command
22
-
23
- # DONE
18
+ - test FileRewriteRule
19
+ - test FileRewriteRuleFactory
20
+ - test VersionDescriptor
21
+ - test VersionDescriptorRepository
24
22
  - support pre-release version number (of semver)
25
23
  - support build version number (of semver) - pending
26
24
  - Generate documentaion
data/bin/bmp CHANGED
@@ -1,6 +1,18 @@
1
1
  #! /usr/bin/env ruby
2
2
 
3
3
  require 'bump'
4
+ require 'slop'
4
5
 
5
- Bump::CLI.new.main
6
+ exit Bump::CLI.new(Slop.parse do |o|
7
+ o.banner = "Usage: #{Bump::CLI::CLI_NAME} [-p|-m|-j] [-c]"
6
8
 
9
+ o.bool '-i', '--info', 'show current version info'
10
+ o.bool '-p', '--patch', 'bump patch (0.0.1) level'
11
+ o.bool '-m', '--minor', 'bump minor (0.1.0) level'
12
+ o.bool '-j', '--major', 'bump major (1.0.0) level'
13
+ o.bool '-c', '--commit', 'commit bump changes (git required)'
14
+ o.bool '-h', '--help', 'show this help and exit'
15
+ o.bool '-v', '--version', 'show the version of this command and exit'
16
+ o.bool '-r', '--release', 'remove the pre-release version id'
17
+ o.string '-s', '--preid', 'set the pre-release version id (e.g. alpha, beta.1)'
18
+ end).main
@@ -1,25 +1,24 @@
1
- # coding: utf-8
2
1
  lib = File.expand_path('../lib', __FILE__)
3
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
3
  require 'bump/version'
5
4
 
6
5
  Gem::Specification.new do |spec|
7
- spec.name = "bmp"
6
+ spec.name = 'bmp'
8
7
  spec.version = Bump::VERSION
9
- spec.authors = ["Yoshiya Hinosawa"]
10
- spec.email = ["stibium121@gmail.com"]
11
- spec.description = "Bump version numbers in a repository"
12
- spec.summary = "No hassle on bumping"
13
- spec.homepage = "https://github.com/kt3k/bump"
14
- spec.license = "MIT License"
8
+ spec.authors = ['Yoshiya Hinosawa']
9
+ spec.email = ['stibium121@gmail.com']
10
+ spec.description = 'Bump version numbers in a repository'
11
+ spec.summary = 'No hassle on bumping'
12
+ spec.homepage = 'https://github.com/kt3k/bump'
13
+ spec.license = 'MIT License'
15
14
 
16
- spec.files = `git ls-files`.split($/)
15
+ spec.files = `git ls-files`.split($RS)
17
16
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
17
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
- spec.require_paths = ["lib"]
18
+ spec.require_paths = ['lib']
20
19
 
21
- spec.add_runtime_dependency "slop", "~> 4.2.0"
20
+ spec.add_runtime_dependency 'slop', '~> 4.2.0'
22
21
 
23
- spec.add_development_dependency "bundler", "~> 1.3"
24
- spec.add_development_dependency "rake"
22
+ spec.add_development_dependency 'bundler', '~> 1.3'
23
+ spec.add_development_dependency 'rake'
25
24
  end
@@ -1,4 +1,3 @@
1
-
2
1
  require 'bump/version'
3
2
  require 'bump/domain'
4
3
  require 'bump/application'
@@ -1,280 +1,291 @@
1
- # lib/bump/application.rb
2
-
3
1
  require 'bump/command'
4
2
 
5
3
  module Bump
4
+ # The application
5
+ class Application
6
+ # @param [Hash] options The cli options
7
+ # @param [String] help The help message
8
+ # @param [String] version The version expression of this command
9
+ # @param [String] file The file name of bump info file
10
+ # @param [Bump::Logger] logger The logger
11
+ # @param [Bump::Command] logger The command executer
12
+ def initialize(options, help, version, file, logger, command = nil)
13
+ @options = options
14
+ @help = help
15
+ @version = version
16
+ @file = file
17
+ @logger = logger
18
+ @command = command
19
+ @command = Bump::Command.new @logger if @command.nil?
20
+ end
6
21
 
7
- # The application
8
- class Application
9
-
10
- # @param [Hash] options The cli options
11
- # @param [String] help The help message
12
- # @param [String] version The version expression of this command
13
- # @param [String] file The file name of bump info file
14
- # @param [Bump::Logger] logger The logger
15
- def initialize options, help, version, file, logger
16
- @options = options
17
- @help = help
18
- @version = version
19
- @file = file
20
- @logger = logger
21
- end
22
-
23
- # Returns a symbol which represents the action to perform.
24
- #
25
- # @return [Symbol]
26
- def selectAction
27
- if @options[:help]
28
- return :help
29
- end
30
-
31
- if @options[:version]
32
- return :version
33
- end
34
-
35
- if @options[:info]
36
- return :info
37
- end
38
-
39
- if @options[:major] || @options[:minor] || @options[:patch] || @options[:commit] || @options[:preid] || @options[:release]
40
- return :bump
41
- end
42
-
43
- # command without options invokes info action
44
- return :info
45
- end
46
-
47
- # handler of `bmp --version`
48
- #
49
- # @return [void]
50
- def actionVersion
51
- log @version
52
- end
53
-
54
- # handler of `bmp --help`
55
- #
56
- # @return [void]
57
- def actionHelp
58
- log @help
59
- end
60
-
61
- # Gets the bump info
62
- #
63
- # @return [Bump::BumpInfo]
64
- def getBumpInfo
65
-
66
- repo = BumpInfoRepository.new @file
67
-
68
- begin
69
- bumpInfo = repo.fromFile
70
- rescue Errno::ENOENT => e then
71
- log_red "Error: the file `#{@file}` not found."
72
- exit 1
73
- end
74
-
75
- return bumpInfo
22
+ # Returns a symbol which represents the action to perform.
23
+ # @return [Symbol]
24
+ def select_action
25
+ return :help if @options[:help]
76
26
 
77
- end
27
+ return :version if @options[:version]
78
28
 
79
- # Saves the bump info
80
- #
81
- # @param [Bump::BumpInfo] bumpInfo
82
- # @return [void]
83
- def saveBumpInfo bumpInfo
84
- repo = BumpInfoRepository.new @file
29
+ return :info if @options[:info]
85
30
 
86
- repo.save bumpInfo
87
- end
31
+ return :bump if bump_option? @options
88
32
 
89
- # Shows the version patterns.
90
- #
91
- # @param [Bump::BumpInfo] bumpInfo
92
- # @return [void]
93
- def showVersionPatterns bumpInfo
33
+ # command without options invokes info action
34
+ :info
35
+ end
94
36
 
95
- log "Current Version:", false
96
- log_green " #{bumpInfo.beforeVersion}"
37
+ # Returns true iff it's a bump option.
38
+ # @param [Hash] options The options
39
+ def bump_option?(options)
40
+ options[:major] || options[:minor] || options[:patch] || options[:commit] || options[:preid] || options[:release]
41
+ end
97
42
 
98
- log "Version patterns:"
43
+ # handler of `bmp --version`
44
+ #
45
+ # @return [void]
46
+ def action_version
47
+ log @version
99
48
 
100
- bumpInfo.updateRules.each do |rule|
49
+ true
50
+ end
101
51
 
102
- if not rule.fileExists
52
+ # handler of `bmp --help`
53
+ #
54
+ # @return [void]
55
+ def action_help
56
+ log @help
103
57
 
104
- log_red " #{rule.file}:", false
105
- log_red " '#{rule.beforePattern}' (file not found)"
58
+ true
59
+ end
106
60
 
107
- next
61
+ # Gets the bump info
62
+ # @private
63
+ # @return [Bump::BumpInfo]
64
+ def create_bump_info
65
+ repo = BumpInfoRepository.new @file
108
66
 
109
- end
67
+ begin
68
+ bump_info = repo.from_file
69
+ rescue Errno::ENOENT
70
+ log_red "Error: the file `#{@file}` not found."
71
+ return nil
72
+ end
110
73
 
111
- log " #{rule.file}:", false
74
+ bump_info
75
+ end
112
76
 
113
- if not rule.patternExists
77
+ # Saves the bump info
78
+ # @param [Bump::BumpInfo] bumpInfo
79
+ # @return [void]
80
+ def save_bump_info(bump_info)
81
+ repo = BumpInfoRepository.new @file
114
82
 
115
- log_red " '#{rule.beforePattern}' (pattern not found)"
83
+ repo.save bump_info
84
+ end
116
85
 
117
- next
86
+ # Shows the version patterns.
87
+ # @param [Bump::BumpInfo] bumpInfo
88
+ # @return [void]
89
+ def print_version_patterns(bump_info)
90
+ log 'Current Version:', false
91
+ log_green " #{bump_info.before_version}"
118
92
 
119
- end
93
+ log 'Version patterns:'
120
94
 
121
- log_green " '#{rule.beforePattern}'"
122
- end
123
- end
95
+ bump_info.update_rules.each do |rule|
96
+ print_rule rule
97
+ end
98
+ end
124
99
 
125
- # handler of `bmp [--info]`
126
- #
127
- # @return [void]
128
- def actionInfo
100
+ # Prints the pattern info for the given rule
101
+ # @param [Bump::FileUpdateRule] rule The rule
102
+ def print_rule(rule)
103
+ unless rule.file_exists
104
+ log_red " #{rule.file}:", false
105
+ log_red " '#{rule.before_pattern}' (file not found)"
129
106
 
130
- bumpInfo = getBumpInfo
107
+ return
108
+ end
131
109
 
132
- showVersionPatterns bumpInfo
110
+ log " #{rule.file}:", false
133
111
 
134
- if bumpInfo.check
135
- exit 0
136
- else
137
- exit 1
138
- end
112
+ unless rule.pattern_exists
113
+ log_red " '#{rule.before_pattern}' (pattern not found)"
139
114
 
140
- end
115
+ return
116
+ end
141
117
 
118
+ log_green " '#{rule.before_pattern}'"
119
+ end
142
120
 
143
- # Checks the bumping is possible.
144
- #
145
- # @param [Bump::BumpInfo] bumpInfo
146
- # @return [void]
147
- def checkBumpInfo bumpInfo
121
+ # handler of `bmp [--info]`
122
+ #
123
+ # @return [void]
124
+ def action_info
125
+ bump_info = create_bump_info
148
126
 
149
- if not bumpInfo.check
150
- log_red "Some patterns are invalid!"
151
- log_red "Stops updating version numbers."
152
- log
127
+ return false if bump_info.nil?
153
128
 
154
- showVersionPatterns bumpInfo
129
+ print_version_patterns bump_info
155
130
 
156
- exit 1
157
- end
131
+ bump_info.valid?
132
+ end
158
133
 
159
- end
134
+ # Checks the bumping is possible.
135
+ # @param [Bump::BumpInfo] bumpInfo
136
+ # @return [void]
137
+ def print_invalid_bump_info(bump_info)
138
+ log_red 'Some patterns are invalid!'
139
+ log_red 'Stops updating version numbers.'
140
+ log
160
141
 
161
- # Reports the bumping details.
162
- #
163
- # @param [Bump::BumpInfo] bumpInfo
164
- # @return [void]
165
- def report bumpInfo
166
- bumpInfo.updateRules.each do |rule|
142
+ print_version_patterns bump_info
143
+ end
167
144
 
168
- log "#{rule.file}"
169
- log " Performed pattern replacement:"
170
- log_green " '#{rule.beforePattern}' => '#{rule.afterPattern}'"
171
- log
145
+ # Reports the bumping details.
146
+ # @param [Bump::BumpInfo] bumpInfo
147
+ def report(bump_info)
148
+ bump_info.update_rules.each do |rule|
149
+ log rule.file.to_s
150
+ log ' Performed pattern replacement:'
151
+ log_green " '#{rule.before_pattern}' => '#{rule.after_pattern}'"
152
+ log
153
+ end
154
+ end
172
155
 
173
- end
174
- end
156
+ # The bump action
157
+ # @return [Boolean] true iff success
158
+ def action_bump
159
+ bump_info = create_bump_info
175
160
 
176
- # handler of `bmp --patch|--minor|--major|--commit`
177
- #
178
- # @return [void]
179
- def actionBump
161
+ return false if bump_info.nil?
180
162
 
181
- bumpInfo = getBumpInfo
163
+ print_bump_plan bump_info
182
164
 
183
- [:major, :minor, :patch].each do |level|
184
- if @options[level]
185
- bumpInfo.bump level
186
- log "Bump #{level} level"
187
- log_green " #{bumpInfo.beforeVersion} => #{bumpInfo.afterVersion}"
188
- break
189
- end
190
- end
165
+ unless bump_info.valid?
166
+ print_invalid_bump_info bump_info
191
167
 
192
- if @options[:preid]
193
- preid = @options[:preid]
194
- bumpInfo.setPreid preid
195
- log "Set pre-release version id: ", false
196
- log_green preid
197
- log_green " #{bumpInfo.beforeVersion} => #{bumpInfo.afterVersion}"
198
- end
168
+ return false
169
+ end
199
170
 
200
- if @options[:release]
201
- bumpInfo.setPreid nil
202
- log "Remove pre-release version id"
203
- log_green " #{bumpInfo.beforeVersion} => #{bumpInfo.afterVersion}"
204
- end
171
+ bump_info.perform_update
205
172
 
206
- log
173
+ report bump_info
207
174
 
208
- checkBumpInfo bumpInfo
175
+ save_bump_info bump_info
209
176
 
210
- bumpInfo.performUpdate
177
+ commit_and_tag bump_info if @options[:commit]
211
178
 
212
- report bumpInfo
179
+ true
180
+ end
213
181
 
214
- saveBumpInfo bumpInfo
182
+ # Gets the requested bump level.
183
+ # @return [Symbol]
184
+ def bump_level
185
+ return :major if @options[:major]
186
+ return :minor if @options[:minor]
187
+ return :patch if @options[:patch]
188
+ end
215
189
 
216
- comm = Command.new @logger
190
+ # Prints the version bump plan.
191
+ # @param [Bump::BumpInfo] bump_info The bump info
192
+ def print_bump_plan(bump_info)
193
+ level = bump_level
194
+ print_bump_plan_level level, bump_info unless level.nil?
217
195
 
218
- if @options[:commit]
219
- comm.exec "git add ."
220
- comm.exec "git commit -m '#{bumpInfo.getCommitMessage}'"
221
- comm.exec "git tag v#{bumpInfo.afterVersion}"
222
- end
223
- end
196
+ preid = @options[:preid]
197
+ print_bump_plan_preid preid, bump_info unless preid.nil?
224
198
 
225
- # The entry point
226
- #
227
- # @return [void]
228
- def main
199
+ print_bump_plan_release bump_info if @options[:release]
229
200
 
230
- action = selectAction
201
+ log
202
+ end
231
203
 
232
- case action
233
- when :version
234
- actionVersion
235
- when :help
236
- actionHelp
237
- when :info
238
- actionInfo
239
- when :bump
240
- actionBump
241
- end
204
+ # Prints the bump plan for the given level.
205
+ # @param [Symbol] level The level
206
+ # @param [Bump::BumpInfo] bump_info The bump info
207
+ def print_bump_plan_level(level, bump_info)
208
+ bump_info.bump level
242
209
 
243
- end
210
+ log "Bump #{level} level"
211
+ print_version_transition bump_info
212
+ end
244
213
 
245
- # Logs the message
246
- #
247
- # @param [String] message
248
- # @param [Boolean] newline
249
- # @return [void]
250
- def log message = '', newline = true
214
+ # Prints the bump plan for the give preid.
215
+ # @param [Bump::BumpInfo] bump_info The bump info
216
+ def print_bump_plan_preid(preid, bump_info)
217
+ bump_info.preid = preid
251
218
 
252
- @logger.log message, newline
219
+ log 'Set pre-release version id: ', false
220
+ log_green preid
221
+ print_version_transition bump_info
222
+ end
253
223
 
254
- end
224
+ # Prints the bump plan for the release
225
+ # @param [Bump::BumpInfo] bump_info The bump info
226
+ def print_bump_plan_release(bump_info)
227
+ bump_info.preid = nil
255
228
 
256
- # Logs the message in red
257
- #
258
- # @param [String] message
259
- # @param [Boolean] newline
260
- # @return [void]
261
- def log_red message, newline = true
262
-
263
- log @logger.red(message), newline
229
+ log 'Remove pre-release version id'
230
+ print_version_transition bump_info
231
+ end
264
232
 
265
- end
233
+ # Prints the version transition.
234
+ # @param [Bump::BumpInfo] bump_info The bump info
235
+ def print_version_transition(bump_info)
236
+ log_green " #{bump_info.before_version} => #{bump_info.after_version}"
237
+ end
266
238
 
267
- # Logs the message in green
268
- #
269
- # @param [String] message
270
- # @param [Boolean] newline
271
- # @return [void]
272
- def log_green message, newline = true
239
+ # Commits current changes and tag it by the current version.
240
+ # @param [Bump::BumpInfo] bump_info The bump info
241
+ def commit_and_tag(bump_info)
242
+ @logger.log '===> executing commands'
243
+ @command.exec 'git add .'
244
+ @command.exec "git commit -m '#{bump_info.commit_message}'"
245
+ @command.exec "git tag v#{bump_info.after_version}"
246
+ end
273
247
 
274
- log @logger.green(message), newline
248
+ # The entry point
249
+ #
250
+ # @return [void]
251
+ def main
252
+ case select_action
253
+ when :version
254
+ action_version
255
+ when :help
256
+ action_help
257
+ when :info
258
+ action_info
259
+ when :bump
260
+ action_bump
261
+ end
262
+ end
275
263
 
276
- end
264
+ # Logs the message
265
+ #
266
+ # @param [String] message
267
+ # @param [Boolean] newline
268
+ # @return [void]
269
+ def log(message = '', newline = true)
270
+ @logger.log message, newline
271
+ end
277
272
 
273
+ # Logs the message in red
274
+ #
275
+ # @param [String] message
276
+ # @param [Boolean] newline
277
+ # @return [void]
278
+ def log_red(message, newline = true)
279
+ log @logger.red(message), newline
278
280
  end
279
281
 
282
+ # Logs the message in green
283
+ #
284
+ # @param [String] message
285
+ # @param [Boolean] newline
286
+ # @return [void]
287
+ def log_green(message, newline = true)
288
+ log @logger.green(message), newline
289
+ end
290
+ end
280
291
  end