Class: Ayadn::CheckAyadn

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

Instance Attribute Summary collapse

Attributes inherited from CheckBase

#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.



441
442
443
# File 'lib/ayadn/diagnostics.rb', line 441

def response
  @response
end

Instance Method Details

#checkObject



443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
# File 'lib/ayadn/diagnostics.rb', line 443

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