Sha256: 387288ed7541d07e6003d2d7f609a92c410738cb998c5eac94c13d0f58071f7b

Contents?: true

Size: 945 Bytes

Versions: 1

Compression:

Stored size: 945 Bytes

Contents

require "open-uri"
require "thor"
require "yajl"

module Codelation
  VERSION = "0.0.27".freeze

  class Cli < Thor
    desc "update", "Update codelation-cli to latest version"
    def update
      command = "gem install codelation-cli"
      puts "Running #{command}..."
      exec(command)
    end

    desc "version", "Show version information"
    def version
      gem_version = "v#{Codelation::VERSION}"

      # Grab the latest version of the RubyGem
      rubygems_json = open("https://rubygems.org/api/v1/gems/codelation-cli.json").read
      rubygems_version = "v#{Yajl::Parser.parse(rubygems_json)['version'].strip}"

      upgrade_message = ""
      if gem_version != rubygems_version
        upgrade_message = " Run `codelation update` to install"
      end

      puts
      puts "Codelation CLI"
      puts "  Installed: #{gem_version}"
      puts "  Latest:    #{rubygems_version}#{upgrade_message}"
      puts
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
codelation-cli-0.0.27 lib/codelation/version.rb