hoptoad-api 2.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -8,7 +8,8 @@ h2. Usage
8
8
  <pre>
9
9
  <code>
10
10
  Hoptoad.account = 'myaccount'
11
- Hoptoad.token = 'abcdeghijklmnopqrstuvwxyz'
11
+ Hoptoad.auth_token = 'abcdeghijklmnopqrstuvwxyz'
12
+ Hoptoad.secure = true # if your account is SSL enabled
12
13
 
13
14
  # find an individual error:
14
15
  Hoptoad::Error.find(12345)
@@ -22,8 +23,8 @@ Hoptoad::Error.find(:all, { :page => 2 })
22
23
 
23
24
  h2. Requirements
24
25
 
25
- * ActiveResource
26
- * ActiveSupport
26
+ * HTTParty
27
+ * Hashie
27
28
 
28
29
  h2. Acknowledgements
29
30
 
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{hoptoad-api}
8
- s.version = "2.0.0"
8
+ s.version = "2.0.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Steve Agalloco"]
12
- s.date = %q{2010-04-23}
12
+ s.date = %q{2010-05-17}
13
13
  s.description = %q{An unofficial gem for interacting with the Hoptoad API}
14
14
  s.email = %q{steve.agalloco@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -33,7 +33,7 @@ Gem::Specification.new do |s|
33
33
  s.homepage = %q{http://github.com/spagalloco/hoptoad-api}
34
34
  s.rdoc_options = ["--charset=UTF-8"]
35
35
  s.require_paths = ["lib"]
36
- s.rubygems_version = %q{1.3.5}
36
+ s.rubygems_version = %q{1.3.6}
37
37
  s.summary = %q{An unofficial gem for interacting with the Hoptoad API}
38
38
  s.test_files = [
39
39
  "test/test_helper.rb",
@@ -3,6 +3,7 @@ require 'httparty'
3
3
 
4
4
  module Hoptoad
5
5
  extend self
6
+ attr_accessor :secure
6
7
 
7
8
  class HoptoadError < StandardError; end
8
9
 
@@ -11,7 +12,7 @@ module Hoptoad
11
12
  end
12
13
 
13
14
  def account
14
- "http://#{@account}.hoptoadapp.com"
15
+ "#{protocol}://#{@account}.hoptoadapp.com"
15
16
  end
16
17
 
17
18
  def auth_token=(token)
@@ -21,6 +22,11 @@ module Hoptoad
21
22
  def auth_token
22
23
  @auth_token
23
24
  end
25
+
26
+ def protocol
27
+ secure ? "https" : "http"
28
+ end
29
+
24
30
  end
25
31
 
26
32
  require 'hoptoad-api/version'
@@ -28,17 +28,8 @@ module Hoptoad
28
28
  include HTTParty
29
29
  format :xml
30
30
 
31
- # cattr_accessor :collection_path, :individual_collection_path
32
-
33
31
  @@collection_path = '/errors.xml'
34
32
  @@individual_collection_path = '/errors/'
35
-
36
- # def initialize
37
- # self.class.base_uri "http://#{account}.hoptoadapp.com"
38
- # self.class.default_params :auth_token => token
39
- #
40
- #
41
- # end
42
33
 
43
34
  def self.collection_path
44
35
  @@collection_path
@@ -58,8 +49,6 @@ module Hoptoad
58
49
  else
59
50
  raise HoptoadError.new('Invalid argument')
60
51
  end
61
-
62
- # puts results.inspect
63
52
 
64
53
  raise HoptoadError.new('No results found.') if results.nil?
65
54
  raise HoptoadError.new(results.errors.error) if results.errors
@@ -88,7 +77,9 @@ module Hoptoad
88
77
  def self.find_individual(args)
89
78
  id = args.shift
90
79
  options = args.extract_options!
91
- Hashie::Mash.new(get("#{@@individual_collection_path}#{id}.xml", { :query => options }))
80
+ hash = Hashie::Mash.new(response = get("#{@@individual_collection_path}#{id}.xml", { :query => options }))
81
+ raise HoptoadError.new('SSL should be enabled - use Hoptoad.secure = true in configuration') if response.code == 403
82
+ hash
92
83
  end
93
84
 
94
85
  end
@@ -1,3 +1,3 @@
1
1
  module Hoptoad
2
- VERSION = '2.0.0'
2
+ VERSION = '2.0.1'
3
3
  end
@@ -8,4 +8,6 @@ require File.join(File.dirname(__FILE__), "..", "lib", "hoptoad-api")
8
8
  FakeWeb.allow_net_connect = false
9
9
  FakeWeb.register_uri(:get, "http://myapp.hoptoadapp.com/errors.xml?auth_token=abcdefg123456", :response => File.join(File.dirname(__FILE__), 'fixtures', 'errors.xml'), :content_type => "application/xml; charset=utf-8", :status => ["200", "OK"])
10
10
  FakeWeb.register_uri(:get, "http://myapp.hoptoadapp.com/errors.xml?auth_token=abcdefg123456&page=2", :response => File.join(File.dirname(__FILE__), 'fixtures', 'paginated_errors.xml'), :content_type => "application/xml; charset=utf-8", :status => ["200", "OK"])
11
- FakeWeb.register_uri(:get, "http://myapp.hoptoadapp.com/errors/1696170.xml?auth_token=abcdefg123456", :response => File.join(File.dirname(__FILE__), 'fixtures', 'individual_error.xml'), :content_type => "application/xml; charset=utf-8", :status => ["200", "OK"])
11
+ FakeWeb.register_uri(:get, "http://myapp.hoptoadapp.com/errors/1696170.xml?auth_token=abcdefg123456", :response => File.join(File.dirname(__FILE__), 'fixtures', 'individual_error.xml'), :content_type => "application/xml; charset=utf-8", :status => ["200", "OK"])
12
+ FakeWeb.register_uri(:get, "http://sslapp.hoptoadapp.com/errors/1696170.xml?auth_token=abcdefg123456", :body => " ", :content_type => "application/xml; charset=utf-8", :status => ["403", "Forbidden"])
13
+ FakeWeb.register_uri(:get, "https://sslapp.hoptoadapp.com/errors/1696170.xml?auth_token=abcdefg123456", :response => File.join(File.dirname(__FILE__), 'fixtures', 'individual_error.xml'), :content_type => "application/xml; charset=utf-8", :status => ["200", "OK"])
@@ -6,12 +6,13 @@ class HoptoadTest < Test::Unit::TestCase
6
6
  setup do
7
7
  Hoptoad.account = 'myapp'
8
8
  Hoptoad.auth_token = 'abcdefg123456'
9
+ Hoptoad.secure = false
9
10
  end
10
11
 
11
12
  should "have correct collection path" do
12
13
  assert_equal "/errors.xml", Hoptoad::Error.collection_path
13
14
  end
14
-
15
+
15
16
  should "find a page of the 30 most recent errors" do
16
17
  errors = Hoptoad::Error.find(:all)
17
18
  ordered = errors.sort_by(&:most_recent_notice_at).reverse
@@ -31,6 +32,22 @@ class HoptoadTest < Test::Unit::TestCase
31
32
  assert_equal error.action, 'index'
32
33
  assert_equal error.id, 1696170
33
34
  end
35
+
36
+ should "find an error if account is SSL enabled" do
37
+ Hoptoad.secure = true
38
+ Hoptoad.account = "sslapp"
39
+ error = Hoptoad::Error.find(1696170)
40
+ assert_equal error.id, 1696170
41
+ end
42
+
43
+ should "raise exception if trying to access SSL enabled account with unsecure connection" do
44
+ Hoptoad.account = "sslapp"
45
+ Hoptoad.secure = false
46
+ assert_raise(Hoptoad::HoptoadError) do
47
+ error = Hoptoad::Error.find(1696170)
48
+ end
49
+ end
50
+
34
51
  end
35
52
 
36
53
  end
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hoptoad-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ prerelease: false
5
+ segments:
6
+ - 2
7
+ - 0
8
+ - 1
9
+ version: 2.0.1
5
10
  platform: ruby
6
11
  authors:
7
12
  - Steve Agalloco
@@ -9,49 +14,61 @@ autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2010-04-23 00:00:00 -04:00
17
+ date: 2010-05-17 00:00:00 -04:00
13
18
  default_executable:
14
19
  dependencies:
15
20
  - !ruby/object:Gem::Dependency
16
21
  name: httparty
17
- type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
20
24
  requirements:
21
25
  - - ">="
22
26
  - !ruby/object:Gem::Version
27
+ segments:
28
+ - 0
29
+ - 5
30
+ - 2
23
31
  version: 0.5.2
24
- version:
32
+ type: :runtime
33
+ version_requirements: *id001
25
34
  - !ruby/object:Gem::Dependency
26
35
  name: hashie
27
- type: :runtime
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
36
+ prerelease: false
37
+ requirement: &id002 !ruby/object:Gem::Requirement
30
38
  requirements:
31
39
  - - ">="
32
40
  - !ruby/object:Gem::Version
41
+ segments:
42
+ - 0
43
+ - 2
44
+ - 0
33
45
  version: 0.2.0
34
- version:
46
+ type: :runtime
47
+ version_requirements: *id002
35
48
  - !ruby/object:Gem::Dependency
36
49
  name: shoulda
37
- type: :development
38
- version_requirement:
39
- version_requirements: !ruby/object:Gem::Requirement
50
+ prerelease: false
51
+ requirement: &id003 !ruby/object:Gem::Requirement
40
52
  requirements:
41
53
  - - ">="
42
54
  - !ruby/object:Gem::Version
55
+ segments:
56
+ - 0
43
57
  version: "0"
44
- version:
58
+ type: :development
59
+ version_requirements: *id003
45
60
  - !ruby/object:Gem::Dependency
46
61
  name: fakeweb
47
- type: :development
48
- version_requirement:
49
- version_requirements: !ruby/object:Gem::Requirement
62
+ prerelease: false
63
+ requirement: &id004 !ruby/object:Gem::Requirement
50
64
  requirements:
51
65
  - - ">="
52
66
  - !ruby/object:Gem::Version
67
+ segments:
68
+ - 0
53
69
  version: "0"
54
- version:
70
+ type: :development
71
+ version_requirements: *id004
55
72
  description: An unofficial gem for interacting with the Hoptoad API
56
73
  email: steve.agalloco@gmail.com
57
74
  executables: []
@@ -87,18 +104,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
87
104
  requirements:
88
105
  - - ">="
89
106
  - !ruby/object:Gem::Version
107
+ segments:
108
+ - 0
90
109
  version: "0"
91
- version:
92
110
  required_rubygems_version: !ruby/object:Gem::Requirement
93
111
  requirements:
94
112
  - - ">="
95
113
  - !ruby/object:Gem::Version
114
+ segments:
115
+ - 0
96
116
  version: "0"
97
- version:
98
117
  requirements: []
99
118
 
100
119
  rubyforge_project:
101
- rubygems_version: 1.3.5
120
+ rubygems_version: 1.3.6
102
121
  signing_key:
103
122
  specification_version: 3
104
123
  summary: An unofficial gem for interacting with the Hoptoad API