toadhopper 0.9.4 → 0.9.5
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +8 -5
- data/README.md +6 -5
- data/Rakefile +8 -7
- data/lib/notice.haml +1 -1
- data/lib/toadhopper.rb +14 -4
- data/test/helper.rb +7 -2
- data/test/test_filters.rb +11 -4
- data/test/test_posting.rb +2 -3
- metadata +4 -3
data/Gemfile
CHANGED
@@ -1,15 +1,18 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
source :gemcutter
|
2
|
+
|
3
|
+
group :runtime do
|
4
|
+
gem 'haml', '~> 2.2.0'
|
3
5
|
gem 'nokogiri'
|
4
6
|
end
|
5
7
|
|
6
|
-
|
8
|
+
group :development do
|
7
9
|
gem 'yard'
|
8
10
|
gem 'jeweler'
|
9
11
|
end
|
10
12
|
|
11
|
-
|
13
|
+
group :test do
|
12
14
|
gem 'rake'
|
13
15
|
gem 'nokogiri'
|
14
|
-
gem 'test-unit', :
|
16
|
+
gem 'test-unit', :require => 'test/unit'
|
17
|
+
gem 'ruby-debug'
|
15
18
|
end
|
data/README.md
CHANGED
@@ -15,23 +15,24 @@ You can install it via rubygems:
|
|
15
15
|
|
16
16
|
## Development
|
17
17
|
|
18
|
-
|
18
|
+
Install Bundler 0.9.x, then:
|
19
19
|
|
20
20
|
% git clone git://github.com/toolmantim/toadhopper.git
|
21
21
|
% cd toadhopper
|
22
|
-
%
|
23
|
-
%
|
22
|
+
% bundle install
|
23
|
+
% bundle exec rake test
|
24
24
|
|
25
25
|
If you set a `HOPTOAD_API_KEY` environment variable it'll test actually posting to the Hoptoad API. For example:
|
26
26
|
|
27
|
-
%
|
27
|
+
% bundle exec rake test HOPTOAD_API_KEY=abc123
|
28
28
|
|
29
29
|
To generate the docs:
|
30
30
|
|
31
|
-
%
|
31
|
+
% bundle exec yardoc
|
32
32
|
|
33
33
|
## Contributors
|
34
34
|
|
35
35
|
* [Tim Lucas](http://github.com/toolmantim)
|
36
36
|
* [Samuel Tesla](http://github.com/stesla)
|
37
37
|
* [atmos](http://github.com/atmos)
|
38
|
+
* [indirect](http://github.com/indirect)
|
data/Rakefile
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
Bundler.
|
1
|
+
Bundler.setup(:runtime, :development, :test)
|
2
|
+
Bundler.require(:runtime, :development, :test)
|
2
3
|
|
3
4
|
require 'rake/testtask'
|
4
5
|
|
@@ -13,16 +14,16 @@ Jeweler::Tasks.new do |s|
|
|
13
14
|
s.summary = "Post error notifications to Hoptoad"
|
14
15
|
s.email = "t.lucas@toolmantim.com"
|
15
16
|
s.homepage = "http://github.com/toolmantim/toadhopper"
|
16
|
-
s.authors = ["Tim Lucas", "Samuel Tesla", "Corey Donohoe"]
|
17
|
+
s.authors = ["Tim Lucas", "Samuel Tesla", "Corey Donohoe", "Andre Arko"]
|
17
18
|
s.extra_rdoc_files = ["README.md", "LICENSE"]
|
18
19
|
s.executables = nil # stops jeweler automatically adding bin/*
|
19
|
-
|
20
|
+
|
20
21
|
require File.join(File.dirname(__FILE__), 'lib', 'toadhopper')
|
21
22
|
s.version = ToadHopper::VERSION
|
22
23
|
|
23
24
|
require 'bundler'
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
25
|
+
bundle = Bundler::Definition.from_gemfile("Gemfile")
|
26
|
+
bundle.dependencies.
|
27
|
+
select { |d| d.groups.include?(:runtime) }.
|
28
|
+
each { |d| s.add_dependency(d.name, d.version_requirements.to_s) }
|
28
29
|
end
|
data/lib/notice.haml
CHANGED
data/lib/toadhopper.rb
CHANGED
@@ -5,7 +5,7 @@ require 'nokogiri'
|
|
5
5
|
|
6
6
|
# Posts errors to the Hoptoad API
|
7
7
|
class ToadHopper
|
8
|
-
VERSION = "0.9.
|
8
|
+
VERSION = "0.9.5"
|
9
9
|
|
10
10
|
# Hoptoad API response
|
11
11
|
class Response < Struct.new(:status, :body, :errors); end
|
@@ -78,10 +78,14 @@ class ToadHopper
|
|
78
78
|
|
79
79
|
# @private
|
80
80
|
def document_for(exception, options={})
|
81
|
+
Haml::Engine.new(notice_template, :escape_html => true).render(Object.new, filtered_data(exception, options))
|
82
|
+
end
|
83
|
+
|
84
|
+
def filtered_data(exception, options)
|
81
85
|
defaults = {
|
82
86
|
:error => exception,
|
83
87
|
:api_key => api_key,
|
84
|
-
:environment =>
|
88
|
+
:environment => ENV.to_hash,
|
85
89
|
:backtrace => exception.backtrace.map {|l| backtrace_line(l)},
|
86
90
|
:url => 'http://localhost/',
|
87
91
|
:component => 'http://localhost/',
|
@@ -94,7 +98,13 @@ class ToadHopper
|
|
94
98
|
:project_root => Dir.pwd
|
95
99
|
}.merge(options)
|
96
100
|
|
97
|
-
|
101
|
+
# Filter session and environment
|
102
|
+
[:session, :environment].each{|n| defaults[n] = clean(defaults[n]) if defaults[n] }
|
103
|
+
|
104
|
+
# Filter params
|
105
|
+
defaults[:request].params = clean(defaults[:request].params) if defaults[:request] && defaults[:request].params
|
106
|
+
|
107
|
+
defaults
|
98
108
|
end
|
99
109
|
|
100
110
|
# @private
|
@@ -135,4 +145,4 @@ end
|
|
135
145
|
# @return [ToadHopper]
|
136
146
|
def ToadHopper(api_key)
|
137
147
|
ToadHopper.new(api_key)
|
138
|
-
end
|
148
|
+
end
|
data/test/helper.rb
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
-
Bundler.
|
1
|
+
Bundler.setup(:runtime, :test)
|
2
|
+
Bundler.require(:runtime, :test)
|
2
3
|
|
3
|
-
require File.
|
4
|
+
require File.expand_path("../../lib/toadhopper", __FILE__)
|
5
|
+
|
6
|
+
def toadhopper
|
7
|
+
@toadhopper ||= ToadHopper.new(ENV['HOPTOAD_API_KEY'] || "test api key")
|
8
|
+
end
|
data/test/test_filters.rb
CHANGED
@@ -1,10 +1,6 @@
|
|
1
1
|
require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
|
2
2
|
|
3
3
|
class ToadHopper::TestFilters < Test::Unit::TestCase
|
4
|
-
def toadhopper
|
5
|
-
@toadhopper ||= ToadHopper("test api key")
|
6
|
-
end
|
7
|
-
|
8
4
|
def test_no_filters
|
9
5
|
assert_equal( {:id => "myid", :password => "mypassword"},
|
10
6
|
toadhopper.clean(:id => "myid", :password => "mypassword"))
|
@@ -28,3 +24,14 @@ class ToadHopper::TestFilters < Test::Unit::TestCase
|
|
28
24
|
toadhopper.clean(:id => "myid", :email => "myemail", :password => "mypassword"))
|
29
25
|
end
|
30
26
|
end
|
27
|
+
|
28
|
+
class ToadHopper::TestCleanedOptions < Test::Unit::TestCase
|
29
|
+
def test_filtering_params
|
30
|
+
request = Struct.new(:params).new
|
31
|
+
request.params = {:password => "foo"}
|
32
|
+
error = begin; raise "Kaboom!"; rescue => e; e end
|
33
|
+
|
34
|
+
toadhopper.filters = "password"
|
35
|
+
assert_equal({:password => "[FILTERED]"}, toadhopper.filtered_data(error, :request => request)[:request].params)
|
36
|
+
end
|
37
|
+
end
|
data/test/test_posting.rb
CHANGED
@@ -2,17 +2,16 @@ require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
|
|
2
2
|
|
3
3
|
class ToadHopper::TestPosting < Test::Unit::TestCase
|
4
4
|
def test_posting
|
5
|
-
toadhopper = ToadHopper("abc123")
|
6
5
|
error = begin; raise "Kaboom!"; rescue => e; e end
|
7
6
|
|
8
|
-
response =
|
7
|
+
response = ToadHopper('bogus key').post!(error)
|
9
8
|
assert_equal 422, response.status
|
10
9
|
assert_equal ['No project exists with the given API key.'], response.errors
|
11
10
|
end
|
12
11
|
|
13
12
|
if ENV['HOPTOAD_API_KEY']
|
14
13
|
def test_posting_integration
|
15
|
-
toadhopper =
|
14
|
+
toadhopper.filters = "HOPTOAD_API_KEY", "ROOT_PASSWORD"
|
16
15
|
error = begin; raise "Kaboom!"; rescue => e; e end
|
17
16
|
|
18
17
|
response = toadhopper.post!(error)
|
metadata
CHANGED
@@ -1,17 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: toadhopper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tim Lucas
|
8
8
|
- Samuel Tesla
|
9
9
|
- Corey Donohoe
|
10
|
+
- Andre Arko
|
10
11
|
autorequire:
|
11
12
|
bindir: bin
|
12
13
|
cert_chain: []
|
13
14
|
|
14
|
-
date:
|
15
|
+
date: 2010-02-17 00:00:00 -08:00
|
15
16
|
default_executable:
|
16
17
|
dependencies:
|
17
18
|
- !ruby/object:Gem::Dependency
|
@@ -22,7 +23,7 @@ dependencies:
|
|
22
23
|
requirements:
|
23
24
|
- - ~>
|
24
25
|
- !ruby/object:Gem::Version
|
25
|
-
version:
|
26
|
+
version: 2.2.0
|
26
27
|
version:
|
27
28
|
- !ruby/object:Gem::Dependency
|
28
29
|
name: nokogiri
|