Sha256: 6bfebe72673689718751c4e21fe66fe0c9c1ebc5282e2f03d3d1ecdd1ce2d8cd

Contents?: true

Size: 847 Bytes

Versions: 1

Compression:

Stored size: 847 Bytes

Contents

require_relative "common"

module Grundler
  module Commands
    class Update
      include Common

      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

      private

      def update(name, latest_version, current_version_number)
        if latest_version["version"] == current_version_number
          puts "#{latest_version["name"]} is already the latest version (#{current_version_number})"
          return
        end

        [name, install(latest_version)["version"]]
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
grundler-0.1.0 lib/grundler/commands/update.rb