Class: Ayadn::CheckBase
Direct Known Subclasses
Instance Attribute Summary collapse
-
#response ⇒ Object
Returns the value of attribute response.
-
#status ⇒ Object
Returns the value of attribute status.
Instance Method Summary collapse
- #check_response_code ⇒ Object
- #get_response(url) ⇒ Object
-
#initialize ⇒ CheckBase
constructor
A new instance of CheckBase.
- #rescue_network(error) ⇒ Object
Constructor Details
Instance Attribute Details
#response ⇒ Object
Returns the value of attribute response.
50 51 52 |
# File 'lib/ayadn/diagnostics.rb', line 50 def response @response end |
#status ⇒ Object
Returns the value of attribute status.
50 51 52 |
# File 'lib/ayadn/diagnostics.rb', line 50 def status @status end |
Instance Method Details
#check_response_code ⇒ Object
60 61 62 63 64 65 66 67 |
# 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) ⇒ Object
56 57 58 |
# File 'lib/ayadn/diagnostics.rb', line 56 def get_response(url) @response = RestClient.get(url) {|response, request, result| response} end |
#rescue_network(error) ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# 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 |