Class: Toadhopper
- Inherits:
-
Object
- Object
- Toadhopper
- Defined in:
- lib/toadhopper.rb
Overview
Posts errors to the Airbrake API
Defined Under Namespace
Classes: BacktraceLine, Response
Constant Summary collapse
- VERSION =
"2.0"- FILTER_REPLACEMENT =
"[FILTERED]"
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
Instance Method Summary collapse
-
#deploy!(options = {}) ⇒ Response
Posts a deployment notification.
-
#filters=(*filters) ⇒ Object
Sets patterns to
[FILTER]out sensitive data such as/password/,/email/and/credit_card_number/. -
#initialize(api_key, params = {}) ⇒ Toadhopper
constructor
A new instance of Toadhopper.
-
#post!(error, options = {}, http_headers = {}) ⇒ Response
Posts an exception to Airbrake.
Constructor Details
#initialize(api_key, params = {}) ⇒ Toadhopper
Returns a new instance of Toadhopper.
15 16 17 18 19 20 |
# File 'lib/toadhopper.rb', line 15 def initialize(api_key, params = {}) @api_key = api_key @notify_host = params.delete(:notify_host) || "http://airbrakeapp.com" @error_url = params.delete(:error_url) || "#{@notify_host}/notifier_api/v2/notices" @deploy_url = params.delete(:deploy_url) || "#{@notify_host}/deploys.txt" end |
Instance Attribute Details
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
13 14 15 |
# File 'lib/toadhopper.rb', line 13 def api_key @api_key end |
Instance Method Details
#deploy!(options = {}) ⇒ Response
Posts a deployment notification
67 68 69 70 71 72 73 74 75 76 |
# File 'lib/toadhopper.rb', line 67 def deploy!(={}) params = {} params['api_key'] = @api_key params['deploy[rails_env]'] = [:framework_env] || 'development' params['deploy[local_username]'] = [:username] || %x(whoami).strip params['deploy[scm_repository]'] = [:scm_repository] params['deploy[scm_revision]'] = [:scm_revision] response = Net::HTTP.post_form(URI.parse(@deploy_url), params) parse_response(response) end |
#filters=(*filters) ⇒ Object
Sets patterns to [FILTER] out sensitive data such as /password/, /email/ and /credit_card_number/
23 24 25 |
# File 'lib/toadhopper.rb', line 23 def filters=(*filters) @filters = filters.flatten end |
#post!(error, options = {}, http_headers = {}) ⇒ Response
Posts an exception to Airbrake.
53 54 55 56 |
# File 'lib/toadhopper.rb', line 53 def post!(error, ={}, http_headers={}) [:notifier_name] ||= 'Toadhopper' post_document(document_for(error, ), {'X-Airbrake-Client-Name' => [:notifier_name]}) end |