toadhopper-sinatra 0.3 → 0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +36 -0
- data/lib/sinatra/toadhopper.rb +14 -8
- data/test/test_report_error_to_hoptoad.rb +5 -5
- metadata +4 -3
data/README.md
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
[Hoptoad](http://www.hoptoadapp.com/) meets [Sinatra](http://www.sinatrarb.com/).
|
2
|
+
|
3
|
+
_____ ,
|
4
|
+
/ \______ |\ __
|
5
|
+
| o | \____ | | |--| __
|
6
|
+
/\_____/ \___ |/ | | |~'
|
7
|
+
/ \ /|_ () () |
|
8
|
+
|_______/ \ //| \ |\ ()
|
9
|
+
\______ _ ___ \ | \|_ | | \
|
10
|
+
/\_// / \ | \_|_/ () |
|
11
|
+
// //______/ /___/ | |
|
12
|
+
/\/\/\ \ / \ \ @' ()
|
13
|
+
\ \ \ \
|
14
|
+
\ \ \ \
|
15
|
+
\ \ \ \
|
16
|
+
\ \ /\/\
|
17
|
+
/\/\
|
18
|
+
|
19
|
+
How?
|
20
|
+
|
21
|
+
require 'sinatra/toadhopper'
|
22
|
+
|
23
|
+
set :toadhopper, :api_key => "your hoptoad API key", :filters => /password/
|
24
|
+
|
25
|
+
get "/" do
|
26
|
+
raise "Kaboom!"
|
27
|
+
end
|
28
|
+
|
29
|
+
error do
|
30
|
+
post_error_to_hoptoad!
|
31
|
+
"Ouch, that hurt."
|
32
|
+
end
|
33
|
+
|
34
|
+
Install it via rubygems:
|
35
|
+
|
36
|
+
gem install toadhopper-sinatra
|
data/lib/sinatra/toadhopper.rb
CHANGED
@@ -6,9 +6,7 @@ module Sinatra
|
|
6
6
|
module Toadhopper
|
7
7
|
# Reports the current sinatra error to Hoptoad
|
8
8
|
def post_error_to_hoptoad!
|
9
|
-
|
10
|
-
options.toadhopper.each_pair {|k, v| ::Toadhopper.__send__("#{k}=", v)}
|
11
|
-
end
|
9
|
+
options.toadhopper.each_pair {|k, v| ::Toadhopper.__send__("#{k}=", v)}
|
12
10
|
unless ::Toadhopper.api_key
|
13
11
|
STDERR.puts "WARNING: Ignoring hoptoad notification - :api_key not set"
|
14
12
|
return
|
@@ -16,14 +14,22 @@ module Sinatra
|
|
16
14
|
::Toadhopper.post!(
|
17
15
|
env['sinatra.error'],
|
18
16
|
{
|
19
|
-
:
|
20
|
-
:
|
21
|
-
|
22
|
-
|
23
|
-
|
17
|
+
:environment => ENV,
|
18
|
+
:request => {
|
19
|
+
:params => params,
|
20
|
+
:rails_root => options.root,
|
21
|
+
:url => request.url
|
22
|
+
},
|
23
|
+
:session => {
|
24
|
+
:key => 42, # Doesn't apply to Rack sessions
|
25
|
+
:data => session
|
26
|
+
}
|
24
27
|
}
|
25
28
|
)
|
26
29
|
end
|
27
30
|
end
|
31
|
+
def self.registered(app)
|
32
|
+
app.set :hoptoad, {}
|
33
|
+
end
|
28
34
|
helpers Toadhopper
|
29
35
|
end
|
@@ -62,11 +62,11 @@ class TestReportErrorToHoptoad < Test::Unit::TestCase
|
|
62
62
|
end
|
63
63
|
|
64
64
|
def test_options
|
65
|
-
assert_equal
|
66
|
-
assert_equal
|
67
|
-
assert_equal
|
68
|
-
assert_equal
|
69
|
-
assert_equal({"id" => "sessionid"}, @options[:
|
65
|
+
assert_equal ENV, @options[:environment]
|
66
|
+
assert_equal "http://example.org/theid", @options[:request][:url]
|
67
|
+
assert_equal({"id" => "theid"}, @options[:request][:params])
|
68
|
+
assert_equal nil, @options[:request][:rails_root]
|
69
|
+
assert_equal({:key => 42, :data => {"id" => "sessionid"}}, @options[:session])
|
70
70
|
end
|
71
71
|
|
72
72
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: toadhopper-sinatra
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: "0.
|
4
|
+
version: "0.4"
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tim Lucas
|
@@ -20,7 +20,7 @@ dependencies:
|
|
20
20
|
requirements:
|
21
21
|
- - ">="
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: "0.
|
23
|
+
version: "0.7"
|
24
24
|
version:
|
25
25
|
description: Post Hoptoad notifications from Sinatra
|
26
26
|
email: t.lucas@toolmantim.com
|
@@ -31,11 +31,12 @@ extensions: []
|
|
31
31
|
extra_rdoc_files:
|
32
32
|
- Readme.md
|
33
33
|
files:
|
34
|
-
-
|
34
|
+
- README.md
|
35
35
|
- Rakefile
|
36
36
|
- LICENSE
|
37
37
|
- lib/sinatra/toadhopper.rb
|
38
38
|
- test/test_report_error_to_hoptoad.rb
|
39
|
+
- Readme.md
|
39
40
|
has_rdoc: true
|
40
41
|
homepage: http://github.com/toolmantim/toadhopper-sinatra
|
41
42
|
post_install_message:
|