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.
-
#repository ⇒ Object
readonly
Returns the value of attribute repository.
-
#version_control ⇒ Object
readonly
Returns the value of attribute version_control.
Instance Method Summary collapse
-
#initialize(bundle:, repository:, version_control:, filter: NullFilter.new) ⇒ Updater
constructor
A new instance of Updater.
- #possible_updates ⇒ Object
- #run ⇒ Object
Constructor Details
#initialize(bundle:, repository:, version_control:, filter: NullFilter.new) ⇒ Updater
Returns a new instance of Updater.
8 9 10 11 12 13 |
# File 'lib/keep_up/updater.rb', line 8 def initialize(bundle:, repository:, version_control:, filter: NullFilter.new) @bundle = bundle @repository = repository @version_control = version_control @filter = filter end |
Instance Attribute Details
#bundle ⇒ Object (readonly)
Returns the value of attribute bundle.
6 7 8 |
# File 'lib/keep_up/updater.rb', line 6 def bundle @bundle end |
#filter ⇒ Object (readonly)
Returns the value of attribute filter.
6 7 8 |
# File 'lib/keep_up/updater.rb', line 6 def filter @filter end |
#repository ⇒ Object (readonly)
Returns the value of attribute repository.
6 7 8 |
# File 'lib/keep_up/updater.rb', line 6 def repository @repository end |
#version_control ⇒ Object (readonly)
Returns the value of attribute version_control.
6 7 8 |
# File 'lib/keep_up/updater.rb', line 6 def version_control @version_control end |
Instance Method Details
#possible_updates ⇒ Object
26 27 28 29 30 |
# File 'lib/keep_up/updater.rb', line 26 def possible_updates bundle.direct_dependencies. select { |dep| filter.call dep }. map { |dep| repository.updated_dependency_for dep }.compact.uniq end |
#run ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/keep_up/updater.rb', line 15 def run possible_updates.each do |update| result = bundle.apply_updated_dependency update if result version_control.commit_changes result else version_control.revert_changes end end end |