Class: IPVSLitmus::Dependency::HTTP
- Inherits:
-
Object
- Object
- IPVSLitmus::Dependency::HTTP
- Defined in:
- lib/ipvs_litmus/dependency/http.rb
Instance Method Summary collapse
- #_body_matches?(response) ⇒ Boolean
- #_successful_response?(response) ⇒ Boolean
- #available? ⇒ Boolean
-
#initialize(uri, options = {}) ⇒ HTTP
constructor
A new instance of HTTP.
Constructor Details
#initialize(uri, options = {}) ⇒ HTTP
Returns a new instance of HTTP.
4 5 6 7 |
# File 'lib/ipvs_litmus/dependency/http.rb', line 4 def initialize(uri, = {}) @uri = uri @expected_content = Regexp.new(.fetch(:contnet, '.*')) end |
Instance Method Details
#_body_matches?(response) ⇒ Boolean
22 23 24 |
# File 'lib/ipvs_litmus/dependency/http.rb', line 22 def _body_matches?(response) response.body =~ @expected_content end |
#_successful_response?(response) ⇒ Boolean
18 19 20 |
# File 'lib/ipvs_litmus/dependency/http.rb', line 18 def _successful_response?(response) response.is_a? Net::HTTPSuccess end |
#available? ⇒ Boolean
9 10 11 12 13 14 15 16 |
# File 'lib/ipvs_litmus/dependency/http.rb', line 9 def available? begin response = Net::HTTP.get_response(URI.parse(@uri)) _successful_response?(response) && _body_matches?(response) rescue Exception => e false end end |