Class: SafeUpdate::Updater
- Inherits:
-
Object
- Object
- SafeUpdate::Updater
- Defined in:
- lib/safe_update/updater.rb
Instance Method Summary collapse
-
#initialize(git_repo = nil) ⇒ Updater
constructor
A new instance of Updater.
-
#run(push: nil, test_command: nil) ⇒ Object
push: If push is eg.
Constructor Details
Instance Method Details
#run(push: nil, test_command: nil) ⇒ Object
push:
If push is eg. 3, we will run @git_repo.push every 3 commits.
If push is nil, we will never run git push.
test_command:
Command to run your tests after each gem update.
If exit status is non-zero, the gem will not be updated.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/safe_update/updater.rb', line 13 def run(push: nil, test_command: nil) run_git_push = (push && push.to_i > 0) ? true : false push_interval = push.to_i if run_git_push puts 'Finding outdated gems...' outdated_gems = get_outdated_gems presenter = SafeUpdate::Presenter.new Thread.new { presenter.call(outdated_gems) } outdated_gems.to_enum.with_index(1) do |outdated_gem, index| outdated_gem.attempt_update(test_command) @git_repo.push if run_git_push && index % push_interval == 0 end # run it once at the very end, so the final commit can be tested in CI @git_repo.push if run_git_push presenter.stop end |