toadhopper 0.5 → 0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE +21 -0
- data/Rakefile +10 -1
- data/lib/toadhopper.rb +37 -36
- metadata +2 -4
- data/lib/toadhopper/test/methods.rb +0 -19
- data/lib/toadhopper/test.rb +0 -1
- data/test/test_test.rb +0 -12
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2009 Tim Lucas
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/Rakefile
CHANGED
@@ -10,5 +10,14 @@ begin
|
|
10
10
|
gem "sr-mg", "<= 0.0.5"
|
11
11
|
require "mg"
|
12
12
|
MG.new("toadhopper.gemspec")
|
13
|
-
rescue LoadError
|
13
|
+
rescue Gem::LoadError
|
14
|
+
end
|
15
|
+
|
16
|
+
begin
|
17
|
+
gem "yard"
|
18
|
+
require 'yard'
|
19
|
+
YARD::Rake::YardocTask.new do |t|
|
20
|
+
t.options = ['-r', 'Readme.md', '--files', 'LICENSE'] # optional
|
21
|
+
end
|
22
|
+
rescue Gem::LoadError
|
14
23
|
end
|
data/lib/toadhopper.rb
CHANGED
@@ -7,7 +7,7 @@ class << self
|
|
7
7
|
def api_key=(key)
|
8
8
|
@api_key = key
|
9
9
|
end
|
10
|
-
# Returns the key
|
10
|
+
# Returns the API key
|
11
11
|
def api_key
|
12
12
|
@api_key
|
13
13
|
end
|
@@ -17,17 +17,10 @@ class << self
|
|
17
17
|
def filters=(*filters)
|
18
18
|
@filters = filters.flatten
|
19
19
|
end
|
20
|
-
# Returns the filters
|
20
|
+
# Returns the filters
|
21
21
|
def filters
|
22
22
|
[@filters].flatten.compact
|
23
23
|
end
|
24
|
-
# Replaces the values of the keys matching Toadhopper.filters with [FILTERED]. Typically used on the params and environment hashes.
|
25
|
-
def filter(hash)
|
26
|
-
hash.inject({}) do |acc, (key, val)|
|
27
|
-
acc[key] = filters.any? {|f| key.to_s =~ Regexp.new(f)} ? "[FILTERED]" : val
|
28
|
-
acc
|
29
|
-
end
|
30
|
-
end
|
31
24
|
# Posts an error to Hoptoad
|
32
25
|
def post!(error, options={}, header_options={})
|
33
26
|
uri = URI.parse("http://hoptoadapp.com/notices/")
|
@@ -45,34 +38,42 @@ class << self
|
|
45
38
|
end
|
46
39
|
end
|
47
40
|
end
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
}.merge(options)
|
56
|
-
))
|
57
|
-
end
|
58
|
-
def stringify_keys(hash) #:nodoc:
|
59
|
-
hash.inject({}) do |h, pair|
|
60
|
-
h[pair.first.to_s] = pair.last.is_a?(Hash) ? stringify_keys(pair.last) : pair.last
|
61
|
-
h
|
41
|
+
private
|
42
|
+
# Replaces the values of the keys matching Toadhopper.filters with [FILTERED]. Typically used on the params and environment hashes.
|
43
|
+
def filter(hash)
|
44
|
+
hash.inject({}) do |acc, (key, val)|
|
45
|
+
acc[key] = filters.any? {|f| key.to_s =~ Regexp.new(f)} ? "[FILTERED]" : val
|
46
|
+
acc
|
47
|
+
end
|
62
48
|
end
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
h
|
49
|
+
def notice_params(error, options={}) # :nodoc:
|
50
|
+
clean_non_serializable_data(stringify_keys(
|
51
|
+
{
|
52
|
+
:api_key => api_key,
|
53
|
+
:error_class => error.class.name,
|
54
|
+
:error_message => error.message,
|
55
|
+
:backtrace => error.backtrace,
|
56
|
+
}.merge(options)
|
57
|
+
))
|
58
|
+
end
|
59
|
+
def stringify_keys(hash) #:nodoc:
|
60
|
+
hash.inject({}) do |h, pair|
|
61
|
+
h[pair.first.to_s] = pair.last.is_a?(Hash) ? stringify_keys(pair.last) : pair.last
|
62
|
+
h
|
63
|
+
end
|
64
|
+
end
|
65
|
+
def serializable?(value) #:nodoc:
|
66
|
+
value.is_a?(Fixnum) ||
|
67
|
+
value.is_a?(Array) ||
|
68
|
+
value.is_a?(String) ||
|
69
|
+
value.is_a?(Hash) ||
|
70
|
+
value.is_a?(Bignum)
|
71
|
+
end
|
72
|
+
def clean_non_serializable_data(data) #:nodoc:
|
73
|
+
data.select{|k,v| serializable?(v) }.inject({}) do |h, pair|
|
74
|
+
h[pair.first] = pair.last.is_a?(Hash) ? clean_non_serializable_data(pair.last) : pair.last
|
75
|
+
h
|
76
|
+
end
|
75
77
|
end
|
76
|
-
end
|
77
78
|
end
|
78
79
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: toadhopper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: "0.
|
4
|
+
version: "0.6"
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tim Lucas
|
@@ -24,13 +24,11 @@ extra_rdoc_files:
|
|
24
24
|
files:
|
25
25
|
- Readme.md
|
26
26
|
- Rakefile
|
27
|
+
- LICENSE
|
27
28
|
- lib/toadhopper.rb
|
28
|
-
- lib/toadhopper/test.rb
|
29
|
-
- lib/toadhopper/test/methods.rb
|
30
29
|
- test/test_filter.rb
|
31
30
|
- test/test_notice_params.rb
|
32
31
|
- test/test_setters.rb
|
33
|
-
- test/test_test.rb
|
34
32
|
has_rdoc: true
|
35
33
|
homepage: http://github.com/toolmantim/toadhopper
|
36
34
|
post_install_message:
|
@@ -1,19 +0,0 @@
|
|
1
|
-
require 'toadhopper'
|
2
|
-
|
3
|
-
module Toadhopper
|
4
|
-
module Test
|
5
|
-
# Helper methods for testing Toadhopper posting
|
6
|
-
module Methods
|
7
|
-
# Stub the posting of the error, storing the post params for accessing via
|
8
|
-
# last_toadhopper_post_params
|
9
|
-
def stub_toadhopper_post!
|
10
|
-
def Toadhopper.post!(*args)
|
11
|
-
Toadhopper.instance_variable_set(:@last_post_arguments, args)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
def last_toadhopper_post_arguments
|
15
|
-
Toadhopper.instance_variable_get(:@last_post_arguments)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
data/lib/toadhopper/test.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
require 'toadhopper/test/methods'
|
data/test/test_test.rb
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + "/../lib/toadhopper/test"
|
2
|
-
|
3
|
-
require 'test/unit'
|
4
|
-
|
5
|
-
class Toadhopper::TestTest < Test::Unit::TestCase
|
6
|
-
include Toadhopper::Test::Methods
|
7
|
-
def test_stub_toadhopper_post!
|
8
|
-
stub_toadhopper_post!
|
9
|
-
Toadhopper.post!(:error, :options, :header_options)
|
10
|
-
assert_equal [:error, :options, :header_options], last_toadhopper_post_arguments
|
11
|
-
end
|
12
|
-
end
|