Class: IsItWorkingInfo::Checkin
- Inherits:
-
Object
- Object
- IsItWorkingInfo::Checkin
- Defined in:
- lib/is_it_working_info.rb
Overview
This class provides a wrapper for checking in with IsItWorking.info
Instance Attribute Summary collapse
-
#params ⇒ Object
Returns the value of attribute params.
-
#response ⇒ Object
Returns the value of attribute response.
-
#result ⇒ Object
Returns the value of attribute result.
-
#uri ⇒ Object
Returns the value of attribute uri.
Class Method Summary collapse
-
.ping(key: nil, message: nil, status: nil, time: nil, boundary: nil) ⇒ Object
checkin with IsItWorking.
-
.time(key: nil, message: nil, status: nil, boundary: nil, &block) ⇒ Object
times the block, in milliseconds and sends the result to IsItWorking.
Instance Attribute Details
#params ⇒ Object
Returns the value of attribute params.
10 11 12 |
# File 'lib/is_it_working_info.rb', line 10 def params @params end |
#response ⇒ Object
Returns the value of attribute response.
11 12 13 |
# File 'lib/is_it_working_info.rb', line 11 def response @response end |
#result ⇒ Object
Returns the value of attribute result.
12 13 14 |
# File 'lib/is_it_working_info.rb', line 12 def result @result end |
#uri ⇒ Object
Returns the value of attribute uri.
9 10 11 |
# File 'lib/is_it_working_info.rb', line 9 def uri @uri end |
Class Method Details
.ping(key: nil, message: nil, status: nil, time: nil, boundary: nil) ⇒ Object
checkin with IsItWorking
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/is_it_working_info.rb', line 16 def self.ping(key:nil,message:nil,status:nil,time:nil, boundary:nil) if key.nil? raise 'You must specify a key' end checkin=Checkin.new checkin.uri = URI("https://api.isitworking.info/c/#{key}") if checkin.nil? raise 'Unable to generate uri - please check your key' end checkin.params = { t: time, b: boundary, m: , s: status } if IsItWorkingInfo.configuration.testing puts "IsItWorking testing. Would call: #{checkin.uri.to_s}" else checkin.result = Net::HTTP.post_form(checkin.uri,checkin.params) end checkin end |
.time(key: nil, message: nil, status: nil, boundary: nil, &block) ⇒ Object
times the block, in milliseconds and sends the result to IsItWorking
45 46 47 48 49 50 51 52 |
# File 'lib/is_it_working_info.rb', line 45 def self.time(key:nil,message:nil,status:nil,boundary:nil, &block) time = Benchmark.realtime do block.call end milliseconds = time * 1000 self.ping(key: key, message: , status: status, time: milliseconds, boundary: boundary) end |