bmp 1.2.0 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.bmp.yml +3 -3
- data/.editorconfig +1 -2
- data/.rubocop.yml +8 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +15 -1
- data/README.md +42 -3
- data/Rakefile +5 -3
- data/TODO.md +9 -11
- data/bin/bmp +13 -1
- data/bump.gemspec +12 -13
- data/lib/bump.rb +0 -1
- data/lib/bump/application.rb +228 -217
- data/lib/bump/cli.rb +14 -34
- data/lib/bump/command.rb +12 -18
- data/lib/bump/domain.rb +0 -2
- data/lib/bump/domain/bump_info.rb +61 -120
- data/lib/bump/domain/bump_info_repository.rb +32 -42
- data/lib/bump/domain/file_update_rule.rb +41 -68
- data/lib/bump/domain/file_update_rule_factory.rb +19 -27
- data/lib/bump/domain/version_number.rb +39 -56
- data/lib/bump/domain/version_number_factory.rb +14 -20
- data/lib/bump/logger.rb +40 -46
- data/lib/bump/version.rb +1 -2
- data/spec/bump/application_spec.rb +119 -36
- data/spec/bump/cli_spec.rb +8 -1
- data/spec/bump/command_spec.rb +10 -17
- data/spec/bump/domain/bump_info_repository_spec.rb +17 -24
- data/spec/bump/domain/bump_info_spec.rb +50 -26
- data/spec/bump/domain/file_update_rule_factory_spec.rb +16 -26
- data/spec/bump/domain/file_update_rule_spec.rb +23 -33
- data/spec/bump/domain/version_number_factory_spec.rb +8 -31
- data/spec/bump/domain/version_number_spec.rb +46 -98
- data/spec/bump/logger_spec.rb +29 -1
- data/spec/fixture/bmp.yml +1 -1
- data/spec/fixture/bmp_invalid.yml +5 -0
- data/spec/fixture/bmp_invalid_pattern.yml +3 -0
- data/spec/fixture/bmp_tmp.yml +5 -0
- data/spec/spec_helper.rb +1 -4
- metadata +9 -2
data/spec/bump/cli_spec.rb
CHANGED
data/spec/bump/command_spec.rb
CHANGED
@@ -1,23 +1,16 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
1
|
describe Bump::Command do
|
2
|
+
describe '#exec' do
|
3
|
+
it 'prints and executes the command' do
|
4
|
+
logger = Bump::Logger.new
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
it 'prints and executes the command' do
|
9
|
-
|
10
|
-
logger = double()
|
6
|
+
comm = Bump::Command.new logger
|
11
7
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
comm.exec "echo 1"
|
18
|
-
|
19
|
-
end
|
8
|
+
expect(logger).to receive(:green).with('+echo 1').once
|
9
|
+
allow(logger).to receive(:green) { 'greened +echo 1' }
|
10
|
+
expect(logger).to receive(:log).with('greened +echo 1').once
|
11
|
+
expect(logger).to receive(:log).with("1\n", nil).once
|
20
12
|
|
13
|
+
comm.exec 'echo 1'
|
21
14
|
end
|
22
|
-
|
15
|
+
end
|
23
16
|
end
|
@@ -1,38 +1,31 @@
|
|
1
|
-
|
2
1
|
require 'bump'
|
3
2
|
require 'spec_helper'
|
4
3
|
|
5
4
|
describe Bump::BumpInfoRepository do
|
5
|
+
describe '#from_file' do
|
6
|
+
it 'gets the bump info from the file' do
|
7
|
+
repo = Bump::BumpInfoRepository.new 'spec/fixture/bmp.yml'
|
6
8
|
|
7
|
-
|
8
|
-
|
9
|
-
it 'gets the bump info from the file' do
|
10
|
-
|
11
|
-
repo = Bump::BumpInfoRepository.new 'spec/fixture/bmp.yml'
|
12
|
-
|
13
|
-
bumpInfo = repo.fromFile
|
14
|
-
|
15
|
-
expect(bumpInfo.class).to eq Bump::BumpInfo
|
16
|
-
|
17
|
-
end
|
9
|
+
bump_info = repo.from_file
|
18
10
|
|
11
|
+
expect(bump_info.class).to eq Bump::BumpInfo
|
19
12
|
end
|
13
|
+
end
|
20
14
|
|
21
|
-
|
22
|
-
|
23
|
-
|
15
|
+
describe '#save' do
|
16
|
+
it 'saves the current info to the file' do
|
17
|
+
repo = Bump::BumpInfoRepository.new 'spec/fixture/bmp.yml'
|
24
18
|
|
25
|
-
|
19
|
+
bump_info = repo.from_file
|
20
|
+
bump_info = Bump::BumpInfo.new Bump::VersionNumber.new(1, 2, 4), bump_info.files, bump_info.commit
|
26
21
|
|
27
|
-
|
28
|
-
|
22
|
+
repo = Bump::BumpInfoRepository.new 'spec/fixture/tmp_bmp.yml'
|
23
|
+
repo.save bump_info
|
29
24
|
|
30
|
-
|
25
|
+
bump_info = repo.from_file
|
26
|
+
expect(bump_info.version.to_s).to eq '1.2.4'
|
31
27
|
|
32
|
-
|
33
|
-
expect(bumpInfo.version.to_s).to eq '1.2.4'
|
34
|
-
|
35
|
-
end
|
28
|
+
File.delete 'spec/fixture/tmp_bmp.yml'
|
36
29
|
end
|
37
|
-
|
30
|
+
end
|
38
31
|
end
|
@@ -1,50 +1,74 @@
|
|
1
|
-
|
2
1
|
require 'bump'
|
3
2
|
require 'spec_helper'
|
4
3
|
|
5
4
|
describe Bump::BumpInfo do
|
5
|
+
before :each do
|
6
|
+
@info = Bump::BumpInfo.new Bump::VersionNumber.new(1, 2, 3), { 'README.md' => 'v%.%.%', 'package.json' => 'v%.%.%' }, nil
|
7
|
+
end
|
6
8
|
|
7
|
-
|
8
|
-
|
9
|
-
|
9
|
+
describe '#commit_message' do
|
10
|
+
it 'gets the commit message' do
|
11
|
+
@info = Bump::BumpInfo.new Bump::VersionNumber.new(1, 2, 3), { 'README.md' => 'v%.%.%', 'package.json' => 'v%.%.%' }, 'chore(bump): v%.%.%'
|
10
12
|
|
13
|
+
expect(@info.commit_message).to eq 'chore(bump): v1.2.3'
|
11
14
|
end
|
15
|
+
end
|
12
16
|
|
13
|
-
|
14
|
-
|
15
|
-
|
17
|
+
describe '#bump' do
|
18
|
+
it 'bumps the version with the give level' do
|
19
|
+
@info.bump :patch
|
20
|
+
expect(@info.version.to_s).to eq '1.2.4'
|
16
21
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
end
|
22
|
+
@info.bump :minor
|
23
|
+
expect(@info.version.to_s).to eq '1.3.0'
|
21
24
|
|
25
|
+
@info.bump :major
|
26
|
+
expect(@info.version.to_s).to eq '2.0.0'
|
22
27
|
end
|
28
|
+
end
|
23
29
|
|
24
|
-
|
30
|
+
describe '#preid=' do
|
31
|
+
it 'sets the preid' do
|
32
|
+
@info.preid = 'beta.1'
|
25
33
|
|
26
|
-
|
34
|
+
expect(@info.version.to_s).to eq '1.2.3-beta.1'
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe '#update_rules' do
|
39
|
+
it 'gets the file update rules' do
|
40
|
+
expect(@info.update_rules.class).to eq Array
|
41
|
+
expect(@info.update_rules.size).to eq 2
|
42
|
+
expect(@info.update_rules[0].class).to eq Bump::FileUpdateRule
|
43
|
+
expect(@info.update_rules[1].class).to eq Bump::FileUpdateRule
|
44
|
+
end
|
45
|
+
end
|
27
46
|
|
28
|
-
|
47
|
+
describe '#perform_update' do
|
48
|
+
it 'performs the update on files' do
|
49
|
+
File.write 'spec/fixture/tmp_dummy.txt', File.read('spec/fixture/dummy.txt', encoding: Encoding::UTF_8)
|
29
50
|
|
30
|
-
|
51
|
+
@info = Bump::BumpInfo.new Bump::VersionNumber.new(1, 2, 3, 'rc1'), { 'spec/fixture/tmp_dummy.txt' => 'v%.%.%' }, nil
|
31
52
|
|
32
|
-
|
53
|
+
@info.bump :patch
|
33
54
|
|
34
|
-
|
55
|
+
@info.perform_update
|
35
56
|
|
36
|
-
|
57
|
+
expect(File.read('spec/fixture/tmp_dummy.txt', encoding: Encoding::UTF_8).strip).to eq 'dummy v1.2.4'
|
37
58
|
|
38
|
-
|
39
|
-
|
59
|
+
File.delete 'spec/fixture/tmp_dummy.txt'
|
60
|
+
end
|
61
|
+
end
|
40
62
|
|
41
|
-
|
42
|
-
|
63
|
+
describe '#valid?' do
|
64
|
+
it 'returns false if the files or petterns are unavailable' do
|
65
|
+
expect(@info.valid?).to be false
|
66
|
+
end
|
43
67
|
|
44
|
-
|
45
|
-
|
68
|
+
it 'returns true if the files and patterns are available' do
|
69
|
+
@info = Bump::BumpInfo.new Bump::VersionNumber.new(1, 2, 3, 'rc1'), { 'spec/fixture/dummy.txt' => 'v%.%.%' }, nil
|
46
70
|
|
47
|
-
|
71
|
+
expect(@info.valid?).to be true
|
48
72
|
end
|
49
|
-
|
73
|
+
end
|
50
74
|
end
|
@@ -1,37 +1,27 @@
|
|
1
|
-
|
2
1
|
require 'bump'
|
3
2
|
require 'spec_helper'
|
4
3
|
|
5
4
|
describe Bump::FileUpdateRuleFactory do
|
5
|
+
describe 'self.create' do
|
6
|
+
it 'creates a FileUpdateRule if the give param is string' do
|
7
|
+
rule = Bump::FileUpdateRuleFactory.create 'README.md', 'v%.%.%', '1.2.3', '2.0.0'
|
6
8
|
|
7
|
-
|
8
|
-
|
9
|
-
it 'creates a FileUpdateRule if the give param is string' do
|
10
|
-
|
11
|
-
rule = Bump::FileUpdateRuleFactory.create 'README.md', 'v%.%.%', '1.2.3', '2.0.0'
|
12
|
-
|
13
|
-
expect(rule.class).to eq Bump::FileUpdateRule
|
14
|
-
|
15
|
-
end
|
16
|
-
|
17
|
-
it 'craetes a list of FileUpdateRules if the give param is an array of string' do
|
18
|
-
|
19
|
-
rules = Bump::FileUpdateRuleFactory.create 'READEME.md', ['v%.%.%', 'w%.%.%'], '1.2.3', '2.0.0'
|
20
|
-
|
21
|
-
expect(rules.class).to eq Array
|
22
|
-
expect(rules[0].class).to eq Bump::FileUpdateRule
|
23
|
-
expect(rules[1].class).to eq Bump::FileUpdateRule
|
24
|
-
expect(rules.size).to eq 2
|
25
|
-
end
|
26
|
-
|
27
|
-
it 'creates a FileUpdateRule if the given param is not a string nor an array' do
|
9
|
+
expect(rule.class).to eq Bump::FileUpdateRule
|
10
|
+
end
|
28
11
|
|
29
|
-
|
12
|
+
it 'craetes a list of FileUpdateRules if the give param is an array of string' do
|
13
|
+
rules = Bump::FileUpdateRuleFactory.create 'READEME.md', ['v%.%.%', 'w%.%.%'], '1.2.3', '2.0.0'
|
30
14
|
|
31
|
-
|
15
|
+
expect(rules.class).to eq Array
|
16
|
+
expect(rules[0].class).to eq Bump::FileUpdateRule
|
17
|
+
expect(rules[1].class).to eq Bump::FileUpdateRule
|
18
|
+
expect(rules.size).to eq 2
|
19
|
+
end
|
32
20
|
|
33
|
-
|
21
|
+
it 'creates a FileUpdateRule if the given param is not a string nor an array' do
|
22
|
+
rule = Bump::FileUpdateRuleFactory.create 'READEME.md', nil, '1.2.3', '2.0.0'
|
34
23
|
|
24
|
+
expect(rule.class).to eq Bump::FileUpdateRule
|
35
25
|
end
|
36
|
-
|
26
|
+
end
|
37
27
|
end
|
@@ -2,49 +2,39 @@ require 'bump'
|
|
2
2
|
require 'spec_helper'
|
3
3
|
|
4
4
|
describe Bump::FileUpdateRule do
|
5
|
+
before :each do
|
6
|
+
File.write 'spec/fixture/tmp_dummy.txt', File.read('spec/fixture/dummy.txt', encoding: Encoding::UTF_8)
|
5
7
|
|
6
|
-
|
7
|
-
|
8
|
-
end
|
9
|
-
|
10
|
-
describe '#file' do
|
11
|
-
|
12
|
-
it 'returns file property' do
|
13
|
-
|
14
|
-
expect(@rule.file).to eq 'spec/fixture/dummy.txt'
|
8
|
+
@rule = Bump::FileUpdateRule.new 'spec/fixture/tmp_dummy.txt', 'v%.%.%', '1.2.3', '2.0.0'
|
9
|
+
end
|
15
10
|
|
16
|
-
|
11
|
+
after :each do
|
12
|
+
File.delete 'spec/fixture/tmp_dummy.txt'
|
13
|
+
end
|
17
14
|
|
15
|
+
describe '#file_exists' do
|
16
|
+
it 'returns true if file exists' do
|
17
|
+
expect(@rule.file_exists).to be true
|
18
18
|
end
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
it 'returns before_pattern property' do
|
23
|
-
|
24
|
-
expect(@rule.beforePattern).to eq 'v1.2.3'
|
25
|
-
|
26
|
-
end
|
20
|
+
it 'returns false if file does not exist' do
|
21
|
+
@rule = Bump::FileUpdateRule.new 'spec/fixture/doesnotexist.txt', 'v%.%.%', '1.2.3', '2.0.0'
|
27
22
|
|
23
|
+
expect(@rule.file_exists).to be false
|
28
24
|
end
|
25
|
+
end
|
29
26
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
expect(@rule.afterPattern).to eq 'v2.0.0'
|
35
|
-
|
36
|
-
end
|
37
|
-
|
27
|
+
describe '#pattern_exists' do
|
28
|
+
it 'checks if the given pattern found in the file' do
|
29
|
+
expect(@rule.pattern_exists).to be true
|
38
30
|
end
|
31
|
+
end
|
39
32
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
expect(@rule.patternExists).to be true
|
45
|
-
|
46
|
-
end
|
33
|
+
describe '#perform' do
|
34
|
+
it 'performs the pattern replacement in the file' do
|
35
|
+
@rule.perform
|
47
36
|
|
37
|
+
expect(File.read('spec/fixture/tmp_dummy.txt', encoding: Encoding::UTF_8).strip).to eq 'dummy v2.0.0-rc1'
|
48
38
|
end
|
49
|
-
|
39
|
+
end
|
50
40
|
end
|
@@ -1,41 +1,18 @@
|
|
1
|
-
|
2
1
|
require 'bump'
|
3
2
|
require 'spec_helper'
|
4
3
|
|
5
4
|
describe Bump::VersionNumberFactory do
|
5
|
+
describe '#from_string' do
|
6
|
+
it 'creates version object from version string' do
|
7
|
+
version = Bump::VersionNumberFactory.from_string '1.2.3-a'
|
6
8
|
|
7
|
-
|
8
|
-
|
9
|
-
it "creates version object from version string" do
|
10
|
-
|
11
|
-
version = Bump::VersionNumberFactory.fromString "1.2.3-a"
|
12
|
-
|
13
|
-
expect(version.to_s).to eq "1.2.3-a"
|
14
|
-
|
15
|
-
version.bump :patch
|
16
|
-
|
17
|
-
expect(version.to_s).to eq "1.2.4"
|
18
|
-
|
19
|
-
version.bump :minor
|
20
|
-
|
21
|
-
expect(version.to_s).to eq "1.3.0"
|
9
|
+
expect(version.to_s).to eq '1.2.3-a'
|
22
10
|
|
23
|
-
|
11
|
+
version = Bump::VersionNumberFactory.from_string '1.2.100-abc'
|
24
12
|
|
25
|
-
|
26
|
-
|
27
|
-
version.setPreid 'rc1'
|
28
|
-
|
29
|
-
expect(version.to_s).to eq "2.0.0-rc1"
|
30
|
-
|
31
|
-
version = Bump::VersionNumberFactory.fromString "1.2.100-abc"
|
32
|
-
|
33
|
-
version.bump :patch
|
34
|
-
|
35
|
-
expect(version.to_s).to eq "1.2.101"
|
36
|
-
|
37
|
-
end
|
13
|
+
version.bump :patch
|
38
14
|
|
15
|
+
expect(version.to_s).to eq '1.2.101'
|
39
16
|
end
|
40
|
-
|
17
|
+
end
|
41
18
|
end
|
@@ -1,132 +1,80 @@
|
|
1
|
-
# bump_spec.rb
|
2
|
-
|
3
1
|
require 'bump'
|
4
2
|
require 'spec_helper'
|
5
3
|
|
6
4
|
describe Bump::VersionNumber do
|
5
|
+
describe '#to_s' do
|
6
|
+
it 'returns version string' do
|
7
|
+
# no suffix
|
8
|
+
version = Bump::VersionNumber.new 1, 2, 3
|
7
9
|
|
8
|
-
|
9
|
-
|
10
|
-
it "returns version string" do
|
11
|
-
|
12
|
-
# no suffix
|
13
|
-
version = Bump::VersionNumber.new 1, 2, 3
|
14
|
-
|
15
|
-
expect(version.to_s).to eq '1.2.3'
|
16
|
-
|
17
|
-
# with a suffix
|
18
|
-
version = Bump::VersionNumber.new 1, 2, 3, 'rc1'
|
19
|
-
|
20
|
-
expect(version.to_s).to eq '1.2.3-rc1'
|
10
|
+
expect(version.to_s).to eq '1.2.3'
|
21
11
|
|
22
|
-
|
12
|
+
# with a suffix
|
13
|
+
version = Bump::VersionNumber.new 1, 2, 3, 'rc1'
|
23
14
|
|
15
|
+
expect(version.to_s).to eq '1.2.3-rc1'
|
24
16
|
end
|
17
|
+
end
|
25
18
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
version = Bump::VersionNumber.new 1, 2, 3
|
31
|
-
|
32
|
-
version.bump :patch
|
33
|
-
|
34
|
-
expect(version.to_s).to eq '1.2.4'
|
35
|
-
|
36
|
-
end
|
19
|
+
describe '#bump :patch' do
|
20
|
+
it 'bumps patch level' do
|
21
|
+
version = Bump::VersionNumber.new 1, 2, 3
|
37
22
|
|
38
|
-
|
39
|
-
|
40
|
-
version = Bump::VersionNumber.new 0, 1, 10
|
41
|
-
|
42
|
-
version.bump :patch
|
43
|
-
|
44
|
-
expect(version.to_s).to eq '0.1.11'
|
45
|
-
|
46
|
-
end
|
47
|
-
|
48
|
-
it "remove suffix if it is set" do
|
49
|
-
|
50
|
-
version = Bump::VersionNumber.new 1, 2, 3, 'rc1'
|
51
|
-
|
52
|
-
version.bump :patch
|
53
|
-
|
54
|
-
expect(version.to_s).to eq '1.2.4'
|
55
|
-
|
56
|
-
end
|
23
|
+
version.bump :patch
|
57
24
|
|
25
|
+
expect(version.to_s).to eq '1.2.4'
|
58
26
|
end
|
59
27
|
|
60
|
-
|
61
|
-
|
62
|
-
it "bumps patch level" do
|
28
|
+
it 'bumps 0.1.10 to 0.1.11' do
|
29
|
+
version = Bump::VersionNumber.new 0, 1, 10
|
63
30
|
|
64
|
-
|
65
|
-
|
66
|
-
version.bump :minor
|
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::VersionNumber.new 1, 2, 3, 'rc1'
|
75
|
-
|
76
|
-
version.bump :minor
|
77
|
-
|
78
|
-
expect(version.to_s).to eq '1.3.0'
|
79
|
-
|
80
|
-
end
|
31
|
+
version.bump :patch
|
81
32
|
|
33
|
+
expect(version.to_s).to eq '0.1.11'
|
82
34
|
end
|
83
35
|
|
84
|
-
|
85
|
-
|
86
|
-
it "bumps patch level" do
|
87
|
-
|
88
|
-
version = Bump::VersionNumber.new 1, 2, 3
|
89
|
-
|
90
|
-
version.bump :major
|
36
|
+
it 'remove suffix if it is set' do
|
37
|
+
version = Bump::VersionNumber.new 1, 2, 3, 'rc1'
|
91
38
|
|
92
|
-
|
93
|
-
|
94
|
-
end
|
95
|
-
|
96
|
-
it "remove suffix if it is set" do
|
97
|
-
|
98
|
-
version = Bump::VersionNumber.new 1, 2, 3, 'rc1'
|
99
|
-
|
100
|
-
version.bump :major
|
101
|
-
|
102
|
-
expect(version.to_s).to eq '2.0.0'
|
103
|
-
|
104
|
-
end
|
39
|
+
version.bump :patch
|
105
40
|
|
41
|
+
expect(version.to_s).to eq '1.2.4'
|
106
42
|
end
|
43
|
+
end
|
107
44
|
|
108
|
-
|
45
|
+
describe '#bump :minor' do
|
46
|
+
it 'bumps patch level' do
|
47
|
+
version = Bump::VersionNumber.new 1, 2, 3
|
109
48
|
|
110
|
-
|
49
|
+
version.bump :minor
|
111
50
|
|
112
|
-
|
51
|
+
expect(version.to_s).to eq '1.3.0'
|
52
|
+
end
|
113
53
|
|
114
|
-
|
54
|
+
it 'remove suffix if it is set' do
|
55
|
+
version = Bump::VersionNumber.new 1, 2, 3, 'rc1'
|
115
56
|
|
116
|
-
|
57
|
+
version.bump :minor
|
117
58
|
|
118
|
-
|
59
|
+
expect(version.to_s).to eq '1.3.0'
|
60
|
+
end
|
61
|
+
end
|
119
62
|
|
120
|
-
|
63
|
+
describe '#bump :major' do
|
64
|
+
it 'bumps patch level' do
|
65
|
+
version = Bump::VersionNumber.new 1, 2, 3
|
121
66
|
|
122
|
-
|
67
|
+
version.bump :major
|
123
68
|
|
124
|
-
|
69
|
+
expect(version.to_s).to eq '2.0.0'
|
70
|
+
end
|
125
71
|
|
126
|
-
|
72
|
+
it 'remove suffix if it is set' do
|
73
|
+
version = Bump::VersionNumber.new 1, 2, 3, 'rc1'
|
127
74
|
|
128
|
-
|
75
|
+
version.bump :major
|
129
76
|
|
77
|
+
expect(version.to_s).to eq '2.0.0'
|
130
78
|
end
|
131
|
-
|
79
|
+
end
|
132
80
|
end
|