Class: Grundler::Commands::Update

Inherits:
Object
  • Object
show all
Includes:
Common
Defined in:
lib/grundler/commands/update.rb

Instance Method Summary collapse

Methods included from Common

#install, #latest_version, #module?, #no_such_package

Constructor Details

#initialize(cli, _arguments, json_writer) ⇒ Update

Returns a new instance of Update.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/grundler/commands/update.rb', line 8

def initialize(cli, _arguments, json_writer)
  super(cli)
  unless File.exist?(Grundler::LOCKFILE_PATH)
    puts "No #{Grundler::LOCKFILE_PATH} file found!"
    return
  end

  json_writer.add(
    json_writer.existing_packages
      .map { |k, v| update(k, latest_version(k), v) }
      .compact
      .to_h
  )
end