Class: Concuss::Runner
- Inherits:
-
Object
- Object
- Concuss::Runner
- Defined in:
- lib/concuss/runner.rb
Instance Attribute Summary collapse
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#test_string ⇒ Object
readonly
Returns the value of attribute test_string.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
-
#initialize(headers:, url:, test_string: nil) ⇒ Runner
constructor
A new instance of Runner.
- #run ⇒ Object
Constructor Details
#initialize(headers:, url:, test_string: nil) ⇒ Runner
Returns a new instance of Runner.
7 8 9 10 11 |
# File 'lib/concuss/runner.rb', line 7 def initialize(headers:, url:, test_string: nil) @headers = headers @url = url @test_string = test_string || SecureRandom.hex(25) end |
Instance Attribute Details
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
5 6 7 |
# File 'lib/concuss/runner.rb', line 5 def headers @headers end |
#test_string ⇒ Object (readonly)
Returns the value of attribute test_string.
5 6 7 |
# File 'lib/concuss/runner.rb', line 5 def test_string @test_string end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
5 6 7 |
# File 'lib/concuss/runner.rb', line 5 def url @url end |
Instance Method Details
#run ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/concuss/runner.rb', line 13 def run uri = URI(@url) @headers.each do |header| response = Net::HTTP.get_response(uri, { header => test_string } ) if response.code == "200" && response.body.include?(@test_string) result = "HIT" else result = "MISS" end puts "#{header} - #{response.code} - #{result}" end end |