wrangler 0.1.15 → 0.1.16

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -87,6 +87,12 @@ Here is the full set of configuration values for both classes, as well as their
87
87
  :notify_on_public_error => true,
88
88
  # send email for exceptions caught outside of a controller context
89
89
  :notify_on_background_error => true,
90
+ # configure regular expressions for specific HTTP headers, which if they
91
+ # match will NOT send notification emails (e.g. for filtering out crazy
92
+ # browsers).
93
+ # array of hashes, each with one key (http header string) and a value
94
+ # (regexp to match in http header string)
95
+ :block_notify_on_request_headers => [],
90
96
  # configure whether to send emails synchronously or asynchronously
91
97
  # using delayed_job (these can be true even if delayed job is not
92
98
  # installed, in which case, will just send emails synchronously anyway)
@@ -55,6 +55,16 @@ module Wrangler
55
55
  :notify_on_public_error => true,
56
56
  # send email for exceptions caught outside of a controller context
57
57
  :notify_on_background_error => true,
58
+ # configure regular expressions for specific HTTP headers, which if they
59
+ # match will NOT send notification emails (e.g. for filtering out crazy
60
+ # browsers).
61
+ # array of hashes, each with one key (http header string) and a value
62
+ # (regexp to match in http header string). this allows for more than one
63
+ # regexp to be specified for the same header if that's more convenient.
64
+ # any one pattern match will block notification.
65
+ # note that this looks in all request headers, including query params
66
+ # (e.g. form fields, url query params)
67
+ :block_notify_on_request_headers => [],
58
68
  # configure whether to send emails synchronously or asynchronously
59
69
  # using delayed_job (these can be true even if delayed job is not
60
70
  # installed, in which case, will just send emails synchronously anyway)
@@ -279,9 +289,7 @@ module Wrangler
279
289
  end
280
290
  end
281
291
 
282
- if (exception && notify_on_exception?(exception, status_code)) ||
283
- (exception.nil? && notify_in_context?)
284
-
292
+ if send_notification?(exception, request, status_code)
285
293
  if notify_with_delayed_job?
286
294
  # don't pass in request as it contains not-easily-serializable stuff
287
295
  log_error "Wrangler sending email notification asynchronously"
@@ -312,6 +320,46 @@ module Wrangler
312
320
  end
313
321
 
314
322
 
323
+ # determine if a notificaiton should be sent
324
+ #-----------------------------------------------------------------------------
325
+ def send_notification?(exception = nil, request = nil, status_code = nil)
326
+ send_notification = notify_in_context?
327
+
328
+ if !send_notification
329
+ log_error("Will not notify because notify_in_context? returned false")
330
+ end
331
+
332
+ if send_notification && !exception.nil?
333
+ send_notification &&= notify_on_exception?(exception, status_code)
334
+ if !send_notification
335
+ log_error("Will not notify because notify_on_exception? returned false")
336
+ end
337
+ end
338
+
339
+ if send_notification && !request.nil?
340
+ config[:block_notify_on_request_headers].each do |headers_and_patterns|
341
+ headers_and_patterns.each_pair do |header, regexp|
342
+ # only send notification if the header does NOT match the regexp
343
+ if request.env.include?(header)
344
+ send_notification &&= (regexp !~ request.env[header])
345
+ end
346
+ if request.env['action_controller.request.query_parameters'].include?(header)
347
+ send_notification &&= (regexp !~ request.env['action_controller.request.query_parameters'][header])
348
+ end
349
+ if request.env['action_controller.request.request_parameters'].include?(header)
350
+ send_notification &&= (regexp !~ request.env['action_controller.request.request_parameters'][header])
351
+ end
352
+ end
353
+ end
354
+ if !send_notification
355
+ log_error "Will not notify because :block_notify_on_request_headers was configured to block this request"
356
+ end
357
+ end
358
+
359
+ return send_notification
360
+ end
361
+
362
+
315
363
  # determine if the current context (+local?+, +background+) indicates that a
316
364
  # notification should be sent. this applies all of the rules around
317
365
  # notifications EXCEPT for what the current exception or status code is
@@ -8,7 +8,11 @@
8
8
  <%= @protocol %><%= @host %><%= @uri %>
9
9
  <% end -%>
10
10
 
11
- A<%= "/an #{@exception_classname}" || "n error" %> occurred:
11
+ <% if !@exception_classname.nil? -%>
12
+ A/an #{@exception_classname} occurred:
13
+ <% else -%>
14
+ An error occurred:
15
+ <% end -%>
12
16
  <%= @error_message %>
13
17
  <% if @additional_messages.is_a?(Array) -%>
14
18
  <%= @additional_messages.join("\n ") %>
data/wrangler.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{wrangler}
8
- s.version = "0.1.15"
8
+ s.version = "0.1.16"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Brian Percival"]
12
- s.date = %q{2010-03-29}
12
+ s.date = %q{2010-03-31}
13
13
  s.description = %q{A gem for handling exceptions thrown inside your Rails app. If you include the
14
14
  gem in your application controller, wrangler will render the error pages you
15
15
  configure for each exception or HTTP error code. It will also handle notifying
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wrangler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.15
4
+ version: 0.1.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Percival
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-03-29 00:00:00 -07:00
12
+ date: 2010-03-31 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency