Class: CheckHTTP::Checker
- Inherits:
-
Object
- Object
- CheckHTTP::Checker
- Defined in:
- lib/check_http/checker.rb
Instance Attribute Summary collapse
-
#blacklist ⇒ Object
Returns the value of attribute blacklist.
Instance Method Summary collapse
- #check(url, opts = {}) ⇒ Object
- #clean(result) ⇒ Object
- #default_blacklist ⇒ Object
-
#initialize ⇒ Checker
constructor
A new instance of Checker.
- #sample(url) ⇒ Object
Constructor Details
#initialize ⇒ Checker
Returns a new instance of Checker.
5 6 7 |
# File 'lib/check_http/checker.rb', line 5 def initialize self.blacklist = default_blacklist end |
Instance Attribute Details
#blacklist ⇒ Object
Returns the value of attribute blacklist.
3 4 5 |
# File 'lib/check_http/checker.rb', line 3 def blacklist @blacklist end |
Instance Method Details
#check(url, opts = {}) ⇒ Object
13 14 15 |
# File 'lib/check_http/checker.rb', line 13 def check(url, opts={}) clean(sample(url)).merge(opts) end |
#clean(result) ⇒ Object
17 18 19 |
# File 'lib/check_http/checker.rb', line 17 def clean(result) result.reject { |k,v| blacklist.include?(k) } end |
#default_blacklist ⇒ Object
9 10 11 |
# File 'lib/check_http/checker.rb', line 9 def default_blacklist [:response_headers, :response_body, :httpauth_avail, :starttransfer_time, :appconnect_time, :pretransfer_time] end |
#sample(url) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/check_http/checker.rb', line 21 def sample(url) ethon = Ethon::Easy.new ethon.url = url ethon.prepare ethon.perform ethon.to_hash end |