Class: SafeUpdate::OutdatedGem

Inherits:
Object
  • Object
show all
Defined in:
lib/safe_update/outdated_gem.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(line) ⇒ OutdatedGem

line is a line from bundle outdated –parseable eg. react-rails (newest 1.6.0, installed 1.5.0, requested ~> 1.0) or. react-rails (newest 1.6.0, installed 1.5.0)



8
9
10
11
12
13
# File 'lib/safe_update/outdated_gem.rb', line 8

def initialize(line)
  @line = line
  if name.to_s.empty?
    fail "Unexpected output from `bundle outdated --parseable`: #{@line}"
  end
end

Instance Attribute Details

#installedObject (readonly)

Returns the value of attribute installed.



3
4
5
# File 'lib/safe_update/outdated_gem.rb', line 3

def installed
  @installed
end

#newestObject (readonly)

Returns the value of attribute newest.



3
4
5
# File 'lib/safe_update/outdated_gem.rb', line 3

def newest
  @newest
end

#requestedObject (readonly)

Returns the value of attribute requested.



3
4
5
# File 'lib/safe_update/outdated_gem.rb', line 3

def requested
  @requested
end

Instance Method Details

#nameObject



27
28
29
# File 'lib/safe_update/outdated_gem.rb', line 27

def name
  string_between(@line, '', ' (newest')
end

#updateObject



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/safe_update/outdated_gem.rb', line 15

def update
  puts '-------------'
  puts "OUTDATED GEM: #{name}"
  puts "   Newest: #{newest}. "
  puts "Installed: #{installed}."
  puts "Running `bundle update #{name}`..."
  `bundle update #{name}`
  puts "committing changes (message: '#{commit_message}')..."
  `git add Gemfile.lock`
  `git commit -m '#{commit_message}'`
end