Class: SafeUpdate::Updater

Inherits:
Object
  • Object
show all
Defined in:
lib/safe_update/updater.rb

Instance Method Summary collapse

Instance Method Details

#run(options = {}) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/safe_update/updater.rb', line 3

def run(options = {})
  options[:push] = options[:push].to_i if options[:push]
  check_for_staged_changes
  check_for_gemfile_lock_changes
  output_array = bundle_outdated_parseable.split(/\n+/)
  output_array.to_enum.with_index(1) do |line, index|
    update_gem(line)
    `git push` if options[:push] && index % options[:push] == 0
  end

  # run it once at the very end, so the final commit can be tested in CI
  `git push` if options[:push]

  puts '-------------'
  puts '-------------'
  puts 'FINISHED'
end