Class: GemUpdater::Updater
- Inherits:
-
Object
- Object
- GemUpdater::Updater
- Defined in:
- lib/gem_updater.rb
Overview
Updater’s main responsability is to fill changes happened before and after update of ‘Gemfile`, and then format them.
Constant Summary collapse
- RUBYGEMS_SOURCE_NAME =
'rubygems repository https://rubygems.org/'
Instance Attribute Summary collapse
-
#gemfile ⇒ Object
Returns the value of attribute gemfile.
Instance Method Summary collapse
-
#format_diff ⇒ Object
Format the diff to get human readable information on the gems that were updated.
-
#initialize ⇒ Updater
constructor
A new instance of Updater.
-
#output_diff ⇒ Object
Print formatted diff.
-
#update!(gems) ⇒ Object
Update process.
Constructor Details
#initialize ⇒ Updater
Returns a new instance of Updater.
17 18 19 |
# File 'lib/gem_updater.rb', line 17 def initialize @gemfile = GemUpdater::Gemfile.new end |
Instance Attribute Details
#gemfile ⇒ Object
Returns the value of attribute gemfile.
15 16 17 |
# File 'lib/gem_updater.rb', line 15 def gemfile @gemfile end |
Instance Method Details
#format_diff ⇒ Object
Format the diff to get human readable information on the gems that were updated.
41 42 43 44 45 46 47 |
# File 'lib/gem_updater.rb', line 41 def format_diff erb = ERB.new(template.force_encoding('UTF-8'), trim_mode: '<>') gemfile.changes.map do |gem, details| erb.result(binding) end end |
#output_diff ⇒ Object
Print formatted diff
35 36 37 |
# File 'lib/gem_updater.rb', line 35 def output_diff Bundler.ui.info format_diff.join end |
#update!(gems) ⇒ Object
Update process. This will:
1. update gemfile
2. find changelogs for updated gems
27 28 29 30 31 32 |
# File 'lib/gem_updater.rb', line 27 def update!(gems) gemfile.update!(gems) gemfile.compute_changes fill_changelogs end |