Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
bummr (1.2.0)
bummr (1.2.1a)
rainbow
thor

Expand Down
2 changes: 1 addition & 1 deletion lib/bummr/git.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def files_staged?
end

def commit(message)
log "Commit: #{message}".color(:green)
log("Commit:".color(:green) + %Q| "#{message}"|)
system("#{git_commit} -m '#{message}'")
end

Expand Down
2 changes: 1 addition & 1 deletion lib/bummr/log.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module Bummr
module Log
def log(message)
puts message
system("touch log/bummr.log && echo '#{message}' >> log/bummr.log")
system("touch log/bummr.log && echo '#{Rainbow.uncolor(message)}' >> log/bummr.log")
end
end
end
16 changes: 9 additions & 7 deletions lib/bummr/outdated.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ class Outdated
def outdated_gems(options = {})
results = []

bundle_options = ""
bundle_options << " --parseable" if Gem::Version.new(Bundler::VERSION) >= Gem::Version.new("2")
bundle_options << " --strict" unless options[:all_gems]
bundle_options << " --group #{options[:group]}" if options[:group]
bundle_options << " #{options[:gem]}" if options[:gem]

Open3.popen2("bundle outdated" + bundle_options) do |_std_in, std_out|
bundle_options = []
bundle_options << "--parseable" if Gem::Version.new(Bundler::VERSION) >= Gem::Version.new("2")
bundle_options << "--strict" unless options[:all_gems]
bundle_options << "--group #{options[:group]}" if options[:group]
bundle_options << "#{options[:gem]}" if options[:gem]

cmd = "bundle outdated #{bundle_options.join(' ')}"
puts "Find Outdated Gems: '#{cmd}'"
Open3.popen2(cmd) do |_std_in, std_out|
while line = std_out.gets
puts line # TODO: remove this if possible (pointless for spec tests)
gem = parse_gem_from(line)
Expand Down
11 changes: 8 additions & 3 deletions lib/bummr/updater.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,25 @@ def update_outdated_gems
end

def update_gem(gem, index)
puts "Updating #{gem[:name]}: #{index + 1} of #{@outdated_gems.count}"
puts "------------\nUpdating #{gem[:name].color(:magenta)}: #{index + 1} of #{@outdated_gems.count}"

system("bundle update #{gem[:name]}")

# Get the current (maybe new?) bundled version for this gem
bundled_version = bundled_version_for(gem)

# If the gem could not be updated at all
if gem[:installed] == bundled_version
log("#{gem[:name]} not updated")
log("Updating #{gem[:name]} cannot be completed".color(:yellow))
# might still be dependency updates, so cannot stop here

# If the gem was updated, but not to latest
elsif gem[:newest] != bundled_version
log("#{gem[:name]} not updated from #{gem[:installed]} to latest: #{gem[:newest]}")
log("Newer #{gem[:name]} installed".color(:yellow) + " - updated from #{gem[:installed]} to #{bundled_version}" + " (latest: #{gem[:newest]})".color(:green))

# Is using the latest version
else
log("Latest #{gem[:name]} installed - updated from #{gem[:installed]} to #{bundled_version.color(:green)}")
end

git.add("Gemfile")
Expand Down
2 changes: 1 addition & 1 deletion lib/bummr/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Bummr
VERSION = "1.2.0"
VERSION = "1.2.1a".freeze
end
4 changes: 2 additions & 2 deletions spec/lib/cli_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def mock_bummr_standard_flow
expect(cli).to receive(:check)
expect(cli).to receive(:log)
expect(cli).to receive(:system).with("bundle install")
expect(cli).to receive(:puts).with("No outdated gems to update".color(:green))
expect(cli).to receive(:puts).with("No outdated gems to update")

cli.update
end
Expand Down Expand Up @@ -126,7 +126,7 @@ def mock_bummr_standard_flow
expect(cli).to receive(:check)
expect(cli).to receive(:log)
expect(cli).to receive(:system).with("bundle install")
expect(cli).to receive(:puts).with("No outdated gems to update".color(:green))
expect(cli).to receive(:puts).with("No outdated gems to update")

cli.update
end
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/git_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
git.commit(commit_message)

expect(git).to have_received(:log).with(
/Commit: #{commit_message}/
%Q|Commit: "#{commit_message}"|
)
end

Expand Down
2 changes: 1 addition & 1 deletion spec/lib/remover_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
remover.remove_commit(sha)

expect(remover).to have_received(:log).with(
"Bad commit: commit message, #{sha}".color(:red)
"Bad commit: commit message, #{sha}"
)
end

Expand Down
18 changes: 15 additions & 3 deletions spec/lib/updater_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,12 @@ def mock_system_log_commit_puts
end

it "logs that it was not updated" do
cannot_update_message =
"Updating #{gem[:name]} cannot be completed"

updater.update_gem(gem, 0)

expect(updater).to have_received(:log).with("#{gem[:name]} not updated")
expect(updater).to have_received(:log).with(cannot_update_message)
end

context "and no dependencies were updated" do
Expand Down Expand Up @@ -107,11 +110,11 @@ def mock_system_log_commit_puts

it "logs that it's not updated to the latest" do
not_latest_message =
"#{gem[:name]} not updated from #{gem[:installed]} to latest: #{gem[:newest]}"
"Newer #{gem[:name]} installed - updated from #{gem[:installed]} to #{intermediate_version} (latest: #{gem[:newest]})"

updater.update_gem(gem, 0)

expect(updater).to have_received(:log).with not_latest_message
expect(updater).to have_received(:log).with(not_latest_message)
end

it "commits" do
Expand All @@ -136,6 +139,15 @@ def mock_system_log_commit_puts
mock_system_log_commit_puts
end

it "logs that was updated to the latest" do
latest_message =
"Latest #{gem[:name]} installed - updated from #{gem[:installed]} to #{gem[:newest]}"

updater.update_gem(gem, 0)

expect(updater).to have_received(:log).with(latest_message)
end

it "commits" do
commit_message =
"Update #{gem[:name]} from #{gem[:installed]} to #{gem[:newest]}"
Expand Down
13 changes: 13 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,16 @@
require 'bummr'
require 'rainbow/ext/string'
require 'jet_black/rspec'

# Disable all colorize methods both in lib and spec files
# This makes it easier to compare plain strings
Rainbow.enabled = false

=begin
RSpec.configure do |config|
# NOTE: before(:suite) does not allow mocking (allow, or allow_any_instance_of)
config.before(:each) do

end
end
=end