class Ayadn::CheckBase
Attributes
baseURL[RW]
response[RW]
status[RW]
Public Class Methods
new()
click to toggle source
# File lib/ayadn/diagnostics.rb, line 52 def initialize @status = Status.new end
Public Instance Methods
check_response_code()
click to toggle source
# File lib/ayadn/diagnostics.rb, line 60 def check_response_code code = @response.code if code == 200 @status.say_green :status, "OK" else @status.say_red :status, "#{code}" end end
get_response(url)
click to toggle source
# File lib/ayadn/diagnostics.rb, line 56 def get_response(url) @response = RestClient.get(url) {|response, request, result| response} end
rescue_network(error)
click to toggle source
# File lib/ayadn/diagnostics.rb, line 69 def rescue_network(error) begin raise error rescue RestClient::RequestTimeout => e @status.say_error "connection timeout" @status.say_trace e rescue SocketError, SystemCallError, OpenSSL::SSL::SSLError => e @status.say_error "connection problem" @status.say_trace e rescue Interrupt @status.say_error "operation canceled" exit rescue => e @status.say_error "unknown error" @status.say_trace e end end