Class: KeepUp::Updater
- Inherits:
-
Object
- Object
- KeepUp::Updater
- Defined in:
- lib/keep_up/updater.rb
Overview
Apply potential updates to a Gemfile.
Instance Attribute Summary collapse
-
#bundle ⇒ Object
readonly
Returns the value of attribute bundle.
-
#filter ⇒ Object
readonly
Returns the value of attribute filter.
-
#version_control ⇒ Object
readonly
Returns the value of attribute version_control.
Instance Method Summary collapse
-
#initialize(bundle:, version_control:, filter: NullFilter.new, out: $stdout) ⇒ Updater
constructor
A new instance of Updater.
- #possible_updates ⇒ Object
- #run ⇒ Object
Constructor Details
#initialize(bundle:, version_control:, filter: NullFilter.new, out: $stdout) ⇒ Updater
Returns a new instance of Updater.
10 11 12 13 14 15 |
# File 'lib/keep_up/updater.rb', line 10 def initialize(bundle:, version_control:, filter: NullFilter.new, out: $stdout) @bundle = bundle @version_control = version_control @filter = filter @out = out end |
Instance Attribute Details
#bundle ⇒ Object (readonly)
Returns the value of attribute bundle.
8 9 10 |
# File 'lib/keep_up/updater.rb', line 8 def bundle @bundle end |
#filter ⇒ Object (readonly)
Returns the value of attribute filter.
8 9 10 |
# File 'lib/keep_up/updater.rb', line 8 def filter @filter end |
#version_control ⇒ Object (readonly)
Returns the value of attribute version_control.
8 9 10 |
# File 'lib/keep_up/updater.rb', line 8 def version_control @version_control end |
Instance Method Details
#possible_updates ⇒ Object
28 29 30 31 32 |
# File 'lib/keep_up/updater.rb', line 28 def possible_updates bundle.dependencies .select { |dep| filter.call dep } .select { |dep| updateable_dependency? dep }.uniq end |
#run ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/keep_up/updater.rb', line 17 def run possible_updates.each do |update| result = apply_updated_dependency update if result version_control.commit_changes result else version_control.revert_changes end end end |