hoptoad-api 2.2.0 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,6 @@
1
+ *.sw?
2
+ .DS_Store
3
+ coverage
4
+ *.gem
5
+ pkg/*
6
+ Gemfile.lock
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ --format=nested
3
+ --backtrace
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source "http://rubygems.org"
2
+ gemspec
@@ -0,0 +1,70 @@
1
+ Hoptoad API
2
+ ===========
3
+
4
+ An unofficial Ruby library for interacting with the [Hoptoad API](http://hoptoadapp.com/pages/api)
5
+
6
+ Usage
7
+ -----
8
+
9
+ The first thing you need to set is the account name. This is the same as the web address for your account.
10
+
11
+ Hoptoad.account = 'myaccount'
12
+
13
+ Then, you should set the authentication token.
14
+
15
+ Hoptoad.auth_token = 'abcdefg'
16
+
17
+ If your account uses ssl then turn it on:
18
+
19
+ Hoptoad.secure = true
20
+
21
+ Optionally, you can configure through a single method:
22
+
23
+ Hoptoad.configure(:account => 'anapp', :auth_token => 'abcdefg', :secure => true)
24
+
25
+ Once you've configured authentication, you can make calls against the API. If no token or authentication is given, a HoptoadError exception will be raised.
26
+
27
+ Finding Errors
28
+ --------------
29
+
30
+ Errors are paginated, the API responds with 25 at a time, pass an optional params hash for additional pages:
31
+
32
+ Hoptoad::Error.find(:all)
33
+ Hoptoad::Error.find(:all, :params => { :page => 2 })
34
+
35
+ To find an individual error, you can find by ID:
36
+
37
+ Hoptoad::Error.find(error_id)
38
+
39
+ Find *all* notices of an error:
40
+
41
+ Hoptoad::Notice.all(error_id)
42
+
43
+ Find an individual notice:
44
+
45
+ Hoptoad::Notice.find(notice_id, error_id)
46
+
47
+ Projects
48
+ --------
49
+
50
+ To retrieve a list of projects:
51
+
52
+ Hoptoad::Project.find(:all)
53
+
54
+ Responses
55
+ ---------
56
+
57
+ If an error is returned from the API. A HoptoadError will be raised. Successful responses will return a Hashie::Mash object based on the data from the response.
58
+
59
+
60
+ Requirements
61
+ ------------
62
+
63
+ * HTTParty
64
+ * Hashie
65
+
66
+ Contributors
67
+ ------------
68
+
69
+ * Matias Käkelä (SSL Support)
70
+ * Jordan Brough (Notices)
data/Rakefile CHANGED
@@ -1,32 +1,19 @@
1
- require 'rake'
2
1
  require 'bundler'
3
2
  Bundler::GemHelper.install_tasks
4
3
 
5
- $:.unshift 'lib'
6
- require 'hoptoad-api/version'
4
+ require 'rspec/core/rake_task'
5
+ RSpec::Core::RakeTask.new(:spec)
7
6
 
8
- require 'rake/testtask'
9
- Rake::TestTask.new(:test) do |test|
10
- test.libs << 'lib' << 'test'
11
- test.pattern = 'test/**/test_*.rb'
12
- test.verbose = true
13
- end
7
+ task :default => :spec
14
8
 
15
- require 'rcov/rcovtask'
16
- Rcov::RcovTask.new do |test|
17
- test.libs << 'test'
18
- test.pattern = 'test/**/test_*.rb'
19
- test.verbose = true
20
- end
21
-
22
- require 'rake/rdoctask'
23
- Rake::RDocTask.new do |rdoc|
24
- version = Hoptoad::VERSION
25
-
26
- rdoc.rdoc_dir = 'rdoc'
27
- rdoc.title = "hoptoad-api #{version}"
28
- rdoc.rdoc_files.include('README*')
29
- rdoc.rdoc_files.include('lib/**/*.rb')
30
- end
31
-
32
- task :default => :test
9
+ namespace :doc do
10
+ require 'yard'
11
+ YARD::Rake::YardocTask.new do |task|
12
+ task.files = ['lib/**/*.rb']
13
+ task.options = [
14
+ '--protected',
15
+ '--output-dir', 'doc/yard',
16
+ '--markup', 'markdown',
17
+ ]
18
+ end
19
+ end
@@ -0,0 +1,33 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "hoptoad-api/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = 'hoptoad-api'
7
+ s.version = Hoptoad::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+
10
+ s.summary = "Hoptoad API"
11
+ s.description = "An unofficial gem for interacting with the Hoptoad API"
12
+
13
+ s.authors = ['Steve Agalloco']
14
+ s.email = ['steve.agalloco@gmail.com']
15
+ s.homepage = 'http://github.com/spagalloco/hoptoad-api'
16
+
17
+ s.add_dependency(%q<httparty>, [">= 0.5.2"])
18
+ s.add_dependency(%q<hashie>, [">= 0.2.0"])
19
+
20
+ s.add_development_dependency('bundler', '~> 1.0')
21
+ s.add_development_dependency('rake', '~> 0.8')
22
+ s.add_development_dependency('rspec', '~> 2.5.0')
23
+ s.add_development_dependency('yard', '~> 0.6')
24
+ s.add_development_dependency('maruku', '~> 0.6')
25
+ s.add_development_dependency('simplecov', '~> 0.3')
26
+ s.add_development_dependency('fakeweb', '~> 1.3.0')
27
+
28
+ # ensure the gem is built out of versioned files
29
+ s.files = `git ls-files`.split("\n")
30
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
31
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
32
+ s.require_paths = ["lib"]
33
+ end
@@ -23,6 +23,8 @@ module Hoptoad
23
23
 
24
24
  end
25
25
 
26
- require 'hoptoad-api/version'
27
26
  require 'hoptoad-api/core_extensions'
28
- require 'hoptoad-api/client'
27
+ require 'hoptoad-api/client'
28
+ require 'hoptoad-api/error'
29
+ require 'hoptoad-api/notice'
30
+ require 'hoptoad-api/project'
@@ -1,40 +1,3 @@
1
- # Ruby lib for working with the Hoptoad API's XML interface.
2
- # The first thing you need to set is the account name. This is the same
3
- # as the web address for your account.
4
- #
5
- # Hoptoad.account = 'myaccount'
6
- #
7
- # Then, you should set the authentication token.
8
- #
9
- # Hoptoad.auth_token = 'abcdefg'
10
- #
11
- # If no token or authentication info is given, a HoptoadError exception will be raised.
12
- #
13
- # If your account uses ssl then turn it on:
14
- #
15
- # Hoptoad.secure = true
16
- #
17
- # For more details, check out the hoptoad docs at http://hoptoadapp.com/pages/api.
18
- #
19
- # Find errors
20
- #
21
- # Errors are paginated. You get 25 at a time.
22
- # errors = Hoptoad::Error.find(:all)
23
- #
24
- # with pagination:
25
- # Hoptoad::Error.find(:all, :params => { :page => 2 })
26
- #
27
- # find individual error by ID
28
- # Hoptoad::Error.find(44)
29
- #
30
- # Find *all* notices by error_id
31
- #
32
- # notices = Hoptoad::Notice.all(1234) # 1234 == error id
33
- #
34
- # Find notice by id + error_id
35
- #
36
- # notice = Hoptoad::Notice.find(12345, 1234) # 12345 == notice id, 1234 == error id
37
-
38
1
  module Hoptoad
39
2
  class Base
40
3
  include HTTParty
@@ -64,114 +27,4 @@ module Hoptoad
64
27
  end
65
28
 
66
29
  end
67
-
68
- class Error < Base
69
-
70
- def self.find(*args)
71
- setup
72
-
73
- results = case args.first
74
- when Fixnum
75
- find_individual(args)
76
- when :all
77
- find_all(args)
78
- else
79
- raise HoptoadError.new('Invalid argument')
80
- end
81
-
82
- raise HoptoadError.new('No results found.') if results.nil?
83
- raise HoptoadError.new(results.errors.error) if results.errors
84
-
85
- results.group || results.groups
86
- end
87
-
88
- def self.update(error, options)
89
- setup
90
-
91
- self.class.put(collection_path, options)
92
- end
93
-
94
- private
95
-
96
- def self.find_all(args)
97
- options = args.extract_options!
98
-
99
- fetch(collection_path, options)
100
- end
101
-
102
- def self.find_individual(args)
103
- id = args.shift
104
- options = args.extract_options!
105
-
106
- fetch(error_path(id), options)
107
- end
108
-
109
- def self.collection_path
110
- '/errors.xml'
111
- end
112
-
113
- def self.error_path(error_id)
114
- "/errors/#{error_id}.xml"
115
- end
116
-
117
- end
118
-
119
- class Notice < Base
120
-
121
- def self.find(id, error_id, options={})
122
- setup
123
-
124
- hash = fetch(find_path(id, error_id), options)
125
-
126
- if hash.errors
127
- raise HoptoadError.new(results.errors.error)
128
- end
129
-
130
- hash.notice
131
- end
132
-
133
- def self.find_all_by_error_id(error_id)
134
- setup
135
-
136
- options = {}
137
- notices = []
138
- page = 1
139
- while true
140
- options[:page] = page
141
- hash = fetch(all_path(error_id), options)
142
- if hash.errors
143
- raise HoptoadError.new(results.errors.error)
144
- end
145
- notice_stubs = hash.notices
146
-
147
- notice_stubs.map do |notice|
148
- notices << find(notice.id, error_id)
149
- end
150
- break if notice_stubs.size < 30
151
- page += 1
152
- end
153
- notices
154
- end
155
-
156
- def self.find_by_error_id(error_id, options={ 'page' => 1})
157
- setup
158
-
159
- hash = fetch(all_path(error_id), options)
160
- if hash.errors
161
- raise HoptoadError.new(results.errors.error)
162
- end
163
-
164
- hash.notices
165
- end
166
-
167
- private
168
-
169
- def self.find_path(id, error_id)
170
- "/errors/#{error_id}/notices/#{id}.xml"
171
- end
172
-
173
- def self.all_path(error_id)
174
- "/errors/#{error_id}/notices.xml"
175
- end
176
- end
177
30
  end
@@ -0,0 +1,52 @@
1
+ module Hoptoad
2
+ class Error < Hoptoad::Base
3
+
4
+ def self.find(*args)
5
+ setup
6
+
7
+ results = case args.first
8
+ when Fixnum
9
+ find_individual(args)
10
+ when :all
11
+ find_all(args)
12
+ else
13
+ raise HoptoadError.new('Invalid argument')
14
+ end
15
+
16
+ raise HoptoadError.new('No results found.') if results.nil?
17
+ raise HoptoadError.new(results.errors.error) if results.errors
18
+
19
+ results.group || results.groups
20
+ end
21
+
22
+ def self.update(error, options)
23
+ setup
24
+
25
+ self.class.put(collection_path, options)
26
+ end
27
+
28
+ private
29
+
30
+ def self.find_all(args)
31
+ options = args.extract_options!
32
+
33
+ fetch(collection_path, options)
34
+ end
35
+
36
+ def self.find_individual(args)
37
+ id = args.shift
38
+ options = args.extract_options!
39
+
40
+ fetch(error_path(id), options)
41
+ end
42
+
43
+ def self.collection_path
44
+ '/errors.xml'
45
+ end
46
+
47
+ def self.error_path(error_id)
48
+ "/errors/#{error_id}.xml"
49
+ end
50
+
51
+ end
52
+ end
@@ -0,0 +1,60 @@
1
+ module Hoptoad
2
+ class Notice < Hoptoad::Base
3
+
4
+ def self.find(id, error_id, options={})
5
+ setup
6
+
7
+ hash = fetch(find_path(id, error_id), options)
8
+
9
+ if hash.errors
10
+ raise HoptoadError.new(results.errors.error)
11
+ end
12
+
13
+ hash.notice
14
+ end
15
+
16
+ def self.find_all_by_error_id(error_id, notice_options = {})
17
+ setup
18
+
19
+ options = {}
20
+ notices = []
21
+ page = 1
22
+ while !notice_options[:pages] || page <= notice_options[:pages]
23
+ options[:page] = page
24
+ hash = fetch(all_path(error_id), options)
25
+ if hash.errors
26
+ raise HoptoadError.new(results.errors.error)
27
+ end
28
+ notice_stubs = hash.notices
29
+
30
+ notice_stubs.map do |notice|
31
+ notices << find(notice.id, error_id)
32
+ end
33
+ break if notice_stubs.size < 30
34
+ page += 1
35
+ end
36
+ notices
37
+ end
38
+
39
+ def self.find_by_error_id(error_id, options={ 'page' => 1})
40
+ setup
41
+
42
+ hash = fetch(all_path(error_id), options)
43
+ if hash.errors
44
+ raise HoptoadError.new(results.errors.error)
45
+ end
46
+
47
+ hash.notices
48
+ end
49
+
50
+ private
51
+
52
+ def self.find_path(id, error_id)
53
+ "/errors/#{error_id}/notices/#{id}.xml"
54
+ end
55
+
56
+ def self.all_path(error_id)
57
+ "/errors/#{error_id}/notices.xml"
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,19 @@
1
+ module Hoptoad
2
+ class Project < Hoptoad::Base
3
+
4
+ def self.find(*args)
5
+ setup
6
+ options = args.extract_options!
7
+
8
+ results = fetch(collection_path, options)
9
+
10
+ raise HoptoadError.new(results.errors.error) if results.errors
11
+ results.projects.project
12
+ end
13
+
14
+ def self.collection_path
15
+ '/data_api/v1/projects.xml'
16
+ end
17
+
18
+ end
19
+ end
@@ -1,3 +1,3 @@
1
1
  module Hoptoad
2
- VERSION = '2.2.0'
2
+ VERSION = '2.3.0'
3
3
  end
File without changes
File without changes
@@ -0,0 +1,25 @@
1
+ HTTP/1.1 200 OK
2
+
3
+ <?xml version="1.0" encoding="UTF-8"?>
4
+ <projects>
5
+ <project>
6
+ <id>1</id>
7
+ <name>Venkman</name>
8
+ <api-key>c3bb6f719742fd1e5768d6d1361cfb49</api-key>
9
+ </project>
10
+ <project>
11
+ <id>2</id>
12
+ <name>Stantz</name>
13
+ <api-key>fda6ef9f6ba8382c875468cd70d33ecf</api-key>
14
+ </project>
15
+ <project>
16
+ <id>3</id>
17
+ <name>Spengler</name>
18
+ <api-key>2430242dc52b9fec75095457ac808899</api-key>
19
+ </project>
20
+ <project>
21
+ <id>4</id>
22
+ <name>Zeddemore</name>
23
+ <api-key>051d21b089e532e4bcce2fe1e7fb0e0b</api-key>
24
+ </project>
25
+ </projects>
@@ -0,0 +1,44 @@
1
+ require 'spec_helper'
2
+
3
+ describe Hoptoad::Error do
4
+ before(:all) do
5
+ Hoptoad.account = 'myapp'
6
+ Hoptoad.auth_token = 'abcdefg123456'
7
+ Hoptoad.secure = false
8
+ end
9
+
10
+ it "should have correct collection path" do
11
+ Hoptoad::Error.collection_path.should == "/errors.xml"
12
+ end
13
+
14
+ it "should generate correct error path given an id" do
15
+ Hoptoad::Error.error_path(1234).should == "/errors/1234.xml"
16
+ end
17
+
18
+ it "should find a page of the 30 most recent errors" do
19
+ errors = Hoptoad::Error.find(:all)
20
+ ordered = errors.sort_by(&:most_recent_notice_at).reverse
21
+ ordered.should == errors
22
+ errors.size.should == 30
23
+ end
24
+
25
+ it "should paginate errors" do
26
+ errors = Hoptoad::Error.find(:all, :page => 2)
27
+ ordered = errors.sort_by(&:most_recent_notice_at).reverse
28
+ ordered.should == errors
29
+ errors.size.should == 2
30
+ end
31
+
32
+ it "should find an individual error" do
33
+ error = Hoptoad::Error.find(1696170)
34
+ error.action.should == 'index'
35
+ error.id.should == 1696170
36
+ end
37
+
38
+ it "should raise an error when not passed an id" do
39
+ lambda do
40
+ Hoptoad::Error.find
41
+ end.should raise_error(Hoptoad::HoptoadError)
42
+ end
43
+
44
+ end
@@ -0,0 +1,30 @@
1
+ require 'spec_helper'
2
+
3
+ describe Hoptoad::Notice do
4
+ before(:all) do
5
+ Hoptoad.account = 'myapp'
6
+ Hoptoad.auth_token = 'abcdefg123456'
7
+ Hoptoad.secure = false
8
+ end
9
+
10
+ it "should find error notices" do
11
+ notices = Hoptoad::Notice.find_by_error_id(1696170)
12
+ notices.size.should == 30
13
+ notices.first.id.should == 1234
14
+ end
15
+
16
+ it "should find all error notices" do
17
+ notices = Hoptoad::Notice.find_all_by_error_id(1696170)
18
+ notices.size.should == 42
19
+ end
20
+
21
+ it "should find all error notices with a page limit" do
22
+ notices = Hoptoad::Notice.find_all_by_error_id(1696171, :pages => 2)
23
+ notices.size.should == 60
24
+ end
25
+
26
+ it "should find individual notices" do
27
+ Hoptoad::Notice.find(1234, 1696170)
28
+ end
29
+
30
+ end
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+
3
+ describe Hoptoad::Project do
4
+ before(:all) do
5
+ Hoptoad.account = 'myapp'
6
+ Hoptoad.auth_token = 'abcdefg123456'
7
+ Hoptoad.secure = false
8
+ end
9
+
10
+ it "should have correct projects path" do
11
+ Hoptoad::Project.collection_path.should == "/data_api/v1/projects.xml"
12
+ end
13
+
14
+ it "should find projects" do
15
+ projects = Hoptoad::Project.find(:all)
16
+ projects.size.should == 4
17
+ projects.first.id.should == '1'
18
+ projects.first.name.should == 'Venkman'
19
+ end
20
+
21
+ end
@@ -0,0 +1,59 @@
1
+ require 'spec_helper'
2
+
3
+ describe Hoptoad do
4
+
5
+ context "configuration" do
6
+ before(:each) do
7
+ Hoptoad.account = nil
8
+ Hoptoad.auth_token = nil
9
+ Hoptoad.secure = false
10
+ end
11
+
12
+ it "should allow setting of the account" do
13
+ Hoptoad.account = 'myapp'
14
+ Hoptoad.account.should == 'myapp'
15
+ Hoptoad.account_path.should == 'http://myapp.hoptoadapp.com'
16
+ end
17
+
18
+ it "should allow setting of the auth token" do
19
+ Hoptoad.auth_token = '123456'
20
+ Hoptoad.auth_token.should == '123456'
21
+ end
22
+
23
+ it "should allow setting of ssl protocol" do
24
+ Hoptoad.secure = true
25
+ Hoptoad.protocol.should == 'https'
26
+ end
27
+
28
+ it "should default to standard http" do
29
+ Hoptoad.protocol.should == 'http'
30
+ end
31
+
32
+ it "should should implement #configure" do
33
+ Hoptoad.configure(:account => 'anapp', :auth_token => 'abcdefg', :secure => true)
34
+ Hoptoad.protocol.should == 'https'
35
+ Hoptoad.auth_token.should == 'abcdefg'
36
+ Hoptoad.account.should == 'anapp'
37
+ Hoptoad.account_path.should == 'https://anapp.hoptoadapp.com'
38
+ end
39
+ end
40
+
41
+ context "when using SSL" do
42
+ before(:each) do
43
+ Hoptoad.configure(:account => 'sslapp', :auth_token => 'abcdefg123456', :secure => true)
44
+ end
45
+
46
+ it "should find an error if account is SSL enabled" do
47
+ error = Hoptoad::Error.find(1696170)
48
+ error.id.should == 1696170
49
+ end
50
+
51
+ it "should raise an exception if trying to access SSL enabled account with unsecure connection" do
52
+ Hoptoad.secure = false
53
+ lambda do
54
+ Hoptoad::Error.find(1696170)
55
+ end.should raise_error(Hoptoad::HoptoadError)
56
+ end
57
+ end
58
+
59
+ end
@@ -1,24 +1,36 @@
1
- require 'rubygems'
2
- require 'test/unit'
3
- require 'shoulda'
4
- require 'fakeweb'
1
+ require 'simplecov'
2
+ SimpleCov.start do
3
+ add_group 'Hoptoad API', 'lib/hoptoad-api'
4
+ add_group 'Specs', 'spec'
5
+ end
6
+
7
+ require File.expand_path('../../lib/hoptoad-api', __FILE__)
5
8
 
6
- require File.join(File.dirname(__FILE__), "..", "lib", "hoptoad-api")
9
+ require 'rspec'
10
+ require 'fakeweb'
7
11
 
8
12
  FakeWeb.allow_net_connect = false
9
13
 
10
- # error responses
14
+ # errors
11
15
  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"])
12
16
  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"])
13
17
  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"])
14
18
 
15
- # notice responses
19
+ # notices
16
20
  FakeWeb.register_uri(:get, "http://myapp.hoptoadapp.com/errors/1696170/notices.xml?auth_token=abcdefg123456", :response => File.join(File.dirname(__FILE__), 'fixtures', 'notices.xml'), :content_type => "application/xml; charset=utf-8", :status => ["200", "OK"])
17
21
  FakeWeb.register_uri(:get, "http://myapp.hoptoadapp.com/errors/1696170/notices.xml?auth_token=abcdefg123456&page=1", :response => File.join(File.dirname(__FILE__), 'fixtures', 'notices.xml'), :content_type => "application/xml; charset=utf-8", :status => ["200", "OK"])
18
22
  FakeWeb.register_uri(:get, "http://myapp.hoptoadapp.com/errors/1696170/notices.xml?page=1&auth_token=abcdefg123456", :response => File.join(File.dirname(__FILE__), 'fixtures', 'notices.xml'), :content_type => "application/xml; charset=utf-8", :status => ["200", "OK"])
19
23
  FakeWeb.register_uri(:get, "http://myapp.hoptoadapp.com/errors/1696170/notices.xml?auth_token=abcdefg123456&page=2", :response => File.join(File.dirname(__FILE__), 'fixtures', 'paginated_notices.xml'), :content_type => "application/xml; charset=utf-8", :status => ["200", "OK"])
20
24
  FakeWeb.register_uri(:get, "http://myapp.hoptoadapp.com/errors/1696170/notices/1234.xml?auth_token=abcdefg123456", :response => File.join(File.dirname(__FILE__), 'fixtures', 'notices.xml'), :content_type => "application/xml; charset=utf-8", :status => ["200", "OK"])
25
+ FakeWeb.register_uri(:get, "http://myapp.hoptoadapp.com/errors/1696171/notices.xml?auth_token=abcdefg123456", :response => File.join(File.dirname(__FILE__), 'fixtures', 'notices.xml'), :content_type => "application/xml; charset=utf-8", :status => ["200", "OK"])
26
+ FakeWeb.register_uri(:get, "http://myapp.hoptoadapp.com/errors/1696171/notices.xml?auth_token=abcdefg123456&page=1", :response => File.join(File.dirname(__FILE__), 'fixtures', 'notices.xml'), :content_type => "application/xml; charset=utf-8", :status => ["200", "OK"])
27
+ FakeWeb.register_uri(:get, "http://myapp.hoptoadapp.com/errors/1696171/notices.xml?auth_token=abcdefg123456&page=2", :response => File.join(File.dirname(__FILE__), 'fixtures', 'notices.xml'), :content_type => "application/xml; charset=utf-8", :status => ["200", "OK"])
28
+ FakeWeb.register_uri(:get, "http://myapp.hoptoadapp.com/errors/1696171/notices.xml?auth_token=abcdefg123456&page=3", :response => File.join(File.dirname(__FILE__), 'fixtures', 'paginated_notices.xml'), :content_type => "application/xml; charset=utf-8", :status => ["200", "OK"])
29
+ FakeWeb.register_uri(:get, "http://myapp.hoptoadapp.com/errors/1696171/notices/1234.xml?auth_token=abcdefg123456", :response => File.join(File.dirname(__FILE__), 'fixtures', 'notices.xml'), :content_type => "application/xml; charset=utf-8", :status => ["200", "OK"])
30
+
21
31
 
32
+ # projects
33
+ FakeWeb.register_uri(:get, "http://myapp.hoptoadapp.com/data_api/v1/projects.xml?auth_token=abcdefg123456", :response => File.join(File.dirname(__FILE__), 'fixtures', 'projects.xml'), :content_type => "application/xml; charset=utf-8", :status => ["200", "OK"])
22
34
 
23
35
  # ssl responses
24
36
  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"])
metadata CHANGED
@@ -1,13 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hoptoad-api
3
3
  version: !ruby/object:Gem::Version
4
- hash: 7
5
- prerelease: false
6
- segments:
7
- - 2
8
- - 2
9
- - 0
10
- version: 2.2.0
4
+ prerelease:
5
+ version: 2.3.0
11
6
  platform: ruby
12
7
  authors:
13
8
  - Steve Agalloco
@@ -15,7 +10,7 @@ autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
12
 
18
- date: 2010-11-06 00:00:00 -04:00
13
+ date: 2011-03-13 00:00:00 -05:00
19
14
  default_executable:
20
15
  dependencies:
21
16
  - !ruby/object:Gem::Dependency
@@ -26,11 +21,6 @@ dependencies:
26
21
  requirements:
27
22
  - - ">="
28
23
  - !ruby/object:Gem::Version
29
- hash: 15
30
- segments:
31
- - 0
32
- - 5
33
- - 2
34
24
  version: 0.5.2
35
25
  type: :runtime
36
26
  version_requirements: *id001
@@ -42,44 +32,89 @@ dependencies:
42
32
  requirements:
43
33
  - - ">="
44
34
  - !ruby/object:Gem::Version
45
- hash: 23
46
- segments:
47
- - 0
48
- - 2
49
- - 0
50
35
  version: 0.2.0
51
36
  type: :runtime
52
37
  version_requirements: *id002
53
38
  - !ruby/object:Gem::Dependency
54
- name: shoulda
39
+ name: bundler
55
40
  prerelease: false
56
41
  requirement: &id003 !ruby/object:Gem::Requirement
57
42
  none: false
58
43
  requirements:
59
- - - ">="
44
+ - - ~>
60
45
  - !ruby/object:Gem::Version
61
- hash: 3
62
- segments:
63
- - 0
64
- version: "0"
46
+ version: "1.0"
65
47
  type: :development
66
48
  version_requirements: *id003
67
49
  - !ruby/object:Gem::Dependency
68
- name: fakeweb
50
+ name: rake
69
51
  prerelease: false
70
52
  requirement: &id004 !ruby/object:Gem::Requirement
71
53
  none: false
72
54
  requirements:
73
- - - ">="
55
+ - - ~>
74
56
  - !ruby/object:Gem::Version
75
- hash: 3
76
- segments:
77
- - 0
78
- version: "0"
57
+ version: "0.8"
79
58
  type: :development
80
59
  version_requirements: *id004
60
+ - !ruby/object:Gem::Dependency
61
+ name: rspec
62
+ prerelease: false
63
+ requirement: &id005 !ruby/object:Gem::Requirement
64
+ none: false
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: 2.5.0
69
+ type: :development
70
+ version_requirements: *id005
71
+ - !ruby/object:Gem::Dependency
72
+ name: yard
73
+ prerelease: false
74
+ requirement: &id006 !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ~>
78
+ - !ruby/object:Gem::Version
79
+ version: "0.6"
80
+ type: :development
81
+ version_requirements: *id006
82
+ - !ruby/object:Gem::Dependency
83
+ name: maruku
84
+ prerelease: false
85
+ requirement: &id007 !ruby/object:Gem::Requirement
86
+ none: false
87
+ requirements:
88
+ - - ~>
89
+ - !ruby/object:Gem::Version
90
+ version: "0.6"
91
+ type: :development
92
+ version_requirements: *id007
93
+ - !ruby/object:Gem::Dependency
94
+ name: simplecov
95
+ prerelease: false
96
+ requirement: &id008 !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ~>
100
+ - !ruby/object:Gem::Version
101
+ version: "0.3"
102
+ type: :development
103
+ version_requirements: *id008
104
+ - !ruby/object:Gem::Dependency
105
+ name: fakeweb
106
+ prerelease: false
107
+ requirement: &id009 !ruby/object:Gem::Requirement
108
+ none: false
109
+ requirements:
110
+ - - ~>
111
+ - !ruby/object:Gem::Version
112
+ version: 1.3.0
113
+ type: :development
114
+ version_requirements: *id009
81
115
  description: An unofficial gem for interacting with the Hoptoad API
82
- email: steve.agalloco@gmail.com
116
+ email:
117
+ - steve.agalloco@gmail.com
83
118
  executables: []
84
119
 
85
120
  extensions: []
@@ -87,20 +122,31 @@ extensions: []
87
122
  extra_rdoc_files: []
88
123
 
89
124
  files:
125
+ - .gitignore
126
+ - .rspec
127
+ - Gemfile
128
+ - README.md
90
129
  - Rakefile
130
+ - hoptoad-api.gemspec
131
+ - lib/hoptoad-api.rb
91
132
  - lib/hoptoad-api/client.rb
92
133
  - lib/hoptoad-api/core_extensions.rb
134
+ - lib/hoptoad-api/error.rb
135
+ - lib/hoptoad-api/notice.rb
136
+ - lib/hoptoad-api/project.rb
93
137
  - lib/hoptoad-api/version.rb
94
- - lib/hoptoad-api.rb
95
- - test/fixtures/errors.xml
96
- - test/fixtures/individual_error.xml
97
- - test/fixtures/individual_notice.xml
98
- - test/fixtures/notices.xml
99
- - test/fixtures/paginated_errors.xml
100
- - test/fixtures/paginated_notices.xml
101
- - test/test_helper.rb
102
- - test/test_hoptoad-api.rb
103
- - README.textile
138
+ - spec/fixtures/errors.xml
139
+ - spec/fixtures/individual_error.xml
140
+ - spec/fixtures/individual_notice.xml
141
+ - spec/fixtures/notices.xml
142
+ - spec/fixtures/paginated_errors.xml
143
+ - spec/fixtures/paginated_notices.xml
144
+ - spec/fixtures/projects.xml
145
+ - spec/hoptoad_api/error_spec.rb
146
+ - spec/hoptoad_api/notice_spec.rb
147
+ - spec/hoptoad_api/project_spec.rb
148
+ - spec/hoptoad_api_spec.rb
149
+ - spec/spec_helper.rb
104
150
  has_rdoc: true
105
151
  homepage: http://github.com/spagalloco/hoptoad-api
106
152
  licenses: []
@@ -115,25 +161,30 @@ required_ruby_version: !ruby/object:Gem::Requirement
115
161
  requirements:
116
162
  - - ">="
117
163
  - !ruby/object:Gem::Version
118
- hash: 3
119
- segments:
120
- - 0
121
164
  version: "0"
122
165
  required_rubygems_version: !ruby/object:Gem::Requirement
123
166
  none: false
124
167
  requirements:
125
168
  - - ">="
126
169
  - !ruby/object:Gem::Version
127
- hash: 3
128
- segments:
129
- - 0
130
170
  version: "0"
131
171
  requirements: []
132
172
 
133
173
  rubyforge_project:
134
- rubygems_version: 1.3.7
174
+ rubygems_version: 1.5.0
135
175
  signing_key:
136
176
  specification_version: 3
137
177
  summary: Hoptoad API
138
- test_files: []
139
-
178
+ test_files:
179
+ - spec/fixtures/errors.xml
180
+ - spec/fixtures/individual_error.xml
181
+ - spec/fixtures/individual_notice.xml
182
+ - spec/fixtures/notices.xml
183
+ - spec/fixtures/paginated_errors.xml
184
+ - spec/fixtures/paginated_notices.xml
185
+ - spec/fixtures/projects.xml
186
+ - spec/hoptoad_api/error_spec.rb
187
+ - spec/hoptoad_api/notice_spec.rb
188
+ - spec/hoptoad_api/project_spec.rb
189
+ - spec/hoptoad_api_spec.rb
190
+ - spec/spec_helper.rb
@@ -1,35 +0,0 @@
1
- h1. Hoptoad API
2
-
3
- An unofficial Ruby library for interacting with the "Hoptoad API":http://hoptoadapp.com/pages/api
4
-
5
- h2. Usage
6
-
7
- <pre>
8
- <code>
9
- Hoptoad.account = 'myaccount'
10
- Hoptoad.auth_token = 'abcdeghijklmnopqrstuvwxyz'
11
- Hoptoad.secure = true # if your account is SSL enabled
12
-
13
- # find an individual error:
14
- Hoptoad::Error.find(12345)
15
-
16
- # or get a list of errors using:
17
- Hoptoad::Error.find(:all)
18
- Hoptoad::Error.find(:all, { :page => 2 })
19
- </code>
20
- </pre>
21
-
22
-
23
- h2. Requirements
24
-
25
- * HTTParty
26
- * Hashie
27
-
28
- h2. Acknowledgements
29
-
30
- * "Hoptoad":http://hoptoadapp.com
31
-
32
- h2. Contributors
33
-
34
- Matias Käkelä (SSL Support)
35
- Jordan Brough (Notices)
@@ -1,121 +0,0 @@
1
- require 'test_helper'
2
-
3
- class HoptoadTest < Test::Unit::TestCase
4
-
5
- context "configuration" do
6
- setup do
7
- Hoptoad.account = nil
8
- Hoptoad.auth_token = nil
9
- Hoptoad.secure = false
10
- end
11
-
12
-
13
- should "allow setting of the account" do
14
- Hoptoad.account = 'myapp'
15
- assert_equal Hoptoad.account, 'myapp'
16
- assert_equal Hoptoad.account_path, 'http://myapp.hoptoadapp.com'
17
- end
18
-
19
- should "allow setting of the auth token" do
20
- Hoptoad.auth_token = '123456'
21
- assert_equal Hoptoad.auth_token, '123456'
22
- end
23
-
24
- should "allow setting of ssl protocol" do
25
- Hoptoad.secure = true
26
- assert_equal Hoptoad.protocol, 'https'
27
- end
28
-
29
- should "default to standard http" do
30
- Hoptoad.secure = false
31
- assert_equal Hoptoad.protocol, 'http'
32
- end
33
-
34
- should "should immplement #configure" do
35
- Hoptoad.configure(:account => 'anapp', :auth_token => 'abcdefg', :secure => true)
36
- assert_equal Hoptoad.protocol, 'https'
37
- assert_equal Hoptoad.auth_token, 'abcdefg'
38
- assert_equal Hoptoad.account, 'anapp'
39
- assert_equal Hoptoad.account_path, 'https://anapp.hoptoadapp.com'
40
- end
41
- end
42
-
43
- context "given a Hoptoad account & API key" do
44
- setup do
45
- Hoptoad.account = 'myapp'
46
- Hoptoad.auth_token = 'abcdefg123456'
47
- Hoptoad.secure = false
48
- end
49
-
50
- should "have correct collection path" do
51
- assert_equal "/errors.xml", Hoptoad::Error.collection_path
52
- end
53
-
54
- should "generate correct error path given an id" do
55
- assert_equal "/errors/1234.xml", Hoptoad::Error.error_path(1234)
56
- end
57
-
58
- context "when finding errors" do
59
-
60
- should "find a page of the 30 most recent errors" do
61
- errors = Hoptoad::Error.find(:all)
62
- ordered = errors.sort_by(&:most_recent_notice_at).reverse
63
- assert_equal ordered, errors
64
- assert_equal errors.size, 30
65
- end
66
-
67
- should "paginate errors" do
68
- errors = Hoptoad::Error.find(:all, :page => 2)
69
- ordered = errors.sort_by(&:most_recent_notice_at).reverse
70
- assert_equal ordered, errors
71
- assert_equal errors.size, 2
72
- end
73
-
74
- should "find an individual error" do
75
- error = Hoptoad::Error.find(1696170)
76
- assert_equal error.action, 'index'
77
- assert_equal error.id, 1696170
78
- end
79
-
80
- end
81
-
82
- context "when finding notices" do
83
-
84
- should "find error notices" do
85
- notices = Hoptoad::Notice.find_by_error_id(1696170)
86
- assert_equal notices.size, 30
87
- assert_equal notices.first.id, 1234
88
- end
89
-
90
- should "find all error notices" do
91
- notices = Hoptoad::Notice.find_all_by_error_id(1696170)
92
- assert_equal notices.size, 42
93
- end
94
-
95
- should "find individual notices" do
96
- Hoptoad::Notice.find(1234, 1696170)
97
- end
98
-
99
- end
100
-
101
- context "when using SSL" do
102
-
103
- should "find an error if account is SSL enabled" do
104
- Hoptoad.secure = true
105
- Hoptoad.account = "sslapp"
106
- error = Hoptoad::Error.find(1696170)
107
- assert_equal error.id, 1696170
108
- end
109
-
110
- should "raise exception if trying to access SSL enabled account with unsecure connection" do
111
- Hoptoad.account = "sslapp"
112
- Hoptoad.secure = false
113
- assert_raise(Hoptoad::HoptoadError) do
114
- error = Hoptoad::Error.find(1696170)
115
- end
116
- end
117
- end
118
-
119
- end
120
-
121
- end