exception_notification_rails3 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -71,7 +71,32 @@ Using:
71
71
  ExceptionNotifier.with do
72
72
  some code...
73
73
  end
74
-
74
+
75
+ ExceptionNotifier.with({
76
+ :name => 'MyDaemon',
77
+ :data => { :username => "david" },
78
+ :files => [ "path/to/screenshot.png" ]
79
+ }) do
80
+ some code...
81
+ end
82
+
83
+ begin
84
+ some code...
85
+ rescue => e
86
+ ExceptionNotifier::Notifier.background_exception_notification(e).deliver
87
+ end
88
+
89
+ begin
90
+ some code...
91
+ rescue => e
92
+ screenshot_file = make_screenshot!
93
+
94
+ ExceptionNotifier::Notifier.background_exception_notification(e, {
95
+ :name => "MyDaemon",
96
+ :files => [ screenshot_file ]
97
+ }).deliver
98
+ end
99
+
75
100
  == Rails 2.3 stable and earlier
76
101
 
77
102
  If you are running Rails 2.3 then see the branch for that:
@@ -86,4 +111,4 @@ If you are running pre-rack Rails then see this tag:
86
111
 
87
112
  https://rails.lighthouseapp.com/projects/8995-rails-plugins
88
113
 
89
- Copyright (c) 2005 Jamis Buck, released under the MIT license
114
+ Copyright (c) 2005 Jamis Buck, released under the MIT license
@@ -12,14 +12,14 @@ class ExceptionNotifier
12
12
  end
13
13
 
14
14
  def background_options
15
- @background_options ||= Rails.application.middleware.find {|klass| klass == ExceptionNotifier }.args.first rescue {}
15
+ @background_options ||= Rails.application.middleware.find { |klass| klass == ExceptionNotifier }.args.first rescue {}
16
16
  end
17
17
 
18
- def with(&block)
18
+ def with(options = {}, &block)
19
19
  block.call
20
20
  rescue Exception => exception
21
21
  unless Array.wrap(background_options[:ignore_exceptions]).include?(exception.class)
22
- Notifier.background_exception_notification(exception).deliver
22
+ Notifier.background_exception_notification(exception, options).deliver
23
23
  end
24
24
  raise exception
25
25
  end
@@ -58,17 +58,24 @@ class ExceptionNotifier
58
58
  end
59
59
  end
60
60
 
61
- def background_exception_notification(exception)
61
+ def background_exception_notification(exception, options = {})
62
62
  @exception = exception
63
63
  @options = ExceptionNotifier.background_options.reverse_merge(self.class.default_options)
64
64
  @kontroller = MissingController.new
65
65
  @backtrace = clean_backtrace(exception)
66
- @sections = %w(backtrace)
67
-
68
- subject = "#{@options[:email_prefix]} (#{@exception.class}) #{@exception.message.inspect}"
69
-
66
+ @sections = %w(data backtrace)
67
+
68
+ prefix = "#{@options[:email_prefix]}#{options[:name] || '[background]'}"
69
+ subject = "#{prefix} (#{@exception.class}) #{@exception.message.inspect}"
70
+
71
+ (options[:files] || []).each do |path|
72
+ attachments[File.basename(path)] = File.read(path)
73
+ end
74
+
75
+ @data = options[:data] || {}
76
+
70
77
  mail(:to => @options[:exception_recipients], :from => @options[:sender_address], :subject => subject) do |format|
71
- format.text { render "#{mailer_name}/exception_notification" }
78
+ format.text { render "#{mailer_name}/exception_notification", :layout => false }
72
79
  end
73
80
  end
74
81
 
@@ -0,0 +1,3 @@
1
+ <% @data.each do |key, value| %>
2
+ * <%= raw key %>: <%= raw value %>
3
+ <% end %>
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: exception_notification_rails3
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
5
4
  prerelease: false
6
5
  segments:
7
6
  - 1
8
- - 1
7
+ - 2
9
8
  - 0
10
- version: 1.1.0
9
+ version: 1.2.0
11
10
  platform: ruby
12
11
  authors:
13
12
  - Jamis Buck
@@ -16,7 +15,7 @@ autorequire:
16
15
  bindir: bin
17
16
  cert_chain: []
18
17
 
19
- date: 2010-10-19 00:00:00 +03:00
18
+ date: 2010-11-04 00:00:00 +02:00
20
19
  default_executable:
21
20
  dependencies: []
22
21
 
@@ -30,13 +29,14 @@ extra_rdoc_files: []
30
29
 
31
30
  files:
32
31
  - README
33
- - lib/exception_notifier/notifier.rb
34
32
  - lib/exception_notifier/views/exception_notifier/_backtrace.text.erb
35
33
  - lib/exception_notifier/views/exception_notifier/_environment.text.erb
36
- - lib/exception_notifier/views/exception_notifier/_request.text.erb
34
+ - lib/exception_notifier/views/exception_notifier/exception_notification.text.erb
37
35
  - lib/exception_notifier/views/exception_notifier/_session.text.erb
36
+ - lib/exception_notifier/views/exception_notifier/_data.text.erb
37
+ - lib/exception_notifier/views/exception_notifier/_request.text.erb
38
38
  - lib/exception_notifier/views/exception_notifier/_title.text.erb
39
- - lib/exception_notifier/views/exception_notifier/exception_notification.text.erb
39
+ - lib/exception_notifier/notifier.rb
40
40
  - lib/exception_notifier.rb
41
41
  has_rdoc: true
42
42
  homepage: http://github.com/railsware/exception_notification
@@ -52,7 +52,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
52
52
  requirements:
53
53
  - - ">="
54
54
  - !ruby/object:Gem::Version
55
- hash: 3
56
55
  segments:
57
56
  - 0
58
57
  version: "0"
@@ -61,7 +60,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
61
60
  requirements:
62
61
  - - ">="
63
62
  - !ruby/object:Gem::Version
64
- hash: 3
65
63
  segments:
66
64
  - 0
67
65
  version: "0"