exception_notification-rake 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -9,17 +9,19 @@ This Ruby gem is an extension of the [exception_notification gem](http://rubygem
9
9
 
10
10
  If you're using Rails 4 (or you're not using Rails at all), use the latest version of the gem:
11
11
 
12
- gem 'exception_notification-rake', '~> 0.1.0'
12
+ gem 'exception_notification-rake', '~> 0.1.1'
13
13
 
14
14
  If you're using Rails 3, use the 0.0.x line of versions:
15
15
 
16
- gem 'exception_notification-rake', '~> 0.0.5'
16
+ gem 'exception_notification-rake', '~> 0.0.6'
17
17
 
18
18
 
19
19
  ## Usage
20
20
 
21
21
  ### Basic Configuration
22
22
 
23
+ **Note:** These examples are for the latest version of the gem (using exception_notification 4 and Rails 4). For a Rails 3.2 example [see below](#rails-32-configuration-example).
24
+
23
25
  Exception notification must be set up in your Rails config files. In general, you'll want to do this in environment-specific config files, such as `config/environments/production.rb`. Minimal configuration:
24
26
 
25
27
  # config/environments/production.rb
@@ -52,6 +54,22 @@ If you are already using `ExceptionNotifier` anyway, you don't need to configure
52
54
  **Note:** As a prerequisite for sending mail your Rails Action Mailer needs to be configured in the environment where you're using exception notification. See the [Rails guide on Action Mailer](http://guides.rubyonrails.org/action_mailer_basics.html#action-mailer-configuration).
53
55
 
54
56
 
57
+ #### Rails 3.2 Configuration Example
58
+
59
+ # config/environments/production.rb
60
+
61
+ YourApp::Application.configure do
62
+ # Other configuration here, including ActionMailer config ...
63
+
64
+ config.middleware.use ExceptionNotifier,
65
+ :sender_address => %{"notifier" <sender.address@example.com>},
66
+ :exception_recipients => %w{your.email@example.com},
67
+ :ignore_if => lambda { true }
68
+
69
+ ExceptionNotifier::Rake.configure
70
+ end
71
+
72
+
55
73
  ### Notification Example
56
74
 
57
75
  Email sent upon a failure will include the Rake tasks executed and a stacktrace. This is the result from calling an undefined method `khaaaaan!` in a task called `failing_task`:
@@ -120,6 +138,8 @@ The most likely options you'll want to use are `:email_prefix` and `:exception_r
120
138
 
121
139
  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` mail notifier itself, they will be overridden but for Rake failures only.
122
140
 
141
+ `:ignore_if` and `:ignore_exceptions` are also supported.
142
+
123
143
  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).
124
144
 
125
145
 
@@ -1,5 +1,5 @@
1
1
  module ExceptionNotifier
2
2
  class Rake
3
- VERSION = '0.1.0'
3
+ VERSION = '0.1.1'
4
4
  end
5
5
  end
data/test/rake_test.rb CHANGED
@@ -6,6 +6,9 @@ require 'exception_notifier/rake'
6
6
 
7
7
  class RakeTest < Test::Unit::TestCase
8
8
 
9
+ class IgnoredException < Exception
10
+ end
11
+
9
12
  def setup
10
13
  ExceptionNotifier::Rake.reset_for_test
11
14
  assert !ExceptionNotifier::Rake.configured?
@@ -54,4 +57,19 @@ class RakeTest < Test::Unit::TestCase
54
57
  ExceptionNotifier::Rake.maybe_deliver_notification(ex, data)
55
58
  assert_equal(original_options, options)
56
59
  end
60
+
61
+ def test_maybe_deliver_notifications_with_ignore_if
62
+ ExceptionNotifier::Rake.configure(
63
+ ignore_if: lambda { |ex, options| true })
64
+ ExceptionNotifier::Rake.maybe_deliver_notification(Exception.new)
65
+ end
66
+
67
+ def test_maybe_deliver_notifications_with_ignore_exceptions
68
+ ExceptionNotifier::Rake.configure(
69
+ ignore_exceptions: ['RakeTest::IgnoredException'])
70
+ ExceptionNotifier::Rake.maybe_deliver_notification(IgnoredException.new)
71
+ ex = Exception.new
72
+ expect_delivery(ex, ExceptionNotifier::Rake.notifier_options)
73
+ ExceptionNotifier::Rake.maybe_deliver_notification(ex)
74
+ end
57
75
  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.1.0
4
+ version: 0.1.1
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: 2013-07-08 00:00:00.000000000 Z
12
+ date: 2014-01-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: exception_notification
@@ -18,7 +18,7 @@ dependencies:
18
18
  requirements:
19
19
  - - ~>
20
20
  - !ruby/object:Gem::Version
21
- version: 4.0.0
21
+ version: 4.0.1
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
@@ -26,7 +26,7 @@ dependencies:
26
26
  requirements:
27
27
  - - ~>
28
28
  - !ruby/object:Gem::Version
29
- version: 4.0.0
29
+ version: 4.0.1
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: rake
32
32
  requirement: !ruby/object:Gem::Requirement