Class: DRG::Tasks::Updater

Inherits:
Object
  • Object
show all
Includes:
Log
Defined in:
lib/drg/tasks/updater.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Log

log

Constructor Details

#initializeUpdater



8
9
10
# File 'lib/drg/tasks/updater.rb', line 8

def initialize
  @gemfile = Gemfile.new
end

Instance Attribute Details

#gemfileObject (readonly)

Returns the value of attribute gemfile.



6
7
8
# File 'lib/drg/tasks/updater.rb', line 6

def gemfile
  @gemfile
end

Instance Method Details

#performObject

Note:

‘bundle outdated` returns lines that look like ’slop (newest 4.2.0, installed 3.6.0) in group “default”‘

Loads the current version of outdated gems



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/drg/tasks/updater.rb', line 16

def perform
  log 'Searching for outdated gems ....'
  outdated = `bundle outdated`.scan(/\s\*\s(.+)\s/).flatten
  gems = outdated.map { |item|
    name = item[/([\-\w0-9]+)\s/, 1]
    name if gemfile.find_by_name(name)
  }.compact
  if gems.any?
    yield gems
  else
    log 'All gems up to date!'
  end
end