Class: CheckHTTP::Checker

Inherits:
Object
  • Object
show all
Defined in:
lib/check_http/checker.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeChecker

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

#blacklistObject

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) ⇒ Object



13
14
15
# File 'lib/check_http/checker.rb', line 13

def check(url)
  clean(sample(url)).merge(:url => url)
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_blacklistObject



9
10
11
# File 'lib/check_http/checker.rb', line 9

def default_blacklist
  [:response_header, :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