Class: Rack::Hoptoad
- Inherits:
-
Object
- Object
- Rack::Hoptoad
- Defined in:
- lib/rack/hoptoad.rb
Overview
Catches all exceptions raised from the app it wraps and posts the results to hoptoad.
Defined Under Namespace
Classes: Error
Constant Summary collapse
- VERSION =
'0.1.5'
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#environment_filters ⇒ Object
Returns the value of attribute environment_filters.
-
#failsafe ⇒ Object
Returns the value of attribute failsafe.
-
#notifier_class ⇒ Object
Returns the value of attribute notifier_class.
-
#rack_environment ⇒ Object
Returns the value of attribute rack_environment.
-
#report_under ⇒ Object
Returns the value of attribute report_under.
Instance Method Summary collapse
- #call(env) ⇒ Object
- #environment_filter_keys ⇒ Object
- #environment_filter_regexps ⇒ Object
-
#initialize(app, api_key = nil, rack_environment = 'RACK_ENV') {|_self| ... } ⇒ Hoptoad
constructor
A new instance of Hoptoad.
Constructor Details
#initialize(app, api_key = nil, rack_environment = 'RACK_ENV') {|_self| ... } ⇒ Hoptoad
Returns a new instance of Hoptoad.
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/rack/hoptoad.rb', line 15 def initialize(app, api_key = nil, rack_environment = 'RACK_ENV') @app = app @api_key = api_key @report_under = %w(staging production) @rack_environment = rack_environment @environment_filters = %w(AWS_ACCESS_KEY AWS_SECRET_ACCESS_KEY AWS_ACCOUNT SSH_AUTH_SOCK) @notifier_class = Toadhopper @failsafe = $stderr yield self if block_given? end |
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key.
13 14 15 |
# File 'lib/rack/hoptoad.rb', line 13 def api_key @api_key end |
#environment_filters ⇒ Object
Returns the value of attribute environment_filters.
13 14 15 |
# File 'lib/rack/hoptoad.rb', line 13 def environment_filters @environment_filters end |
#failsafe ⇒ Object
Returns the value of attribute failsafe.
13 14 15 |
# File 'lib/rack/hoptoad.rb', line 13 def failsafe @failsafe end |
#notifier_class ⇒ Object
Returns the value of attribute notifier_class.
13 14 15 |
# File 'lib/rack/hoptoad.rb', line 13 def notifier_class @notifier_class end |
#rack_environment ⇒ Object
Returns the value of attribute rack_environment.
13 14 15 |
# File 'lib/rack/hoptoad.rb', line 13 def rack_environment @rack_environment end |
#report_under ⇒ Object
Returns the value of attribute report_under.
13 14 15 |
# File 'lib/rack/hoptoad.rb', line 13 def report_under @report_under end |
Instance Method Details
#call(env) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/rack/hoptoad.rb', line 26 def call(env) status, headers, body = begin @app.call(env) rescue StandardError, LoadError, SyntaxError => boom notified = send_notification boom, env env['hoptoad.notified'] = notified raise end send_notification env['rack.exception'], env if env['rack.exception'] [status, headers, body] end |
#environment_filter_keys ⇒ Object
39 40 41 |
# File 'lib/rack/hoptoad.rb', line 39 def environment_filter_keys @environment_filters.flatten end |
#environment_filter_regexps ⇒ Object
43 44 45 46 47 |
# File 'lib/rack/hoptoad.rb', line 43 def environment_filter_regexps environment_filter_keys.map do |key| "^#{Regexp.escape(wrapped_key_for(key))}$" end end |