Class: GemUpdater::Gemfile
- Inherits:
-
Object
- Object
- GemUpdater::Gemfile
- Defined in:
- lib/gem_updater/gemfile.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.
12 13 14 |
# File 'lib/gem_updater/gemfile.rb', line 12 def initialize @changes = {} end |
Instance Attribute Details
#changes ⇒ Object
Returns the value of attribute changes.
9 10 11 |
# File 'lib/gem_updater/gemfile.rb', line 9 def changes @changes end |
#new_spec_set ⇒ Object (readonly)
Returns the value of attribute new_spec_set.
10 11 12 |
# File 'lib/gem_updater/gemfile.rb', line 10 def new_spec_set @new_spec_set end |
#old_spec_set ⇒ Object (readonly)
Returns the value of attribute old_spec_set.
10 11 12 |
# File 'lib/gem_updater/gemfile.rb', line 10 def old_spec_set @old_spec_set end |
Instance Method Details
#compute_changes ⇒ Hash
Compute the diffs between two ‘Gemfile.lock`.
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/gem_updater/gemfile.rb', line 25 def compute_changes spec_sets_diff! old_spec_set.each do |old_gem| updated_gem = new_spec_set.find { |new_gem| new_gem.name == old_gem.name } next unless updated_gem && old_gem.version != updated_gem.version fill_changes(old_gem, updated_gem) end end |
#update!(gems) ⇒ Object
Run ‘bundle update` to update gems.
17 18 19 20 |
# File 'lib/gem_updater/gemfile.rb', line 17 def update!(gems) Bundler.ui.warn 'Updating gems...' Bundler::CLI.start(['update'] + gems) end |