Class: Failbot::Haystack
- Inherits:
-
Object
- Object
- Failbot::Haystack
- Defined in:
- lib/failbot/haystack.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(url) ⇒ Haystack
constructor
A new instance of Haystack.
- #password ⇒ Object
- #ping ⇒ Object
- #send_data(data) ⇒ Object
- #user ⇒ Object
Constructor Details
#initialize(url) ⇒ Haystack
Returns a new instance of Haystack.
7 8 9 |
# File 'lib/failbot/haystack.rb', line 7 def initialize(url) @url = url end |
Class Method Details
Instance Method Details
#password ⇒ Object
15 16 17 |
# File 'lib/failbot/haystack.rb', line 15 def password @url.password end |
#ping ⇒ Object
34 35 36 37 38 |
# File 'lib/failbot/haystack.rb', line 34 def ping request = Net::HTTP::Head.new('/') response = send_request(request) raise StandardError, "haystack returned #{response.code}" unless response.code == "200" end |
#send_data(data) ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/failbot/haystack.rb', line 19 def send_data(data) # make a post post = Net::HTTP::Post.new(@url.path) post.set_form_data('json' => Yajl.dump(data)) response = send_request(post) # Raise if the exception doesn't make it to Haystack, ensures the failure # is logged raise StandardError, "couldn't send exception to Haystack" unless response.code == "201" end |
#user ⇒ Object
11 12 13 |
# File 'lib/failbot/haystack.rb', line 11 def user @url.user || "failbot" end |