Class: GemUpdater::Updater

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initializeUpdater

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

#gemfileObject

Returns the value of attribute gemfile.



15
16
17
# File 'lib/gem_updater.rb', line 15

def gemfile
  @gemfile
end

Instance Method Details

#format_diffObject

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_diffObject

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

Parameters:

  • gems (Array)

    list of gems to update



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