exception_notification-rake 0.0.5 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +3 -1
- data/lib/exception_notifier/rake/rake.rb +19 -0
- data/lib/exception_notifier/rake/version.rb +1 -1
- data/test/rake_test.rb +18 -0
- metadata +2 -2
data/README.md
CHANGED
@@ -105,7 +105,9 @@ The most likely options you'll want to use are `:email_prefix` and `:exception_r
|
|
105
105
|
:email_prefix => "[Rake Failure] ",
|
106
106
|
:exception_recipients => %w{user1@example.com user2@example.com})
|
107
107
|
|
108
|
-
This will prefix the email subjects of Rake failure notifications with `[
|
108
|
+
This will prefix the email subjects of Rake failure notifications with `[Rake Failure]` and will send them to the two given email addresses. Note that if you set the same options when you configure `ExceptionNotifier` itself, they will be overridden but for Rake failures only.
|
109
|
+
|
110
|
+
`:ignore_if` and `:ignore_exceptions` are also supported. Note that the first argument to the block expected by `:ignore_if` (the environment) will always be an empty dictionary since there is no meaningful environment for background tasks.
|
109
111
|
|
110
112
|
If you want to configure sections, which is unlikely, note that by default the sections `['rake', 'backtrace']` are used (where `rake` is a custom section introduced by this gem).
|
111
113
|
|
@@ -40,6 +40,11 @@ class ExceptionNotifier
|
|
40
40
|
def self.maybe_deliver_notification(exception, data={})
|
41
41
|
if configured?
|
42
42
|
options = notifier_options
|
43
|
+
if conditionally_ignored(options[:ignore_if], exception) ||
|
44
|
+
ignored_exception(options[:ignore_exceptions], exception)
|
45
|
+
return
|
46
|
+
end
|
47
|
+
|
43
48
|
if !data.empty?
|
44
49
|
options = options.dup
|
45
50
|
options[:data] = data.merge(options[:data] || {})
|
@@ -52,5 +57,19 @@ class ExceptionNotifier
|
|
52
57
|
def self.reset_for_test
|
53
58
|
@notifier_options = {}
|
54
59
|
end
|
60
|
+
|
61
|
+
private
|
62
|
+
|
63
|
+
# Duplicated from exception_notification
|
64
|
+
def self.conditionally_ignored(ignore_proc, exception)
|
65
|
+
ignore_proc.call({}, exception)
|
66
|
+
rescue Exception
|
67
|
+
false
|
68
|
+
end
|
69
|
+
|
70
|
+
# Duplicated from exception_notification
|
71
|
+
def self.ignored_exception(ignore_array, exception)
|
72
|
+
Array.wrap(ignore_array).map(&:to_s).include?(exception.class.name)
|
73
|
+
end
|
55
74
|
end
|
56
75
|
end
|
data/test/rake_test.rb
CHANGED
@@ -5,6 +5,9 @@ require 'exception_notifier/rake'
|
|
5
5
|
|
6
6
|
class RakeTest < Test::Unit::TestCase
|
7
7
|
|
8
|
+
class IgnoredException < Exception
|
9
|
+
end
|
10
|
+
|
8
11
|
def setup
|
9
12
|
ExceptionNotifier::Rake.reset_for_test
|
10
13
|
assert !ExceptionNotifier::Rake.configured?
|
@@ -56,4 +59,19 @@ class RakeTest < Test::Unit::TestCase
|
|
56
59
|
ExceptionNotifier::Rake.maybe_deliver_notification(ex, data)
|
57
60
|
assert_equal(original_options, options)
|
58
61
|
end
|
62
|
+
|
63
|
+
def test_maybe_deliver_notifications_with_ignore_if
|
64
|
+
ExceptionNotifier::Rake.configure(
|
65
|
+
:ignore_if => lambda { |env, e| true })
|
66
|
+
ExceptionNotifier::Rake.maybe_deliver_notification(Exception.new)
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_maybe_deliver_notifications_with_ignore_exceptions
|
70
|
+
ExceptionNotifier::Rake.configure(
|
71
|
+
:ignore_exceptions => ['RakeTest::IgnoredException'])
|
72
|
+
ExceptionNotifier::Rake.maybe_deliver_notification(IgnoredException.new)
|
73
|
+
ex = Exception.new
|
74
|
+
expect_delivery(ex, ExceptionNotifier::Rake.notifier_options)
|
75
|
+
ExceptionNotifier::Rake.maybe_deliver_notification(ex)
|
76
|
+
end
|
59
77
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: exception_notification-rake
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2014-01-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: exception_notification
|