Class: GemUpdater::GemFile
- Inherits:
-
Object
- Object
- GemUpdater::GemFile
- Defined in:
- lib/gem_updater/gem_file.rb
Overview
GemFile is responsible for handling ‘Gemfile`
Instance Attribute Summary collapse
-
#changes ⇒ Object
Returns the value of attribute changes.
-
#new_spec_set ⇒ Object
readonly
Returns the value of attribute new_spec_set.
-
#old_spec_set ⇒ Object
readonly
Returns the value of attribute old_spec_set.
Instance Method Summary collapse
-
#compute_changes ⇒ Hash
Compute the diffs between two ‘Gemfile.lock`.
-
#initialize ⇒ GemFile
constructor
A new instance of GemFile.
-
#update!(gems) ⇒ Object
Run ‘bundle update` to update gems.
Constructor Details
#initialize ⇒ GemFile
Returns a new instance of GemFile.
10 11 12 |
# File 'lib/gem_updater/gem_file.rb', line 10 def initialize @changes = {} end |
Instance Attribute Details
#changes ⇒ Object
Returns the value of attribute changes.
7 8 9 |
# File 'lib/gem_updater/gem_file.rb', line 7 def changes @changes end |
#new_spec_set ⇒ Object (readonly)
Returns the value of attribute new_spec_set.
8 9 10 |
# File 'lib/gem_updater/gem_file.rb', line 8 def new_spec_set @new_spec_set end |
#old_spec_set ⇒ Object (readonly)
Returns the value of attribute old_spec_set.
8 9 10 |
# File 'lib/gem_updater/gem_file.rb', line 8 def old_spec_set @old_spec_set end |
Instance Method Details
#compute_changes ⇒ Hash
Compute the diffs between two ‘Gemfile.lock`.
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/gem_updater/gem_file.rb', line 23 def compute_changes get_spec_sets old_spec_set.each do |old_gem| updated_gem = new_spec_set.find { |new_gem| new_gem.name == old_gem.name } if updated_gem && old_gem.version != updated_gem.version fill_changes(old_gem, updated_gem) end end end |
#update!(gems) ⇒ Object
Run ‘bundle update` to update gems.
15 16 17 18 |
# File 'lib/gem_updater/gem_file.rb', line 15 def update!(gems) Bundler.ui.warn 'Updating gems...' Bundler::CLI.start(['update'] + gems) end |