Sha256: 1db308b325a1282c0e8f0435694dc8087bddea1ed204dffcf8a7c7a884b06e2a
Contents?: true
Size: 964 Bytes
Versions: 1
Compression:
Stored size: 964 Bytes
Contents
require "grundler/good_mode" require "grundler/crap_mode" module Grundler module Commands module Common def initialize(cli) @cli = cli end def module?(version) !version["module"].nil? || version["type"] == "module" end def latest_version(package_name) package_metadata = JSON.parse(HTTP.get("https://registry.npmjs.org/#{package_name}").to_s) latest_version_number = package_metadata.dig("dist-tags", "latest") package_metadata["error"] || package_metadata.dig("versions", latest_version_number) end def install(version) return no_such_package if version == "Not found" if module?(version) GoodMode.new(@cli, version).write else CrapMode.new(@cli, version).write end version end def no_such_package puts "That package could not be found in the npm repository!" end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
grundler-0.1.0 | lib/grundler/commands/common.rb |