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.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeUpdater

Returns a new instance of Updater.



12
13
14
# File 'lib/gem_updater.rb', line 12

def initialize
  @gemfile = GemUpdater::GemFile.new
end

Instance Attribute Details

#gemfileObject

Returns the value of attribute gemfile.



10
11
12
# File 'lib/gem_updater.rb', line 10

def gemfile
  @gemfile
end

Instance Method Details

#format_diffObject

Format the diff to get human readable information on the gems that were updated.



36
37
38
39
40
# File 'lib/gem_updater.rb', line 36

def format_diff
  gemfile.changes.map do |gem, details|
    ERB.new(template, nil, '<>').result(binding)
  end
end

#output_diffObject

Print formatted diff



30
31
32
# File 'lib/gem_updater.rb', line 30

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



22
23
24
25
26
27
# File 'lib/gem_updater.rb', line 22

def update!(gems)
  gemfile.update!(gems)
  gemfile.compute_changes

  fill_changelogs
end