Class: AutoGemUpdater::Updater
- Inherits:
-
Object
- Object
- AutoGemUpdater::Updater
- Includes:
- System
- Defined in:
- lib/auto_gem_updater/updater.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(outdated_gems:) ⇒ Updater
constructor
A new instance of Updater.
- #perform ⇒ Object
Methods included from System
Constructor Details
#initialize(outdated_gems:) ⇒ Updater
Returns a new instance of Updater.
12 13 14 |
# File 'lib/auto_gem_updater/updater.rb', line 12 def initialize(outdated_gems:) @outdated_gems = outdated_gems end |
Class Method Details
.perform ⇒ Object
8 9 10 |
# File 'lib/auto_gem_updater/updater.rb', line 8 def self.perform new(outdated_gems: AutoGemUpdater::Outdated.perform).perform end |
Instance Method Details
#perform ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/auto_gem_updater/updater.rb', line 17 def perform return unless outdated_gems.any? return unless system("git checkout -b auto_gem_updates_#{Time.now.strftime('%d_%m_%Y')}") outdated_gems.each do |name:, newest:, installed:| puts "Updating #{name} from #{installed} to #{newest}" system_command("bundle update #{name} --conservative") if AutoGemUpdater.pre_checks.all? { |check| system_command(check) } puts "Update checks passed commiting update to #{name}" system_command('git add Gemfile.lock') system_command("git commit -m 'Updated: #{name} from #{installed} to #{newest}'") else puts "Failed to update the gem #{name}" system_command('git checkout Gemfile.lock') end end end |