Sha256: 29002f718e4709866de431fe47190ff205ef5478824046385b9b02442cf8e5cc

Contents?: true

Size: 1000 Bytes

Versions: 1

Compression:

Stored size: 1000 Bytes

Contents

# frozen_string_literal: true

require 'colorize'
require 'spout/helpers/json_request'

module Spout
  module Commands
    # Command to check if there is an updated version of the gem available.
    class Update
      class << self
        def start(*args)
          new(*args).start
        end
      end

      def initialize(argv)
      end

      def start
        (json, _status) = Spout::Helpers::JsonRequest.get('https://rubygems.org/api/v1/gems/spout.json')
        if json
          if json['version'] == Spout::VERSION::STRING
            puts 'The spout gem is ' + 'up-to-date'.colorize(:green) + '!'
          else
            puts
            puts "A newer version (v#{json['version']}) is available! Type the following command to update:"
            puts
            puts '  gem install spout --no-document'.colorize(:white)
            puts
          end
        else
          puts 'Unable to connect to RubyGems.org. Please try again later.'
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
spout-0.12.0.rc lib/spout/commands/update.rb