toadhopper 0.9.8 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +1 -1
- data/Rakefile +1 -1
- data/lib/toadhopper.rb +9 -9
- data/test/helper.rb +1 -1
- data/test/test_filters.rb +1 -1
- data/test/test_notice_document_data.rb +1 -1
- data/test/test_posting.rb +2 -2
- metadata +1 -1
data/README.md
CHANGED
data/Rakefile
CHANGED
@@ -19,7 +19,7 @@ Jeweler::Tasks.new do |s|
|
|
19
19
|
s.executables = nil # stops jeweler automatically adding bin/*
|
20
20
|
|
21
21
|
require File.join(File.dirname(__FILE__), 'lib', 'toadhopper')
|
22
|
-
s.version =
|
22
|
+
s.version = Toadhopper::VERSION
|
23
23
|
|
24
24
|
require 'bundler'
|
25
25
|
bundle = Bundler::Definition.from_gemfile("Gemfile")
|
data/lib/toadhopper.rb
CHANGED
@@ -3,8 +3,8 @@ require 'erb'
|
|
3
3
|
require 'ostruct'
|
4
4
|
|
5
5
|
# Posts errors to the Hoptoad API
|
6
|
-
class
|
7
|
-
VERSION = "0.
|
6
|
+
class Toadhopper
|
7
|
+
VERSION = "1.0.0"
|
8
8
|
|
9
9
|
# Hoptoad API response
|
10
10
|
class Response < Struct.new(:status, :body, :errors); end
|
@@ -34,7 +34,7 @@ class ToadHopper
|
|
34
34
|
# @option options [String] component Normally this is your Controller name in an MVC framework
|
35
35
|
# @option options [String] action Normally the action for your request in an MVC framework
|
36
36
|
# @option options [Hash] params A hash of the request's parameters
|
37
|
-
# @option options [String] notifier_name Say you're a different notifier than
|
37
|
+
# @option options [String] notifier_name Say you're a different notifier than Toadhopper
|
38
38
|
# @option options [String] notifier_version Specify the version of your custom notifier
|
39
39
|
# @option options [String] notifier_url Specify the project URL of your custom notifier
|
40
40
|
# @option options [Hash] session A hash of the user session in a web request
|
@@ -46,13 +46,13 @@ class ToadHopper
|
|
46
46
|
# @param [Hash] http_headers extra HTTP headers to be sent in the post to the API
|
47
47
|
#
|
48
48
|
# @example
|
49
|
-
#
|
49
|
+
# Toadhopper('apikey').post! error,
|
50
50
|
# {:action => 'show', :controller => 'Users'},
|
51
51
|
# {'X-Hoptoad-Client-Name' => 'My Awesome Notifier'}
|
52
52
|
#
|
53
53
|
# @return [Response]
|
54
54
|
def post!(error, options={}, http_headers={})
|
55
|
-
options[:notifier_name] ||= '
|
55
|
+
options[:notifier_name] ||= 'Toadhopper'
|
56
56
|
post_document(document_for(error, options), {'X-Hoptoad-Client-Name' => options[:notifier_name]})
|
57
57
|
end
|
58
58
|
|
@@ -140,9 +140,9 @@ class ToadHopper
|
|
140
140
|
end
|
141
141
|
end
|
142
142
|
|
143
|
-
# Convenience method for creating
|
143
|
+
# Convenience method for creating Toadhoppers
|
144
144
|
#
|
145
|
-
# @return [
|
146
|
-
def
|
147
|
-
|
145
|
+
# @return [Toadhopper]
|
146
|
+
def Toadhopper(api_key)
|
147
|
+
Toadhopper.new(api_key)
|
148
148
|
end
|
data/test/helper.rb
CHANGED
@@ -4,7 +4,7 @@ Bundler.require(:test)
|
|
4
4
|
require File.expand_path("../../lib/toadhopper", __FILE__)
|
5
5
|
|
6
6
|
def toadhopper
|
7
|
-
@toadhopper ||=
|
7
|
+
@toadhopper ||= Toadhopper.new(ENV['HOPTOAD_API_KEY'] || "test api key")
|
8
8
|
end
|
9
9
|
|
10
10
|
def error
|
data/test/test_filters.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
|
2
2
|
|
3
|
-
class
|
3
|
+
class Toadhopper::TestFilters < Test::Unit::TestCase
|
4
4
|
def test_no_filters
|
5
5
|
assert_equal( {:id => "myid", :password => "mypassword"},
|
6
6
|
toadhopper.clean(:id => "myid", :password => "mypassword"))
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
|
2
2
|
|
3
|
-
class
|
3
|
+
class Toadhopper::TestNoticeDocument < Test::Unit::TestCase
|
4
4
|
def test_filtering
|
5
5
|
toadhopper.filters = "password"
|
6
6
|
sensitive_options = {
|
data/test/test_posting.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
|
2
2
|
|
3
|
-
class
|
3
|
+
class Toadhopper::TestPosting < Test::Unit::TestCase
|
4
4
|
def test_posting
|
5
|
-
response =
|
5
|
+
response = Toadhopper('bogus key').post!(error)
|
6
6
|
assert_equal 422, response.status
|
7
7
|
assert_equal ['No project exists with the given API key.'], response.errors
|
8
8
|
end
|