Class: Bummr::Updater
Instance Method Summary collapse
-
#initialize(outdated_gems) ⇒ Updater
constructor
A new instance of Updater.
- #update_gem(gem, index) ⇒ Object
- #update_gems ⇒ Object
- #updated_version_for(gem) ⇒ Object
Methods included from Log
Constructor Details
#initialize(outdated_gems) ⇒ Updater
Returns a new instance of Updater.
6 7 8 |
# File 'lib/bummr/updater.rb', line 6 def initialize(outdated_gems) @outdated_gems = outdated_gems end |
Instance Method Details
#update_gem(gem, index) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/bummr/updater.rb', line 18 def update_gem(gem, index) puts "Updating #{gem[:name]}: #{index+1} of #{@outdated_gems.count}" system("bundle update #{gem[:name]}") updated_version = updated_version_for(gem) if (updated_version) = "Update #{gem[:name]} from #{gem[:installed]} to #{updated_version}" else = "Update dependencies for #{gem[:name]}" end if gem[:installed] == updated_version log("#{gem[:name]} not updated") return end if gem[:newest] != updated_version log("#{gem[:name]} not updated from #{gem[:installed]} to latest: #{gem[:newest]}") end git.add("Gemfile") git.add("Gemfile.lock") git.add("vendor/cache") git.commit() end |
#update_gems ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/bummr/updater.rb', line 10 def update_gems puts "Updating outdated gems".color(:green) @outdated_gems.each_with_index do |gem, index| update_gem(gem, index) end end |
#updated_version_for(gem) ⇒ Object
45 46 47 |
# File 'lib/bummr/updater.rb', line 45 def updated_version_for(gem) `bundle list | grep " #{gem[:name]} "`&.split('(')[1].split(')')[0] end |