Sha256: 1d7b8f295c588944e53242044ac4312643074a49445c5de7af44e0307d6df546

Contents?: true

Size: 997 Bytes

Versions: 4

Compression:

Stored size: 997 Bytes

Contents

# frozen_string_literal: true

require 'colorize'
require 'nsrr/helpers/json_request'

module Nsrr
  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) = Nsrr::Helpers::JsonRequest.get('https://rubygems.org/api/v1/gems/nsrr.json')
        if json
          if json['version'] == Nsrr::VERSION::STRING
            puts 'The nsrr 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 nsrr --no-ri --no-rdoc'.colorize(:white)
            puts
          end
        else
          puts 'Unable to connect to RubyGems.org. Please try again later.'
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
nsrr-0.3.0 lib/nsrr/commands/update.rb
nsrr-0.3.0.rc lib/nsrr/commands/update.rb
nsrr-0.3.0.beta2 lib/nsrr/commands/update.rb
nsrr-0.3.0.beta1 lib/nsrr/commands/update.rb