bummr 0.3.0 → 0.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 +4 -4
- data/README.md +1 -0
- data/lib/bummr/cli.rb +5 -2
- data/lib/bummr/outdated.rb +6 -5
- data/lib/bummr/version.rb +1 -1
- data/spec/lib/cli_spec.rb +30 -21
- data/spec/lib/outdated_spec.rb +40 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dfc66045a4cf51578172ac7c875574465d60b019
|
4
|
+
data.tar.gz: 343b2794e4c16c57b938a26a41aa256df41216c3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 36acc698fe92f04a82c4158bf7600a9453dc2235cbb58c4a125fd05280eaf8abc60d811d9c8f4675ad29df9b14a55f6043ade5c79842daae6c58c3000487ab37
|
7
|
+
data.tar.gz: e68e9a0212deeb3211904b8549b4e7be67d2eb657bc389faaf964e17c9c7519d007aecac6d848a1196c8eae736430b6dc5d733b630088098241dd6a2a2ceb063
|
data/README.md
CHANGED
@@ -63,6 +63,7 @@ instructions in the Installation section of this README.
|
|
63
63
|
- Commits each gem update separately, with a commit message like:
|
64
64
|
- Options:
|
65
65
|
- `--all` to include indirect dependencies (`bummr` defaults to direct dependencies only)
|
66
|
+
- `--group` to update only gems from a specific group (i.e. `test`, `development`)
|
66
67
|
|
67
68
|
`Update gemname from 0.0.1 to 0.0.2`
|
68
69
|
|
data/lib/bummr/cli.rb
CHANGED
@@ -12,6 +12,7 @@ module Bummr
|
|
12
12
|
|
13
13
|
desc "update", "Update outdated gems, run tests, bisect if tests fail"
|
14
14
|
method_option :all, type: :boolean, default: false
|
15
|
+
method_option :group, type: :string
|
15
16
|
def update
|
16
17
|
ask_questions
|
17
18
|
|
@@ -20,7 +21,9 @@ module Bummr
|
|
20
21
|
log("Bummr update initiated #{Time.now}")
|
21
22
|
system("bundle")
|
22
23
|
|
23
|
-
outdated_gems = Bummr::Outdated.instance.outdated_gems(
|
24
|
+
outdated_gems = Bummr::Outdated.instance.outdated_gems(
|
25
|
+
all_gems: options[:all], group: options[:group]
|
26
|
+
)
|
24
27
|
|
25
28
|
if outdated_gems.empty?
|
26
29
|
puts "No outdated gems to update".color(:green)
|
@@ -66,7 +69,7 @@ module Bummr
|
|
66
69
|
puts "- Have a 'log' directory, where we can place logs"
|
67
70
|
puts "- Have your build configured to fail fast (recommended)"
|
68
71
|
puts "- Have locked any Gem version that you don't wish to update in your Gemfile"
|
69
|
-
puts "- It is recommended that you lock your versions of `ruby` and `rails in your Gemfile`"
|
72
|
+
puts "- It is recommended that you lock your versions of `ruby` and `rails` in your `Gemfile`"
|
70
73
|
puts "Your test command is: '#{TEST_COMMAND}'"
|
71
74
|
end
|
72
75
|
end
|
data/lib/bummr/outdated.rb
CHANGED
@@ -5,18 +5,19 @@ module Bummr
|
|
5
5
|
class Outdated
|
6
6
|
include Singleton
|
7
7
|
|
8
|
-
def outdated_gems(
|
8
|
+
def outdated_gems(options = {})
|
9
9
|
results = []
|
10
10
|
|
11
|
-
|
12
|
-
|
11
|
+
bundle_options = ""
|
12
|
+
bundle_options << " --strict" unless options[:all_gems]
|
13
|
+
bundle_options << " --group #{options[:group]}" if options[:group]
|
13
14
|
|
14
|
-
Open3.popen2("bundle outdated" +
|
15
|
+
Open3.popen2("bundle outdated" + bundle_options) do |_std_in, std_out|
|
15
16
|
while line = std_out.gets
|
16
17
|
puts line
|
17
18
|
gem = parse_gem_from(line)
|
18
19
|
|
19
|
-
if gem && (all_gems || gemfile_contains(gem[:name]))
|
20
|
+
if gem && (options[:all_gems] || gemfile_contains(gem[:name]))
|
20
21
|
results.push gem
|
21
22
|
end
|
22
23
|
end
|
data/lib/bummr/version.rb
CHANGED
data/spec/lib/cli_spec.rb
CHANGED
@@ -25,6 +25,20 @@ describe Bummr::CLI do
|
|
25
25
|
end
|
26
26
|
|
27
27
|
context "when user agrees to move forward" do
|
28
|
+
def mock_bummr_standard_flow
|
29
|
+
updater = double
|
30
|
+
allow(updater).to receive(:update_gems)
|
31
|
+
|
32
|
+
expect(cli).to receive(:ask_questions)
|
33
|
+
expect(cli).to receive(:yes?).and_return(true)
|
34
|
+
expect(cli).to receive(:check)
|
35
|
+
expect(cli).to receive(:log)
|
36
|
+
expect(cli).to receive(:system).with("bundle")
|
37
|
+
expect(Bummr::Updater).to receive(:new).with(outdated_gems).and_return updater
|
38
|
+
expect(cli).to receive(:system).with("git rebase -i #{BASE_BRANCH}")
|
39
|
+
expect(cli).to receive(:test)
|
40
|
+
end
|
41
|
+
|
28
42
|
context "and there are no outdated gems" do
|
29
43
|
it "informs that there are no outdated gems" do
|
30
44
|
allow_any_instance_of(Bummr::Outdated).to receive(:outdated_gems)
|
@@ -45,17 +59,8 @@ describe Bummr::CLI do
|
|
45
59
|
it "calls 'update' on the updater" do
|
46
60
|
allow_any_instance_of(Bummr::Outdated).to receive(:outdated_gems)
|
47
61
|
.and_return outdated_gems
|
48
|
-
updater = double
|
49
|
-
allow(updater).to receive(:update_gems)
|
50
62
|
|
51
|
-
|
52
|
-
expect(cli).to receive(:yes?).and_return(true)
|
53
|
-
expect(cli).to receive(:check)
|
54
|
-
expect(cli).to receive(:log)
|
55
|
-
expect(cli).to receive(:system).with("bundle")
|
56
|
-
expect(Bummr::Updater).to receive(:new).with(outdated_gems).and_return updater
|
57
|
-
expect(cli).to receive(:system).with("git rebase -i #{BASE_BRANCH}")
|
58
|
-
expect(cli).to receive(:test)
|
63
|
+
mock_bummr_standard_flow
|
59
64
|
|
60
65
|
cli.update
|
61
66
|
end
|
@@ -66,20 +71,24 @@ describe Bummr::CLI do
|
|
66
71
|
options[:all] = true
|
67
72
|
|
68
73
|
expect_any_instance_of(Bummr::Outdated)
|
69
|
-
.to receive(:outdated_gems).with({ all_gems: true })
|
74
|
+
.to receive(:outdated_gems).with(hash_including({ all_gems: true }))
|
70
75
|
.and_return outdated_gems
|
71
76
|
|
72
|
-
|
73
|
-
allow(updater).to receive(:update_gems)
|
77
|
+
mock_bummr_standard_flow
|
74
78
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
79
|
+
cli.update
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
describe "group option" do
|
84
|
+
it "requests only outdated gems from supplied be listed" do
|
85
|
+
options[:group] = 'test'
|
86
|
+
|
87
|
+
expect_any_instance_of(Bummr::Outdated)
|
88
|
+
.to receive(:outdated_gems).with(hash_including({ group: 'test' }))
|
89
|
+
.and_return outdated_gems
|
90
|
+
|
91
|
+
mock_bummr_standard_flow
|
83
92
|
|
84
93
|
cli.update
|
85
94
|
end
|
data/spec/lib/outdated_spec.rb
CHANGED
@@ -7,6 +7,7 @@ describe Bummr::Outdated do
|
|
7
7
|
output += " * devise (newest 4.1.1, installed 3.5.2) in group \"default\"\n"
|
8
8
|
output += " * rake (newest 11.1.2, installed 10.4.2)\n"
|
9
9
|
output += " * rails (newest 4.2.6, installed 4.2.5.1, requested ~> 4.2.0) in group \"default\"\n"
|
10
|
+
output += " * spring (newest 4.2.6, installed 4.2.5.1, requested ~> 4.2.0) in group \"development\"\n"
|
10
11
|
output += " * indirect_dep (newest 1.0.0, installed 0.0.1)\n"
|
11
12
|
StringIO.new(output)
|
12
13
|
}
|
@@ -16,6 +17,7 @@ describe Bummr::Outdated do
|
|
16
17
|
gemfile += "gem 'devise'\n"
|
17
18
|
gemfile += "gem 'rake'\n"
|
18
19
|
gemfile += "gem 'rails'\n"
|
20
|
+
gemfile += "gem 'spring', :group => :development\n"
|
19
21
|
gemfile
|
20
22
|
}
|
21
23
|
|
@@ -38,6 +40,10 @@ describe Bummr::Outdated do
|
|
38
40
|
expect(result[2][:name]).to eq('rails')
|
39
41
|
expect(result[2][:newest]).to eq('4.2.6')
|
40
42
|
expect(result[2][:installed]).to eq('4.2.5.1')
|
43
|
+
|
44
|
+
expect(result[3][:name]).to eq('spring')
|
45
|
+
expect(result[3][:newest]).to eq('4.2.6')
|
46
|
+
expect(result[3][:installed]).to eq('4.2.5.1')
|
41
47
|
end
|
42
48
|
|
43
49
|
describe "all gems option" do
|
@@ -63,6 +69,40 @@ describe Bummr::Outdated do
|
|
63
69
|
expect(gem_names).to_not include "indirect_dep"
|
64
70
|
end
|
65
71
|
end
|
72
|
+
|
73
|
+
describe "group option" do
|
74
|
+
let(:stdoutput_from_development_group) {
|
75
|
+
output = String.new
|
76
|
+
output += " * spring (newest 4.2.6, installed 4.2.5.1, requested ~> 4.2.0)"
|
77
|
+
StringIO.new(output)
|
78
|
+
}
|
79
|
+
|
80
|
+
it "lists outdated gems only from supplied group" do
|
81
|
+
allow(Open3).to receive(:popen2)
|
82
|
+
.with("bundle outdated --strict --group development")
|
83
|
+
.and_yield(nil, stdoutput_from_development_group)
|
84
|
+
|
85
|
+
allow(Bummr::Outdated.instance).to receive(:gemfile).and_return gemfile
|
86
|
+
|
87
|
+
results = Bummr::Outdated.instance.outdated_gems(group: :development)
|
88
|
+
gem_names = results.map { |result| result[:name] }
|
89
|
+
|
90
|
+
expect(gem_names).to match_array ['spring']
|
91
|
+
end
|
92
|
+
|
93
|
+
it "defaults to all groups" do
|
94
|
+
allow(Open3).to receive(:popen2)
|
95
|
+
.with("bundle outdated --strict")
|
96
|
+
.and_yield(nil, stdoutput)
|
97
|
+
|
98
|
+
allow(Bummr::Outdated.instance).to receive(:gemfile).and_return gemfile
|
99
|
+
|
100
|
+
results = Bummr::Outdated.instance.outdated_gems
|
101
|
+
gem_names = results.map { |result| result[:name] }
|
102
|
+
|
103
|
+
expect(gem_names).to include 'devise', 'rake', 'rails', 'spring'
|
104
|
+
end
|
105
|
+
end
|
66
106
|
end
|
67
107
|
|
68
108
|
describe "#parse_gem_from" do
|