bmp 0.6.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 +15 -0
- data/.gitignore +16 -0
- data/.travis.yml +1 -0
- data/.version +5 -0
- data/Gemfile +12 -0
- data/Gemfile.lock +52 -0
- data/LICENSE.txt +22 -0
- data/README.md +78 -0
- data/Rakefile +6 -0
- data/TODO.md +27 -0
- data/bin/bmp +6 -0
- data/bump.gemspec +25 -0
- data/lib/bump/application.rb +144 -0
- data/lib/bump/cli.rb +36 -0
- data/lib/bump/command.rb +18 -0
- data/lib/bump/domain/file_rewrite_rule.rb +49 -0
- data/lib/bump/domain/file_rewrite_rule_factory.rb +22 -0
- data/lib/bump/domain/version.rb +55 -0
- data/lib/bump/domain/version_descriptor.rb +65 -0
- data/lib/bump/domain/version_descriptor_repository.rb +23 -0
- data/lib/bump/domain/version_factory.rb +17 -0
- data/lib/bump/domain.rb +8 -0
- data/lib/bump/logger.rb +33 -0
- data/lib/bump/version.rb +3 -0
- data/lib/bump.rb +6 -0
- data/spec/bump/application_spec.rb +7 -0
- data/spec/bump/cli_spec.rb +7 -0
- data/spec/bump/domain/file_rewrite_rule_factory_spec.rb +7 -0
- data/spec/bump/domain/file_rewrite_rule_spec.rb +7 -0
- data/spec/bump/domain/version_descriptor_repository_spec.rb +7 -0
- data/spec/bump/domain/version_descriptor_spec.rb +7 -0
- data/spec/bump/domain/version_factory_spec.rb +35 -0
- data/spec/bump/domain/version_spec.rb +132 -0
- data/spec/bump/logger_spec.rb +7 -0
- data/spec/spec_helper.rb +14 -0
- metadata +131 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
MDVkNzk1YTJmMWMzMmExNGI3NjQ3MzJhOWE1NGMyM2JhOGU4OTI1OA==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
NDJhMTM4NTBhNGFjNzM2NTZlMWQ1MjY4MzViNGUyZGYwNGViZWFmYg==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
ZDQ4NzI5M2FkNWFmY2I3YjE2MzhlM2I0YWZhNzAwMmFiYmY2NDliOTBhMWYy
|
10
|
+
YjBiNWRkZWEwMDE3NDU3Y2Y5YmMzZDcyMWU4OTIyOGFhNDg2ZTdhZGVlZWQ0
|
11
|
+
ZThjOGY2MTBmYzU5ZjVhYjYwZDI0Y2E0NjY1ZWM0OTc0YTg1NDM=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
OTUzMmVhZGZlYzM5ODBiYWUwNzM5MjIwNTA2ZDZlNjI5MTMwNmRkMWE1NzI0
|
14
|
+
MjJhZTcyM2E4N2M0YTcxOWIzMmM5ZTc1ODA3ZWEyYzg5ZTk4MTYyZDE0NzU2
|
15
|
+
NGIwYzJlNDMxYWQ5MzcyYWFmNTY0NjBkNDAyMjg2Y2IxZDcwNTY=
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
language: ruby
|
data/.version
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
bmp (0.6.1)
|
5
|
+
slop (~> 3.4.7)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
coveralls (0.7.0)
|
11
|
+
multi_json (~> 1.3)
|
12
|
+
rest-client
|
13
|
+
simplecov (>= 0.7)
|
14
|
+
term-ansicolor
|
15
|
+
thor
|
16
|
+
diff-lcs (1.2.5)
|
17
|
+
docile (1.1.1)
|
18
|
+
mime-types (2.0)
|
19
|
+
multi_json (1.8.2)
|
20
|
+
rake (10.1.0)
|
21
|
+
rest-client (1.6.7)
|
22
|
+
mime-types (>= 1.16)
|
23
|
+
rspec (2.14.1)
|
24
|
+
rspec-core (~> 2.14.0)
|
25
|
+
rspec-expectations (~> 2.14.0)
|
26
|
+
rspec-mocks (~> 2.14.0)
|
27
|
+
rspec-core (2.14.7)
|
28
|
+
rspec-expectations (2.14.4)
|
29
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
30
|
+
rspec-mocks (2.14.4)
|
31
|
+
simplecov (0.8.2)
|
32
|
+
docile (~> 1.1.0)
|
33
|
+
multi_json
|
34
|
+
simplecov-html (~> 0.8.0)
|
35
|
+
simplecov-html (0.8.0)
|
36
|
+
slop (3.4.7)
|
37
|
+
term-ansicolor (1.2.2)
|
38
|
+
tins (~> 0.8)
|
39
|
+
thor (0.18.1)
|
40
|
+
tins (0.13.1)
|
41
|
+
|
42
|
+
PLATFORMS
|
43
|
+
ruby
|
44
|
+
|
45
|
+
DEPENDENCIES
|
46
|
+
bmp!
|
47
|
+
bundler (~> 1.3)
|
48
|
+
coveralls
|
49
|
+
rake
|
50
|
+
rspec
|
51
|
+
simplecov
|
52
|
+
slop
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Yoshiya Hinosawa
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
# Bmp v0.6.1
|
2
|
+
|
3
|
+
[](https://travis-ci.org/kt3k/bmp) [](https://coveralls.io/r/kt3k/bmp?branch=master)
|
4
|
+
|
5
|
+
> Bump version info in a repository
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
```sh
|
10
|
+
gem install bmp
|
11
|
+
```
|
12
|
+
|
13
|
+
This install `bmp` command
|
14
|
+
|
15
|
+
## Usage
|
16
|
+
|
17
|
+
### version descriptor
|
18
|
+
|
19
|
+
put `.version` file on the top of your repository like following (which is `YAML`):
|
20
|
+
|
21
|
+
```
|
22
|
+
---
|
23
|
+
version: 0.1.6
|
24
|
+
files:
|
25
|
+
gradle.properties: version=%.%.%
|
26
|
+
README.md:
|
27
|
+
- coveralls-gradle-plugin v%.%.%
|
28
|
+
- org.kt3k.gradle.plugin:coveralls-gradle-plugin:%.%.%
|
29
|
+
```
|
30
|
+
|
31
|
+
`version` value is the current version number of the repository.
|
32
|
+
|
33
|
+
`files` are the mappings of the files which contain version numbers in them.
|
34
|
+
|
35
|
+
```
|
36
|
+
gradle.properties: version=%.%.%
|
37
|
+
```
|
38
|
+
|
39
|
+
The expression above means the file `./gradle.properties` contains the string `version=0.1.6` (because the current version is 0.1.6) and `%.%.%` is the placeholder for current version number and will updated on version bumps.
|
40
|
+
|
41
|
+
### bmp command
|
42
|
+
|
43
|
+
show current version info:
|
44
|
+
```
|
45
|
+
bmp -i
|
46
|
+
```
|
47
|
+
|
48
|
+
|
49
|
+
bump patch (0.0.1) level:
|
50
|
+
```
|
51
|
+
bmp -p
|
52
|
+
```
|
53
|
+
|
54
|
+
|
55
|
+
bump minor (0.1.0) level:
|
56
|
+
```
|
57
|
+
bmp -m
|
58
|
+
```
|
59
|
+
|
60
|
+
|
61
|
+
bump major (1.0.0) level:
|
62
|
+
```
|
63
|
+
bmp -j
|
64
|
+
```
|
65
|
+
|
66
|
+
|
67
|
+
commit bump results
|
68
|
+
```
|
69
|
+
bmp -f
|
70
|
+
```
|
71
|
+
|
72
|
+
## Contributing
|
73
|
+
|
74
|
+
1. Fork it
|
75
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
76
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
77
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
78
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/TODO.md
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# TODO
|
2
|
+
|
3
|
+
- test
|
4
|
+
- domain - FileRewriteRule
|
5
|
+
- domain - FileRewriteRuleFactory
|
6
|
+
- domain - VersionDescriptor
|
7
|
+
- domain - VersionDescriptorRepository
|
8
|
+
- Application
|
9
|
+
- CLI
|
10
|
+
- Logger
|
11
|
+
- Command
|
12
|
+
|
13
|
+
# done
|
14
|
+
- travis - done
|
15
|
+
- coveralls - done
|
16
|
+
- introduce simplecov - done
|
17
|
+
- git tag when -f - done
|
18
|
+
- show command before execution - done
|
19
|
+
- write tests
|
20
|
+
- Version - done
|
21
|
+
- VersionFactory - done
|
22
|
+
- separate classes into separate files - done
|
23
|
+
- decent console log - done
|
24
|
+
- git command outputs
|
25
|
+
- bump description - done
|
26
|
+
- introduce slop - done
|
27
|
+
- introduce commander - no
|
data/bin/bmp
ADDED
data/bump.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'bump/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "bmp"
|
8
|
+
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 = "Bump version numbers in a repository"
|
13
|
+
spec.homepage = "https://github.com/kt3k/bump"
|
14
|
+
spec.license = "MIT License"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_runtime_dependency "slop", "~> 3.4.7"
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
24
|
+
spec.add_development_dependency "rake"
|
25
|
+
end
|
@@ -0,0 +1,144 @@
|
|
1
|
+
# lib/bump/application.rb
|
2
|
+
|
3
|
+
require 'bump/command'
|
4
|
+
|
5
|
+
module Bump
|
6
|
+
|
7
|
+
class Application
|
8
|
+
|
9
|
+
def initialize options, help, version, file, logger
|
10
|
+
@options = options
|
11
|
+
@help = help
|
12
|
+
@version = version
|
13
|
+
@file = file
|
14
|
+
@logger = logger
|
15
|
+
end
|
16
|
+
|
17
|
+
def selectAction
|
18
|
+
if @options[:help]
|
19
|
+
return :help
|
20
|
+
end
|
21
|
+
|
22
|
+
if @options[:version]
|
23
|
+
return :version
|
24
|
+
end
|
25
|
+
|
26
|
+
if @options[:info]
|
27
|
+
return :info
|
28
|
+
end
|
29
|
+
|
30
|
+
if !@options[:major] && !@options[:minor] && !@options[:patch] && !@options[:fix]
|
31
|
+
return :help
|
32
|
+
end
|
33
|
+
|
34
|
+
return :bump
|
35
|
+
end
|
36
|
+
|
37
|
+
def actionVersion
|
38
|
+
@logger.log @version
|
39
|
+
end
|
40
|
+
|
41
|
+
def actionHelp
|
42
|
+
@logger.log @help
|
43
|
+
end
|
44
|
+
|
45
|
+
def actionInfo
|
46
|
+
repo = VersionDescriptorRepository.new @file
|
47
|
+
|
48
|
+
descriptor = repo.fromFile
|
49
|
+
|
50
|
+
@logger.log "Current Version:"
|
51
|
+
@logger.log descriptor.beforeVersion
|
52
|
+
|
53
|
+
@logger.log
|
54
|
+
|
55
|
+
descriptor.rewriteRules.each do |rule|
|
56
|
+
rule.prepare
|
57
|
+
|
58
|
+
@logger.log "#{rule.file}"
|
59
|
+
@logger.log " Replace Target Pattern:"
|
60
|
+
@logger.log " '#{rule.beforePattern}'"
|
61
|
+
@logger.log
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def actionBump
|
66
|
+
|
67
|
+
repo = VersionDescriptorRepository.new @file
|
68
|
+
|
69
|
+
srv = repo.fromFile
|
70
|
+
|
71
|
+
if @options[:patch]
|
72
|
+
srv.patchBump
|
73
|
+
|
74
|
+
@logger.log 'Bump patch level'
|
75
|
+
@logger.log "#{srv.beforeVersion} => #{srv.afterVersion}"
|
76
|
+
end
|
77
|
+
|
78
|
+
if @options[:minor]
|
79
|
+
srv.minorBump
|
80
|
+
|
81
|
+
@logger.log 'Bump minor level'
|
82
|
+
@logger.log "#{srv.beforeVersion} => #{srv.afterVersion}"
|
83
|
+
end
|
84
|
+
|
85
|
+
if @options[:major]
|
86
|
+
srv.majorBump
|
87
|
+
|
88
|
+
@logger.log 'Bump major level'
|
89
|
+
@logger.log "#{srv.beforeVersion} => #{srv.afterVersion}"
|
90
|
+
end
|
91
|
+
|
92
|
+
@logger.log
|
93
|
+
|
94
|
+
srv.rewriteRules.each do |rule|
|
95
|
+
result = rule.perform
|
96
|
+
|
97
|
+
if result
|
98
|
+
@logger.log "#{rule.file}"
|
99
|
+
@logger.log " Performed pattern replacement:"
|
100
|
+
@logger.log " '#{rule.beforePattern}' => '#{rule.afterPattern}'"
|
101
|
+
@logger.log
|
102
|
+
else
|
103
|
+
@logger.log " Current version pattern ('#{rule.beforePattern}') not found!"
|
104
|
+
@logger.log
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
repo.save srv
|
109
|
+
|
110
|
+
comm = Command.new @logger
|
111
|
+
|
112
|
+
if @options[:fix]
|
113
|
+
comm.exec "git add ."
|
114
|
+
comm.exec "git commit -m 'Bump to version v#{srv.afterVersion}'"
|
115
|
+
comm.exec "git tag v#{srv.afterVersion}"
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
def actionError
|
120
|
+
@logger.error @error_message
|
121
|
+
end
|
122
|
+
|
123
|
+
def main
|
124
|
+
|
125
|
+
action = selectAction
|
126
|
+
|
127
|
+
case action
|
128
|
+
when :version
|
129
|
+
actionVersion
|
130
|
+
when :help
|
131
|
+
actionHelp
|
132
|
+
when :info
|
133
|
+
actionInfo
|
134
|
+
when :bump
|
135
|
+
actionBump
|
136
|
+
when :error
|
137
|
+
actionError
|
138
|
+
end
|
139
|
+
|
140
|
+
end
|
141
|
+
|
142
|
+
end
|
143
|
+
|
144
|
+
end
|
data/lib/bump/cli.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
|
2
|
+
require 'bump/version'
|
3
|
+
require 'yaml'
|
4
|
+
require 'slop'
|
5
|
+
|
6
|
+
module Bump
|
7
|
+
|
8
|
+
class CLI
|
9
|
+
|
10
|
+
VERSION_FILE = '.version'
|
11
|
+
|
12
|
+
CLI_NAME = 'bmp'
|
13
|
+
|
14
|
+
def main
|
15
|
+
|
16
|
+
opts = Slop.parse do
|
17
|
+
banner "Usage: #{CLI_NAME} [-p|-m|-j] [-f]"
|
18
|
+
|
19
|
+
on :i, :info, 'show current version info'
|
20
|
+
on :p, :patch, 'bump patch (0.0.1) level'
|
21
|
+
on :m, :minor, 'bump minor (0.1.0) level'
|
22
|
+
on :j, :major, 'bump major (1.0.0) level'
|
23
|
+
on :f, :fix, 'fix bumping and commit current changes (git required)'
|
24
|
+
on :h, :help, 'show this help and exit'
|
25
|
+
on :v, :version, 'show version and exit'
|
26
|
+
end
|
27
|
+
|
28
|
+
app = Application.new opts.to_hash, opts.to_s, "#{CLI_NAME} v#{Bump::VERSION}", VERSION_FILE, Logger.new
|
29
|
+
|
30
|
+
app.main
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
data/lib/bump/command.rb
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
module Bump
|
4
|
+
|
5
|
+
class FileRewriteRule
|
6
|
+
|
7
|
+
PLACEHOLDER_PATTERN = '%.%.%'
|
8
|
+
|
9
|
+
def initialize(file, pattern, before_version, after_version)
|
10
|
+
@file = file
|
11
|
+
@pattern = pattern || PLACEHOLDER_PATTERN # default pattern is '%.%.%'
|
12
|
+
@before_version = before_version
|
13
|
+
@after_version = after_version
|
14
|
+
end
|
15
|
+
|
16
|
+
def prepare
|
17
|
+
@before_pattern = @pattern.sub PLACEHOLDER_PATTERN, @before_version
|
18
|
+
@after_pattern = @pattern.sub PLACEHOLDER_PATTERN, @after_version
|
19
|
+
end
|
20
|
+
|
21
|
+
def file
|
22
|
+
@file
|
23
|
+
end
|
24
|
+
|
25
|
+
def beforePattern
|
26
|
+
@before_pattern
|
27
|
+
end
|
28
|
+
|
29
|
+
def afterPattern
|
30
|
+
@after_pattern
|
31
|
+
end
|
32
|
+
|
33
|
+
def perform
|
34
|
+
prepare
|
35
|
+
|
36
|
+
contents = File.read @file, :encoding => Encoding::UTF_8
|
37
|
+
|
38
|
+
if contents.index @before_pattern
|
39
|
+
File.write @file, contents.sub(@before_pattern, @after_pattern)
|
40
|
+
|
41
|
+
return true
|
42
|
+
else
|
43
|
+
return false
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
module Bump
|
4
|
+
|
5
|
+
class FileRewriteRuleFactory
|
6
|
+
|
7
|
+
def self.create file, param, before_version, after_version
|
8
|
+
|
9
|
+
case param
|
10
|
+
when String
|
11
|
+
return FileRewriteRule.new file, param, before_version, after_version
|
12
|
+
when Array
|
13
|
+
return param.map { |param| FileRewriteRule.new file, param, before_version, after_version }.flatten
|
14
|
+
else
|
15
|
+
return FileRewriteRule.new file, nil, before_version, after_version
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# lib/bump/domain/version.rb
|
2
|
+
|
3
|
+
module Bump
|
4
|
+
|
5
|
+
class Version
|
6
|
+
|
7
|
+
def initialize major, minor, patch, suffix = ''
|
8
|
+
@major = major
|
9
|
+
@minor = minor
|
10
|
+
@patch = patch
|
11
|
+
@suffix = suffix
|
12
|
+
end
|
13
|
+
|
14
|
+
def bump level
|
15
|
+
|
16
|
+
case level
|
17
|
+
when 'major'
|
18
|
+
@major += 1
|
19
|
+
@minor = 0
|
20
|
+
@patch = 0
|
21
|
+
@suffix = ''
|
22
|
+
when 'minor'
|
23
|
+
@minor += 1
|
24
|
+
@patch = 0
|
25
|
+
@suffix = ''
|
26
|
+
when 'patch'
|
27
|
+
@patch += 1
|
28
|
+
@suffix = ''
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
def patchBump
|
34
|
+
bump 'patch'
|
35
|
+
end
|
36
|
+
|
37
|
+
def minorBump
|
38
|
+
bump 'minor'
|
39
|
+
end
|
40
|
+
|
41
|
+
def majorBump
|
42
|
+
bump 'major'
|
43
|
+
end
|
44
|
+
|
45
|
+
def append suffix
|
46
|
+
@suffix = suffix
|
47
|
+
end
|
48
|
+
|
49
|
+
def to_s
|
50
|
+
@major.to_s + '.' + @minor.to_s + '.' + @patch.to_s + @suffix
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
|
2
|
+
require 'yaml'
|
3
|
+
|
4
|
+
module Bump
|
5
|
+
|
6
|
+
class VersionDescriptor
|
7
|
+
|
8
|
+
def initialize config
|
9
|
+
@config = config
|
10
|
+
|
11
|
+
@version = VersionFactory.fromString @config['version']
|
12
|
+
|
13
|
+
@before_version = @version.to_s
|
14
|
+
@after_version = @version.to_s
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
def resetAfterVersion
|
19
|
+
@after_version = @version.to_s
|
20
|
+
@config['version'] = @after_version
|
21
|
+
end
|
22
|
+
|
23
|
+
def toYaml
|
24
|
+
@config.to_yaml
|
25
|
+
end
|
26
|
+
|
27
|
+
def majorBump
|
28
|
+
@version.bump 'major'
|
29
|
+
|
30
|
+
resetAfterVersion
|
31
|
+
end
|
32
|
+
|
33
|
+
def minorBump
|
34
|
+
@version.bump 'minor'
|
35
|
+
|
36
|
+
resetAfterVersion
|
37
|
+
end
|
38
|
+
|
39
|
+
def patchBump
|
40
|
+
@version.bump 'patch'
|
41
|
+
|
42
|
+
resetAfterVersion
|
43
|
+
end
|
44
|
+
|
45
|
+
def config
|
46
|
+
@config
|
47
|
+
end
|
48
|
+
|
49
|
+
def rewriteRules
|
50
|
+
return @config['files'].map { |file, param|
|
51
|
+
FileRewriteRuleFactory.create(file, param, @before_version, @after_version)
|
52
|
+
}.flatten
|
53
|
+
end
|
54
|
+
|
55
|
+
def afterVersion
|
56
|
+
@after_version
|
57
|
+
end
|
58
|
+
|
59
|
+
def beforeVersion
|
60
|
+
@before_version
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
require 'yaml'
|
4
|
+
|
5
|
+
module Bump
|
6
|
+
|
7
|
+
class VersionDescriptorRepository
|
8
|
+
|
9
|
+
def initialize file
|
10
|
+
@file = file
|
11
|
+
end
|
12
|
+
|
13
|
+
def fromFile
|
14
|
+
VersionDescriptor.new YAML.load_file @file
|
15
|
+
end
|
16
|
+
|
17
|
+
def save descriptor
|
18
|
+
File.write @file, descriptor.toYaml
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
module Bump
|
4
|
+
|
5
|
+
class VersionFactory
|
6
|
+
|
7
|
+
VERSION_REGEXP = /^(\d).(\d).(\d)(\S*)$/
|
8
|
+
|
9
|
+
def self.fromString version_string
|
10
|
+
match = VERSION_REGEXP.match version_string
|
11
|
+
|
12
|
+
return Version.new match[1].to_i, match[2].to_i, match[3].to_i, match[4]
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
data/lib/bump/domain.rb
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
# lib/bump/domain.rb
|
2
|
+
|
3
|
+
require 'bump/domain/version'
|
4
|
+
require 'bump/domain/version_factory'
|
5
|
+
require 'bump/domain/version_descriptor'
|
6
|
+
require 'bump/domain/version_descriptor_repository'
|
7
|
+
require 'bump/domain/file_rewrite_rule'
|
8
|
+
require 'bump/domain/file_rewrite_rule_factory'
|
data/lib/bump/logger.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# lib/bump/logger.rb
|
2
|
+
|
3
|
+
module Bump
|
4
|
+
|
5
|
+
class Logger
|
6
|
+
|
7
|
+
def log message = ''
|
8
|
+
puts message
|
9
|
+
end
|
10
|
+
|
11
|
+
def error message = ''
|
12
|
+
puts message
|
13
|
+
end
|
14
|
+
|
15
|
+
def warn message = ''
|
16
|
+
puts message
|
17
|
+
end
|
18
|
+
|
19
|
+
def info message = ''
|
20
|
+
puts message
|
21
|
+
end
|
22
|
+
|
23
|
+
def debug message = ''
|
24
|
+
puts message
|
25
|
+
end
|
26
|
+
|
27
|
+
def verbose message = ''
|
28
|
+
puts message
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
data/lib/bump/version.rb
ADDED
data/lib/bump.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
|
2
|
+
require 'bump'
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Bump::VersionFactory do
|
6
|
+
|
7
|
+
describe "#fromString" do
|
8
|
+
|
9
|
+
it "creates version object from version string" do
|
10
|
+
|
11
|
+
version = Bump::VersionFactory.fromString "1.2.3a"
|
12
|
+
|
13
|
+
expect(version.to_s).to eq "1.2.3a"
|
14
|
+
|
15
|
+
version.patchBump
|
16
|
+
|
17
|
+
expect(version.to_s).to eq "1.2.4"
|
18
|
+
|
19
|
+
version.minorBump
|
20
|
+
|
21
|
+
expect(version.to_s).to eq "1.3.0"
|
22
|
+
|
23
|
+
version.majorBump
|
24
|
+
|
25
|
+
expect(version.to_s).to eq "2.0.0"
|
26
|
+
|
27
|
+
version.append 'rc1'
|
28
|
+
|
29
|
+
expect(version.to_s).to eq "2.0.0rc1"
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
@@ -0,0 +1,132 @@
|
|
1
|
+
# bump_spec.rb
|
2
|
+
|
3
|
+
require 'bump'
|
4
|
+
require 'spec_helper'
|
5
|
+
|
6
|
+
describe Bump::Version do
|
7
|
+
|
8
|
+
describe "#initialize" do
|
9
|
+
|
10
|
+
it "constructs" do
|
11
|
+
|
12
|
+
expect(Bump::Version.new(1, 2, 3)).not_to be_nil
|
13
|
+
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "#to_s" do
|
19
|
+
|
20
|
+
it "returns version string" do
|
21
|
+
|
22
|
+
# no suffix
|
23
|
+
version = Bump::Version.new 1, 2, 3
|
24
|
+
|
25
|
+
expect(version.to_s).to eq '1.2.3'
|
26
|
+
|
27
|
+
# with a suffix
|
28
|
+
version = Bump::Version.new 1, 2, 3, 'rc1'
|
29
|
+
|
30
|
+
expect(version.to_s).to eq '1.2.3rc1'
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
describe "#patchBump" do
|
37
|
+
|
38
|
+
it "bumps patch level" do
|
39
|
+
|
40
|
+
version = Bump::Version.new 1, 2, 3
|
41
|
+
|
42
|
+
version.patchBump
|
43
|
+
|
44
|
+
expect(version.to_s).to eq '1.2.4'
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
it "remove suffix if it is set" do
|
49
|
+
|
50
|
+
version = Bump::Version.new 1, 2, 3, 'rc1'
|
51
|
+
|
52
|
+
version.patchBump
|
53
|
+
|
54
|
+
expect(version.to_s).to eq '1.2.4'
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
describe "#minorBump" do
|
61
|
+
|
62
|
+
it "bumps patch level" do
|
63
|
+
|
64
|
+
version = Bump::Version.new 1, 2, 3
|
65
|
+
|
66
|
+
version.minorBump
|
67
|
+
|
68
|
+
expect(version.to_s).to eq '1.3.0'
|
69
|
+
|
70
|
+
end
|
71
|
+
|
72
|
+
it "remove suffix if it is set" do
|
73
|
+
|
74
|
+
version = Bump::Version.new 1, 2, 3, 'rc1'
|
75
|
+
|
76
|
+
version.minorBump
|
77
|
+
|
78
|
+
expect(version.to_s).to eq '1.3.0'
|
79
|
+
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
|
84
|
+
describe "#majorBump" do
|
85
|
+
|
86
|
+
it "bumps patch level" do
|
87
|
+
|
88
|
+
version = Bump::Version.new 1, 2, 3
|
89
|
+
|
90
|
+
version.majorBump
|
91
|
+
|
92
|
+
expect(version.to_s).to eq '2.0.0'
|
93
|
+
|
94
|
+
end
|
95
|
+
|
96
|
+
it "remove suffix if it is set" do
|
97
|
+
|
98
|
+
version = Bump::Version.new 1, 2, 3, 'rc1'
|
99
|
+
|
100
|
+
version.majorBump
|
101
|
+
|
102
|
+
expect(version.to_s).to eq '2.0.0'
|
103
|
+
|
104
|
+
end
|
105
|
+
|
106
|
+
end
|
107
|
+
|
108
|
+
describe "#append" do
|
109
|
+
|
110
|
+
it "appends a suffix" do
|
111
|
+
|
112
|
+
version = Bump::Version.new 1, 2, 3
|
113
|
+
|
114
|
+
version.append 'rc1'
|
115
|
+
|
116
|
+
expect(version.to_s).to eq '1.2.3rc1'
|
117
|
+
|
118
|
+
end
|
119
|
+
|
120
|
+
it "rewrite the suffix if it is already set" do
|
121
|
+
|
122
|
+
version = Bump::Version.new 1, 2, 3, 'rc1'
|
123
|
+
|
124
|
+
version.append 'rc2'
|
125
|
+
|
126
|
+
expect(version.to_s).to eq '1.2.3rc2'
|
127
|
+
|
128
|
+
end
|
129
|
+
|
130
|
+
end
|
131
|
+
|
132
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
|
2
|
+
require 'simplecov'
|
3
|
+
require 'coveralls'
|
4
|
+
|
5
|
+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
6
|
+
SimpleCov::Formatter::HTMLFormatter,
|
7
|
+
Coveralls::SimpleCov::Formatter
|
8
|
+
]
|
9
|
+
|
10
|
+
SimpleCov.start do
|
11
|
+
add_filter '/spec/'
|
12
|
+
end
|
13
|
+
|
14
|
+
#Coveralls.wear!
|
metadata
ADDED
@@ -0,0 +1,131 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bmp
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.6.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Yoshiya Hinosawa
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-01-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: slop
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 3.4.7
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 3.4.7
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.3'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ! '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: Bump version numbers in a repository
|
56
|
+
email:
|
57
|
+
- stibium121@gmail.com
|
58
|
+
executables:
|
59
|
+
- bmp
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- .gitignore
|
64
|
+
- .travis.yml
|
65
|
+
- .version
|
66
|
+
- Gemfile
|
67
|
+
- Gemfile.lock
|
68
|
+
- LICENSE.txt
|
69
|
+
- README.md
|
70
|
+
- Rakefile
|
71
|
+
- TODO.md
|
72
|
+
- bin/bmp
|
73
|
+
- bump.gemspec
|
74
|
+
- lib/bump.rb
|
75
|
+
- lib/bump/application.rb
|
76
|
+
- lib/bump/cli.rb
|
77
|
+
- lib/bump/command.rb
|
78
|
+
- lib/bump/domain.rb
|
79
|
+
- lib/bump/domain/file_rewrite_rule.rb
|
80
|
+
- lib/bump/domain/file_rewrite_rule_factory.rb
|
81
|
+
- lib/bump/domain/version.rb
|
82
|
+
- lib/bump/domain/version_descriptor.rb
|
83
|
+
- lib/bump/domain/version_descriptor_repository.rb
|
84
|
+
- lib/bump/domain/version_factory.rb
|
85
|
+
- lib/bump/logger.rb
|
86
|
+
- lib/bump/version.rb
|
87
|
+
- spec/bump/application_spec.rb
|
88
|
+
- spec/bump/cli_spec.rb
|
89
|
+
- spec/bump/domain/file_rewrite_rule_factory_spec.rb
|
90
|
+
- spec/bump/domain/file_rewrite_rule_spec.rb
|
91
|
+
- spec/bump/domain/version_descriptor_repository_spec.rb
|
92
|
+
- spec/bump/domain/version_descriptor_spec.rb
|
93
|
+
- spec/bump/domain/version_factory_spec.rb
|
94
|
+
- spec/bump/domain/version_spec.rb
|
95
|
+
- spec/bump/logger_spec.rb
|
96
|
+
- spec/spec_helper.rb
|
97
|
+
homepage: https://github.com/kt3k/bump
|
98
|
+
licenses:
|
99
|
+
- MIT License
|
100
|
+
metadata: {}
|
101
|
+
post_install_message:
|
102
|
+
rdoc_options: []
|
103
|
+
require_paths:
|
104
|
+
- lib
|
105
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
|
+
requirements:
|
112
|
+
- - ! '>='
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: '0'
|
115
|
+
requirements: []
|
116
|
+
rubyforge_project:
|
117
|
+
rubygems_version: 2.1.11
|
118
|
+
signing_key:
|
119
|
+
specification_version: 4
|
120
|
+
summary: Bump version numbers in a repository
|
121
|
+
test_files:
|
122
|
+
- spec/bump/application_spec.rb
|
123
|
+
- spec/bump/cli_spec.rb
|
124
|
+
- spec/bump/domain/file_rewrite_rule_factory_spec.rb
|
125
|
+
- spec/bump/domain/file_rewrite_rule_spec.rb
|
126
|
+
- spec/bump/domain/version_descriptor_repository_spec.rb
|
127
|
+
- spec/bump/domain/version_descriptor_spec.rb
|
128
|
+
- spec/bump/domain/version_factory_spec.rb
|
129
|
+
- spec/bump/domain/version_spec.rb
|
130
|
+
- spec/bump/logger_spec.rb
|
131
|
+
- spec/spec_helper.rb
|