class Ayadn::CheckAyadn

Attributes

response[RW]

Public Instance Methods

check() click to toggle source
# File lib/ayadn/diagnostics.rb, line 416
def check
  begin
    @status.say_header "checking RubyGems server response"
    get_response "https://rubygems.org/api/v1/gems/ayadn.json"
    check_response_code
    @status.say_header "checking Ayadn version"
    info = JSON.parse(@response.body)
    live = info["version"]
    @status.say_green(:live, "version #{live}")
    if live != VERSION
      @status.say_red(:local, "version #{VERSION}")
      @status.say { @status.say_yellow :update, "run 'gem update ayadn' to get the last version" }
    else
      @status.say_green(:local, "version #{VERSION}")
    end
  rescue JSON::ParserError => e
    @status.say_error "JSON error"
    @status.say_trace e
  rescue Interrupt
    @status.say_error "operation canceled"
    exit
  rescue => e
    rescue_network(e)
  end
end