Class: Ayadn::CheckAyadn

Inherits:
CheckBase show all
Defined in:
lib/ayadn/diagnostics.rb

Instance Attribute Summary collapse

Attributes inherited from CheckBase

#baseURL, #status

Instance Method Summary collapse

Methods inherited from CheckBase

#check_response_code, #get_response, #initialize, #rescue_network

Constructor Details

This class inherits a constructor from Ayadn::CheckBase

Instance Attribute Details

#responseObject

Returns the value of attribute response.



414
415
416
# File 'lib/ayadn/diagnostics.rb', line 414

def response
  @response
end

Instance Method Details

#checkObject



416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
# 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