exception_notification 3.0.0 → 3.0.1.rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +10 -1
- data/Gemfile.lock +2 -2
- data/README.md +24 -2
- data/Rakefile +7 -3
- data/exception_notification.gemspec +4 -3
- data/lib/exception_notifier.rb +1 -0
- data/lib/exception_notifier/campfire_notifier.rb +5 -1
- data/lib/exception_notifier/notifier.rb +15 -3
- data/lib/exception_notifier/views/exception_notifier/background_exception_notification.html.erb +1 -1
- data/lib/exception_notifier/views/exception_notifier/background_exception_notification.text.erb +1 -1
- data/lib/exception_notifier/views/exception_notifier/exception_notification.html.erb +1 -1
- data/lib/exception_notifier/views/exception_notifier/exception_notification.text.erb +1 -1
- data/test/campfire_test.rb +1 -0
- data/test/dummy/Gemfile +1 -0
- data/test/dummy/Gemfile.lock +1 -1
- data/test/dummy/config/environment.rb +1 -0
- data/test/dummy/config/environments/development.rb +0 -2
- data/test/dummy/db/schema.rb +3 -2
- data/test/dummy/test/functional/posts_controller_test.rb +4 -0
- data/test/exception_notification_test.rb +4 -0
- metadata +6 -6
data/CHANGELOG.rdoc
CHANGED
@@ -1,8 +1,17 @@
|
|
1
|
+
== 3.0.1
|
2
|
+
|
3
|
+
* enhancements
|
4
|
+
* Custom Headers (by @DouweM)
|
5
|
+
* Make Tinder a soft-dependency (by @fgrehm)
|
6
|
+
|
7
|
+
* bug fixes
|
8
|
+
* Fix `code converter not found` (by @alanjds)
|
9
|
+
|
1
10
|
== 3.0.0
|
2
11
|
|
3
12
|
* enhancements
|
4
13
|
* Campfire integration
|
5
|
-
* Support
|
14
|
+
* Support for HTML notifications (by @Xenofex)
|
6
15
|
* Be able to override SMTP settings (by @piglop and @Macint)
|
7
16
|
|
8
17
|
* bug fixes
|
data/Gemfile.lock
CHANGED
@@ -1,9 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
exception_notification (3.0.
|
4
|
+
exception_notification (3.0.1.rc1)
|
5
5
|
actionmailer (>= 3.0.4)
|
6
|
-
tinder (~> 1.8)
|
7
6
|
|
8
7
|
GEM
|
9
8
|
remote: http://rubygems.org/
|
@@ -120,3 +119,4 @@ DEPENDENCIES
|
|
120
119
|
mocha (>= 0.11.3)
|
121
120
|
rails (>= 3.0.4)
|
122
121
|
sqlite3 (>= 1.3.4)
|
122
|
+
tinder (~> 1.8)
|
data/README.md
CHANGED
@@ -40,8 +40,16 @@ Campfire Integration
|
|
40
40
|
|
41
41
|
Additionally, ExceptionNotification supports sending notifications to
|
42
42
|
your Campfire room.
|
43
|
+
|
44
|
+
First you'll need to add [tinder](https://github.com/collectiveidea/tinder)
|
45
|
+
to your `Gemfile`:
|
46
|
+
|
47
|
+
```ruby
|
48
|
+
gem 'tinder'
|
49
|
+
```
|
50
|
+
|
43
51
|
To configure it, you need to set the subdomain, token and room name,
|
44
|
-
like this
|
52
|
+
like this:
|
45
53
|
|
46
54
|
```ruby
|
47
55
|
Whatever::Application.config.middleware.use ExceptionNotifier,
|
@@ -90,7 +98,7 @@ Whatever::Application.config.middleware.use ExceptionNotifier,
|
|
90
98
|
:sections => %w{my_section1 my_section2} + ExceptionNotifier::Notifier.default_sections
|
91
99
|
```
|
92
100
|
|
93
|
-
Place your custom sections under `./app/views/exception_notifier/` with the suffix `.text.erb`, e.g.
|
101
|
+
Place your custom sections under `./app/views/exception_notifier/` with the suffix `.text.erb`, e.g.
|
94
102
|
`./app/views/exception_notifier/_my_section1.text.erb`.
|
95
103
|
|
96
104
|
If your new section requires information that isn't available by default, make sure
|
@@ -192,6 +200,20 @@ Whatever::Application.config.middleware.use ExceptionNotifier,
|
|
192
200
|
You can make use of both the environment and the exception inside the lambda to decide wether to
|
193
201
|
avoid or not sending the notification.
|
194
202
|
|
203
|
+
### Headers
|
204
|
+
|
205
|
+
Additionally, you may want to set customized headers on the outcoming
|
206
|
+
emails. To do so, simply use the _:email_headers_ option:
|
207
|
+
|
208
|
+
```ruby
|
209
|
+
Whatever::Application.config.middleware.use ExceptionNotifier,
|
210
|
+
:email_prefix => "[Whatever] ",
|
211
|
+
:sender_address => %{"notifier" <notifier@example.com>},
|
212
|
+
:exception_recipients => %w{exceptions@example.com},
|
213
|
+
:ignore_if => lambda { |env, e| e.message =~ /^Couldn't find Page with ID=/ },
|
214
|
+
:email_headers => { "X-Custom-Header" => "foobar" }
|
215
|
+
```
|
216
|
+
|
195
217
|
### Verbose
|
196
218
|
|
197
219
|
You can also choose to exclude the exception message from the subject, which is included by default.
|
data/Rakefile
CHANGED
@@ -3,8 +3,12 @@ Bundler::GemHelper.install_tasks
|
|
3
3
|
|
4
4
|
require 'rake/testtask'
|
5
5
|
|
6
|
-
|
7
|
-
|
6
|
+
task 'setup_dummy_app' do
|
7
|
+
unless File.exists? "test/dummy/db/test.sqlite3"
|
8
|
+
Bundler.with_clean_env do
|
9
|
+
sh "cd test/dummy; bundle; rake db:migrate; rake db:test:prepare; cd ../../;"
|
10
|
+
end
|
11
|
+
end
|
8
12
|
end
|
9
13
|
|
10
14
|
Rake::TestTask.new(:test) do |t|
|
@@ -14,4 +18,4 @@ Rake::TestTask.new(:test) do |t|
|
|
14
18
|
t.verbose = true
|
15
19
|
end
|
16
20
|
|
17
|
-
task :default => :test
|
21
|
+
task :default => [:setup_dummy_app, :test]
|
@@ -1,8 +1,8 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'exception_notification'
|
3
|
-
s.version = '3.0.
|
3
|
+
s.version = '3.0.1.rc1'
|
4
4
|
s.authors = ["Jamis Buck", "Josh Peek"]
|
5
|
-
s.date = %q{
|
5
|
+
s.date = %q{2013-01-19}
|
6
6
|
s.summary = "Exception notification for Rails apps"
|
7
7
|
s.homepage = "http://smartinez87.github.com/exception_notification"
|
8
8
|
s.email = "smartinez87@gmail.com"
|
@@ -12,7 +12,8 @@ Gem::Specification.new do |s|
|
|
12
12
|
s.require_path = 'lib'
|
13
13
|
|
14
14
|
s.add_dependency("actionmailer", ">= 3.0.4")
|
15
|
-
|
15
|
+
|
16
|
+
s.add_development_dependency "tinder", "~> 1.8"
|
16
17
|
s.add_development_dependency "rails", ">= 3.0.4"
|
17
18
|
s.add_development_dependency "mocha", ">= 0.11.3"
|
18
19
|
s.add_development_dependency "sqlite3", ">= 1.3.4"
|
data/lib/exception_notifier.rb
CHANGED
@@ -28,6 +28,7 @@ class ExceptionNotifier
|
|
28
28
|
Notifier.default_verbose_subject = @options[:verbose_subject]
|
29
29
|
Notifier.default_normalize_subject = @options[:normalize_subject]
|
30
30
|
Notifier.default_smtp_settings = @options[:smtp_settings]
|
31
|
+
Notifier.default_email_headers = @options[:email_headers]
|
31
32
|
|
32
33
|
@campfire = CampfireNotifier.new @options[:campfire]
|
33
34
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
class ExceptionNotifier
|
2
2
|
class CampfireNotifier
|
3
|
-
|
3
|
+
cattr_accessor :tinder_available, true
|
4
4
|
|
5
5
|
attr_accessor :subdomain
|
6
6
|
attr_accessor :token
|
@@ -8,6 +8,8 @@ class ExceptionNotifier
|
|
8
8
|
|
9
9
|
def initialize(options)
|
10
10
|
begin
|
11
|
+
return unless tinder_available
|
12
|
+
|
11
13
|
subdomain = options.delete(:subdomain)
|
12
14
|
room_name = options.delete(:room_name)
|
13
15
|
@campfire = Tinder::Campfire.new subdomain, options
|
@@ -28,3 +30,5 @@ class ExceptionNotifier
|
|
28
30
|
end
|
29
31
|
end
|
30
32
|
end
|
33
|
+
|
34
|
+
ExceptionNotifier::CampfireNotifier.tinder_available = Gem.loaded_specs.keys.include? 'tinder'
|
@@ -18,6 +18,7 @@ class ExceptionNotifier
|
|
18
18
|
attr_writer :default_verbose_subject
|
19
19
|
attr_writer :default_normalize_subject
|
20
20
|
attr_writer :default_smtp_settings
|
21
|
+
attr_writer :default_email_headers
|
21
22
|
|
22
23
|
def default_sender_address
|
23
24
|
@default_sender_address || %("Exception Notifier" <exception.notifier@default.com>)
|
@@ -55,6 +56,10 @@ class ExceptionNotifier
|
|
55
56
|
@default_smtp_settings || nil
|
56
57
|
end
|
57
58
|
|
59
|
+
def default_email_headers
|
60
|
+
@default_email_headers || {}
|
61
|
+
end
|
62
|
+
|
58
63
|
def default_options
|
59
64
|
{ :sender_address => default_sender_address,
|
60
65
|
:exception_recipients => default_exception_recipients,
|
@@ -65,7 +70,8 @@ class ExceptionNotifier
|
|
65
70
|
:verbose_subject => default_verbose_subject,
|
66
71
|
:normalize_subject => default_normalize_subject,
|
67
72
|
:template_path => mailer_name,
|
68
|
-
:smtp_settings => default_smtp_settings
|
73
|
+
:smtp_settings => default_smtp_settings,
|
74
|
+
:email_headers => default_email_headers }
|
69
75
|
end
|
70
76
|
|
71
77
|
def normalize_digits(string)
|
@@ -155,8 +161,14 @@ class ExceptionNotifier
|
|
155
161
|
subject = compose_subject
|
156
162
|
name = @env.nil? ? 'background_exception_notification' : 'exception_notification'
|
157
163
|
|
158
|
-
|
159
|
-
|
164
|
+
headers = {
|
165
|
+
:to => @options[:exception_recipients],
|
166
|
+
:from => @options[:sender_address],
|
167
|
+
:subject => subject,
|
168
|
+
:template_name => name
|
169
|
+
}.merge(@options[:email_headers])
|
170
|
+
|
171
|
+
mail = mail(headers) do |format|
|
160
172
|
format.text
|
161
173
|
format.html if html_mail?
|
162
174
|
end
|
data/lib/exception_notifier/views/exception_notifier/background_exception_notification.html.erb
CHANGED
@@ -18,7 +18,7 @@
|
|
18
18
|
"#{title}\n\n#{summary.gsub(/^/, " ")}\n\n"
|
19
19
|
end
|
20
20
|
end.join
|
21
|
-
sections = sections.force_encoding('UTF-8').encode('UTF-
|
21
|
+
sections = sections.force_encoding('UTF-8').encode('UTF-16LE', :invalid => :replace).encode('UTF-8') if sections.respond_to?(:force_encoding)
|
22
22
|
%>
|
23
23
|
<%= raw sections %>
|
24
24
|
</pre>
|
data/lib/exception_notifier/views/exception_notifier/background_exception_notification.text.erb
CHANGED
@@ -10,6 +10,6 @@
|
|
10
10
|
"#{title}\n\n#{summary.gsub(/^/, " ")}\n\n"
|
11
11
|
end
|
12
12
|
end.join
|
13
|
-
sections = sections.force_encoding('UTF-8').encode('UTF-
|
13
|
+
sections = sections.force_encoding('UTF-8').encode('UTF-16LE', :invalid => :replace).encode('UTF-8') if sections.respond_to?(:force_encoding)
|
14
14
|
%>
|
15
15
|
<%= raw sections %>
|
@@ -27,7 +27,7 @@
|
|
27
27
|
[title, summary.gsub(/^/, " "), nil].join("\n\n")
|
28
28
|
end
|
29
29
|
end.join
|
30
|
-
sections = sections.force_encoding('UTF-8').encode('UTF-
|
30
|
+
sections = sections.force_encoding('UTF-8').encode('UTF-16LE', :invalid => :replace).encode('UTF-8') if sections.respond_to?(:force_encoding)
|
31
31
|
%>
|
32
32
|
|
33
33
|
<%= raw sections %>
|
@@ -19,7 +19,7 @@
|
|
19
19
|
[title, summary.gsub(/^/, " "), nil].join("\n\n")
|
20
20
|
end
|
21
21
|
end.join
|
22
|
-
sections = sections.force_encoding('UTF-8').encode('UTF-
|
22
|
+
sections = sections.force_encoding('UTF-8').encode('UTF-16LE', :invalid => :replace).encode('UTF-8') if sections.respond_to?(:force_encoding)
|
23
23
|
%>
|
24
24
|
|
25
25
|
<%= raw sections %>
|
data/test/campfire_test.rb
CHANGED
data/test/dummy/Gemfile
CHANGED
data/test/dummy/Gemfile.lock
CHANGED
@@ -5,6 +5,7 @@ Dummy::Application.config.middleware.use ExceptionNotifier,
|
|
5
5
|
:email_prefix => "[Dummy ERROR] ",
|
6
6
|
:sender_address => %{"Dummy Notifier" <dummynotifier@example.com>},
|
7
7
|
:exception_recipients => %w{dummyexceptions@example.com},
|
8
|
+
:email_headers => { "X-Custom-Header" => "foobar" },
|
8
9
|
:sections => ['new_section', 'request', 'session', 'environment', 'backtrace'],
|
9
10
|
:background_sections => %w(new_bkg_section) + ExceptionNotifier::Notifier.default_background_sections
|
10
11
|
|
@@ -11,7 +11,6 @@ Dummy::Application.configure do
|
|
11
11
|
|
12
12
|
# Show full error reports and disable caching
|
13
13
|
config.consider_all_requests_local = true
|
14
|
-
config.action_view.debug_rjs = true
|
15
14
|
config.action_controller.perform_caching = false
|
16
15
|
|
17
16
|
# Don't care if the mailer can't send
|
@@ -23,4 +22,3 @@ Dummy::Application.configure do
|
|
23
22
|
# Only use best-standards-support built into browsers
|
24
23
|
config.action_dispatch.best_standards_support = :builtin
|
25
24
|
end
|
26
|
-
|
data/test/dummy/db/schema.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# encoding: UTF-8
|
1
2
|
# This file is auto-generated from the current state of the database. Instead
|
2
3
|
# of editing this file, please use the migrations feature of Active Record to
|
3
4
|
# incrementally modify your database, and then regenerate this schema definition.
|
@@ -16,8 +17,8 @@ ActiveRecord::Schema.define(:version => 20110729022608) do
|
|
16
17
|
t.string "title"
|
17
18
|
t.text "body"
|
18
19
|
t.string "secret"
|
19
|
-
t.datetime "created_at"
|
20
|
-
t.datetime "updated_at"
|
20
|
+
t.datetime "created_at", :null => false
|
21
|
+
t.datetime "updated_at", :null => false
|
21
22
|
end
|
22
23
|
|
23
24
|
end
|
@@ -59,6 +59,10 @@ class PostsControllerTest < ActionController::TestCase
|
|
59
59
|
assert @mail.encoded.include? "secret\"=>\"[FILTERED]"
|
60
60
|
end
|
61
61
|
|
62
|
+
test "mail should contain the custom header" do
|
63
|
+
assert @mail.encoded.include? 'X-Custom-Header: foobar'
|
64
|
+
end
|
65
|
+
|
62
66
|
test "mail should not contain any attachments" do
|
63
67
|
assert @mail.attachments == []
|
64
68
|
end
|
@@ -17,6 +17,10 @@ class ExceptionNotificationTest < ActiveSupport::TestCase
|
|
17
17
|
assert ExceptionNotifier::Notifier.default_email_format == :text
|
18
18
|
end
|
19
19
|
|
20
|
+
test "should have default email headers overridden" do
|
21
|
+
assert ExceptionNotifier::Notifier.default_email_headers == { "X-Custom-Header" => "foobar"}
|
22
|
+
end
|
23
|
+
|
20
24
|
test "should have default sections" do
|
21
25
|
for section in %w(request session environment backtrace)
|
22
26
|
assert ExceptionNotifier::Notifier.default_sections.include? section
|
metadata
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: exception_notification
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
5
|
-
prerelease:
|
4
|
+
version: 3.0.1.rc1
|
5
|
+
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Jamis Buck
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2013-01-19 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: actionmailer
|
@@ -36,7 +36,7 @@ dependencies:
|
|
36
36
|
- - ~>
|
37
37
|
- !ruby/object:Gem::Version
|
38
38
|
version: '1.8'
|
39
|
-
type: :
|
39
|
+
type: :development
|
40
40
|
prerelease: false
|
41
41
|
version_requirements: !ruby/object:Gem::Requirement
|
42
42
|
none: false
|
@@ -200,9 +200,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
200
200
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
201
201
|
none: false
|
202
202
|
requirements:
|
203
|
-
- - ! '
|
203
|
+
- - ! '>'
|
204
204
|
- !ruby/object:Gem::Version
|
205
|
-
version:
|
205
|
+
version: 1.3.1
|
206
206
|
requirements: []
|
207
207
|
rubyforge_project:
|
208
208
|
rubygems_version: 1.8.23
|