Class: Nsrr::Commands::Update

Inherits:
Object
  • Object
show all
Defined in:
lib/nsrr/commands/update.rb

Overview

Command to check if there is an updated version of the gem available.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ Update

Returns a new instance of Update.



16
17
# File 'lib/nsrr/commands/update.rb', line 16

def initialize(argv)
end

Class Method Details

.start(*args) ⇒ Object



11
12
13
# File 'lib/nsrr/commands/update.rb', line 11

def start(*args)
  new(*args).start
end

Instance Method Details

#startObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/nsrr/commands/update.rb', line 19

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".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".white
      puts
    end
  else
    puts "Unable to connect to RubyGems.org. Please try again later."
  end
end