Sha256: aa6598c1896876cf233c182aa1ba6f863e8502eebb6ac952709db93f6a6d8794

Contents?: true

Size: 993 Bytes

Versions: 3

Compression:

Stored size: 993 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-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

3 entries across 3 versions & 1 rubygems

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