rack_hoptoad 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/rack/hoptoad.rb +23 -7
  2. metadata +19 -10
data/lib/rack/hoptoad.rb CHANGED
@@ -6,9 +6,11 @@ module Rack
6
6
  # Catches all exceptions raised from the app it wraps and
7
7
  # posts the results to hoptoad.
8
8
  class Hoptoad
9
- VERSION = '0.1.3'
9
+ VERSION = '0.1.4'
10
10
 
11
- attr_accessor :api_key, :environment_filters, :report_under, :rack_environment
11
+ class Error < StandardError; end
12
+
13
+ attr_accessor :api_key, :environment_filters, :report_under, :rack_environment, :notifier_class, :failsafe
12
14
 
13
15
  def initialize(app, api_key = nil, rack_environment = 'RACK_ENV')
14
16
  @app = app
@@ -16,6 +18,8 @@ module Rack
16
18
  @report_under = %w(staging production)
17
19
  @rack_environment = rack_environment
18
20
  @environment_filters = %w(AWS_ACCESS_KEY AWS_SECRET_ACCESS_KEY AWS_ACCOUNT SSH_AUTH_SOCK)
21
+ @notifier_class = Toadhopper
22
+ @failsafe = $stderr
19
23
  yield self if block_given?
20
24
  end
21
25
 
@@ -24,8 +28,6 @@ module Rack
24
28
  begin
25
29
  @app.call(env)
26
30
  rescue StandardError, LoadError, SyntaxError => boom
27
- # TODO don't allow exceptions from send_notification to
28
- # propogate
29
31
  notified = send_notification boom, env
30
32
  env['hoptoad.notified'] = notified
31
33
  raise
@@ -56,8 +58,22 @@ module Rack
56
58
  :session => env['rack.session']
57
59
  }
58
60
 
59
- result = toadhopper.post!(exception, options, {'X-Hoptoad-Client-Name' => 'Rack::Hoptoad'})
60
- result.errors.empty?
61
+ if result = toadhopper.post!(exception, options, {'X-Hoptoad-Client-Name' => 'Rack::Hoptoad'})
62
+ if result.errors.empty?
63
+ true
64
+ else
65
+ raise Error, "Status: #{result.status} #{result.errors.inspect}"
66
+ end
67
+ else
68
+ raise Error, "No response from Toadhopper"
69
+ end
70
+ rescue Exception => e
71
+ return unless @failsafe
72
+ @failsafe.puts "Fail safe error caught: #{e.class}: #{e.message}"
73
+ @failsafe.puts e.backtrace
74
+ @failsafe.puts "Exception is #{exception.class}: #{exception.message}"
75
+ @failsafe.puts exception.backtrace
76
+ false
61
77
  end
62
78
 
63
79
  def rack_env
@@ -65,7 +81,7 @@ module Rack
65
81
  end
66
82
 
67
83
  def toadhopper
68
- toad = Toadhopper(api_key)
84
+ toad = @notifier_class.new(api_key)
69
85
  toad.filters = environment_filter_keys
70
86
  toad
71
87
  end
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack_hoptoad
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 19
4
5
  prerelease: false
5
6
  segments:
6
7
  - 0
7
8
  - 1
8
- - 3
9
- version: 0.1.3
9
+ - 4
10
+ version: 0.1.4
10
11
  platform: ruby
11
12
  authors:
12
13
  - Corey Donohoe
@@ -14,35 +15,39 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-03-23 00:00:00 -07:00
18
+ date: 2010-06-12 00:00:00 -07:00
18
19
  default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
- name: rack
22
22
  prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
23
+ version_requirements: &id001 !ruby/object:Gem::Requirement
24
+ none: false
24
25
  requirements:
25
26
  - - ">="
26
27
  - !ruby/object:Gem::Version
28
+ hash: 3
27
29
  segments:
28
30
  - 0
29
31
  version: "0"
32
+ requirement: *id001
30
33
  type: :runtime
31
- version_requirements: *id001
34
+ name: rack
32
35
  - !ruby/object:Gem::Dependency
33
- name: toadhopper
34
36
  prerelease: false
35
- requirement: &id002 !ruby/object:Gem::Requirement
37
+ version_requirements: &id002 !ruby/object:Gem::Requirement
38
+ none: false
36
39
  requirements:
37
40
  - - ~>
38
41
  - !ruby/object:Gem::Version
42
+ hash: 21
39
43
  segments:
40
44
  - 1
41
45
  - 0
42
46
  - 1
43
47
  version: 1.0.1
48
+ requirement: *id002
44
49
  type: :runtime
45
- version_requirements: *id002
50
+ name: toadhopper
46
51
  description: A gem that provides hoptoad notifications from rack
47
52
  email: atmos@atmos.org
48
53
  executables: []
@@ -68,23 +73,27 @@ rdoc_options: []
68
73
  require_paths:
69
74
  - lib
70
75
  required_ruby_version: !ruby/object:Gem::Requirement
76
+ none: false
71
77
  requirements:
72
78
  - - ">="
73
79
  - !ruby/object:Gem::Version
80
+ hash: 3
74
81
  segments:
75
82
  - 0
76
83
  version: "0"
77
84
  required_rubygems_version: !ruby/object:Gem::Requirement
85
+ none: false
78
86
  requirements:
79
87
  - - ">="
80
88
  - !ruby/object:Gem::Version
89
+ hash: 3
81
90
  segments:
82
91
  - 0
83
92
  version: "0"
84
93
  requirements: []
85
94
 
86
95
  rubyforge_project:
87
- rubygems_version: 1.3.6
96
+ rubygems_version: 1.3.7
88
97
  signing_key:
89
98
  specification_version: 3
90
99
  summary: A gem that provides hoptoad notifications from rack