Class: ExceptionNotifier::Rake
- Inherits:
-
Object
- Object
- ExceptionNotifier::Rake
- Defined in:
- lib/exception_notifier/rake/rake.rb,
lib/exception_notifier/rake/version.rb
Constant Summary collapse
- VERSION =
'0.1.3'
Class Method Summary collapse
-
.configure(options = {}) ⇒ Object
Configure Rake exception notifications.
-
.configured? ⇒ Boolean
Whether Rake exception notifications have been configured.
- .default_notifier_options ⇒ Object
-
.maybe_deliver_notification(exception, data = {}) ⇒ Object
Deliver a notification about the given exception by email, in case notifications have been configured.
- .notifier_options ⇒ Object
- .reset_for_test ⇒ Object
Class Method Details
.configure(options = {}) ⇒ Object
Configure Rake exception notifications. Should be called in a config file, usually in config/environments/production.rb for production use. An optional hash of options can be given, which will be passed through unchanged to the underlying notifiers.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/exception_notifier/rake/rake.rb', line 18 def self.configure( = {}) @notifier_options.merge!() @notifier_options.merge!() # There is only a single static list registered ignore_ifs. We make # ignore_ifs passed to just this configuration only effective for exceptions # actually raised through Rake, identified by the :rake? variable in the # environment. if [:ignore_if] ExceptionNotifier.ignore_if do |exception, | [:env][:rake?] && [:ignore_if].call([:env], exception) end end # Append view path for this gem, assuming that the client is using # ActionMailer::Base. This isn't ideal but there doesn't seem to be # a different way to extend the path. require 'action_mailer' ActionMailer::Base.append_view_path "#{File.dirname(__FILE__)}/views" end |
.configured? ⇒ Boolean
Whether Rake exception notifications have been configured.
10 11 12 |
# File 'lib/exception_notifier/rake/rake.rb', line 10 def self.configured? !@notifier_options.empty? end |
.default_notifier_options ⇒ Object
39 40 41 42 43 44 |
# File 'lib/exception_notifier/rake/rake.rb', line 39 def self. { :background_sections => %w(rake backtrace), :env => {:rake? => true}, } end |
.maybe_deliver_notification(exception, data = {}) ⇒ Object
Deliver a notification about the given exception by email, in case notifications have been configured. The additional data hash will be passed through to ExceptionNotifier’s data hash and will be availble in templates.
54 55 56 57 58 59 60 61 62 63 |
# File 'lib/exception_notifier/rake/rake.rb', line 54 def self.maybe_deliver_notification(exception, data={}) if configured? = if !data.empty? = .dup [:data] = data.merge([:data] || {}) end ExceptionNotifier.notify_exception(exception, ) end end |
.notifier_options ⇒ Object
46 47 48 |
# File 'lib/exception_notifier/rake/rake.rb', line 46 def self. @notifier_options end |
.reset_for_test ⇒ Object
65 66 67 68 |
# File 'lib/exception_notifier/rake/rake.rb', line 65 def self.reset_for_test @notifier_options = {} ExceptionNotifier.clear_ignore_conditions! end |