rack_hoptoad 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 +11 -4
- data/Rakefile +15 -12
- data/lib/rack/hoptoad.rb +28 -11
- metadata +3 -3
data/README.md
CHANGED
@@ -13,15 +13,22 @@ Throw something like this in your config.ru to enable notifications.
|
|
13
13
|
|
14
14
|
You can also exclude certain sensitive environmental variables using the block syntax
|
15
15
|
|
16
|
-
require 'rack/hoptoad'
|
17
|
-
|
18
16
|
use Rack::Hoptoad, 'fd48c7d26f724503a0280f808f44b339fc65fab8' do |notifier|
|
19
17
|
notifier.environment_filters << %w(MY_SECRET_KEY MY_SECRET_TOKEN)
|
20
18
|
end
|
21
19
|
|
20
|
+
If you want to post exceptions in an environment other than staging or production(the defaults)
|
21
|
+
|
22
|
+
use Rack::Hoptoad, 'fd48c7d26f724503a0280f808f44b339fc65fab8' do |notifier|
|
23
|
+
notifier.report_under << 'custom'
|
24
|
+
end
|
25
|
+
|
26
|
+
If you want to use an environmental variable other than RACK_ENV and still have it post
|
22
27
|
|
23
|
-
|
24
|
-
|
28
|
+
use Rack::Hoptoad, 'fd48c7d26f724503a0280f808f44b339fc65fab8', 'MERB_ENV' do |notifier|
|
29
|
+
notifier.report_under << 'custom'
|
30
|
+
notifier.environment_filters << %w(MY_SECRET_KEY MY_SECRET_TOKEN)
|
31
|
+
end
|
25
32
|
|
26
33
|
Installation
|
27
34
|
============
|
data/Rakefile
CHANGED
@@ -1,30 +1,33 @@
|
|
1
|
-
require 'rubygems'
|
2
1
|
require 'rake/gempackagetask'
|
3
2
|
require 'rubygems/specification'
|
4
3
|
require 'spec/rake/spectask'
|
5
4
|
require 'date'
|
6
5
|
require 'bundler'
|
7
6
|
|
7
|
+
Bundler.require_env
|
8
|
+
|
9
|
+
require 'lib/rack/hoptoad'
|
10
|
+
|
8
11
|
GEM = "rack_hoptoad"
|
9
|
-
GEM_VERSION =
|
12
|
+
GEM_VERSION = Rack::Hoptoad::VERSION
|
10
13
|
AUTHOR = "Corey Donohoe"
|
11
14
|
EMAIL = "atmos@atmos.org"
|
12
15
|
HOMEPAGE = "http://github.com/atmos/rack_hoptoad"
|
13
16
|
SUMMARY = "A gem that provides hoptoad notifications from rack"
|
14
17
|
|
15
18
|
spec = Gem::Specification.new do |s|
|
16
|
-
s.name
|
17
|
-
s.version
|
18
|
-
s.platform
|
19
|
-
s.has_rdoc
|
19
|
+
s.name = GEM
|
20
|
+
s.version = GEM_VERSION
|
21
|
+
s.platform = Gem::Platform::RUBY
|
22
|
+
s.has_rdoc = true
|
20
23
|
s.extra_rdoc_files = ["LICENSE", 'TODO']
|
21
|
-
s.summary
|
22
|
-
s.description
|
23
|
-
s.author
|
24
|
-
s.email
|
25
|
-
s.homepage
|
24
|
+
s.summary = SUMMARY
|
25
|
+
s.description = s.summary
|
26
|
+
s.author = AUTHOR
|
27
|
+
s.email = EMAIL
|
28
|
+
s.homepage = HOMEPAGE
|
26
29
|
|
27
|
-
manifest = Bundler::
|
30
|
+
manifest = Bundler::Dsl.load_gemfile(File.dirname(__FILE__) + '/Gemfile')
|
28
31
|
manifest.dependencies.each do |d|
|
29
32
|
next unless d.only && d.only.include?('release')
|
30
33
|
s.add_dependency(d.name, d.version)
|
data/lib/rack/hoptoad.rb
CHANGED
@@ -6,11 +6,15 @@ 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
|
-
|
9
|
+
VERSION = '0.1.1'
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
attr_accessor :api_key, :environment_filters, :report_under, :rack_environment
|
12
|
+
|
13
|
+
def initialize(app, api_key = nil, rack_environment = 'RACK_ENV')
|
14
|
+
@app = app
|
15
|
+
@api_key = api_key
|
16
|
+
@report_under = %w(staging production)
|
17
|
+
@rack_environment = rack_environment
|
14
18
|
@environment_filters = %w(AWS_ACCESS_KEY AWS_SECRET_ACCESS_KEY AWS_ACCOUNT SSH_AUTH_SOCK)
|
15
19
|
yield self if block_given?
|
16
20
|
end
|
@@ -22,7 +26,8 @@ module Rack
|
|
22
26
|
rescue StandardError, LoadError, SyntaxError => boom
|
23
27
|
# TODO don't allow exceptions from send_notification to
|
24
28
|
# propogate
|
25
|
-
send_notification boom, env
|
29
|
+
notified = send_notification boom, env
|
30
|
+
env['hoptoad.notified'] = notified
|
26
31
|
raise
|
27
32
|
end
|
28
33
|
send_notification env['rack.exception'], env if env['rack.exception']
|
@@ -33,24 +38,36 @@ module Rack
|
|
33
38
|
@environment_filters.flatten
|
34
39
|
end
|
35
40
|
private
|
41
|
+
def report?
|
42
|
+
report_under.include?(rack_env)
|
43
|
+
end
|
36
44
|
|
37
45
|
def send_notification(exception, env)
|
46
|
+
return true unless report?
|
38
47
|
request = Rack::Request.new(env)
|
39
48
|
|
40
49
|
options = {
|
41
50
|
:api_key => api_key,
|
42
51
|
:url => "#{request.scheme}://#{request.host}#{request.path}",
|
43
52
|
:request => request,
|
44
|
-
:framework_env =>
|
53
|
+
:framework_env => rack_env,
|
45
54
|
:notifier_name => 'Rack::Hoptoad',
|
46
|
-
:notifier_version =>
|
55
|
+
:notifier_version => VERSION,
|
47
56
|
:session => env['rack.session']
|
48
57
|
}
|
49
58
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
59
|
+
result = toadhopper.post!(exception, options, {'X-Hoptoad-Client-Name' => 'Rack::Hoptoad'})
|
60
|
+
result.errors.empty?
|
61
|
+
end
|
62
|
+
|
63
|
+
def rack_env
|
64
|
+
ENV[rack_environment] || 'development'
|
65
|
+
end
|
66
|
+
|
67
|
+
def toadhopper
|
68
|
+
toad = ToadHopper(api_key)
|
69
|
+
toad.filters = environment_filter_keys
|
70
|
+
toad
|
54
71
|
end
|
55
72
|
|
56
73
|
def extract_body(env)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack_hoptoad
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Corey Donohoe
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-12-
|
12
|
+
date: 2009-12-25 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -30,7 +30,7 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ~>
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.9.
|
33
|
+
version: 0.9.4
|
34
34
|
version:
|
35
35
|
description: A gem that provides hoptoad notifications from rack
|
36
36
|
email: atmos@atmos.org
|