reviewed 0.1.32 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -59,25 +59,20 @@ module Reviewed
59
59
 
60
60
  def perform(method, path, params={})
61
61
  begin
62
- response = self.connection.send(method.to_sym, path, params) do |request|
62
+ self.connection.send(method.to_sym, path, params) do |request|
63
63
  request.params.merge!(self.request_params)
64
64
  request.headers['X-Reviewed-Authorization'] ||= self.api_key
65
65
  end
66
- rescue => e
67
- if e.class < Faraday::Error::ClientError
68
- message = <<-EOS.gsub(/^[ ]*/, '')
69
- API Error. method: #{method}. path: #{path}. params: #{params.to_s}. api_key: #{self.api_key}
70
- Original exception message:
71
- #{e.message}
72
- EOS
73
- new_exception = Reviewed::ApiError.new(msg: message)
74
- new_exception.set_backtrace(e.backtrace)
75
- raise new_exception
76
- else
77
- raise
78
- end
66
+ rescue Faraday::Error::ClientError => e
67
+ message = <<-EOS.gsub(/^[ ]*/, '')
68
+ API Error. method: #{method}. path: #{path}. params: #{params.to_s}. api_key: #{self.api_key}
69
+ Original exception message:
70
+ #{e.message}
71
+ EOS
72
+ new_exception = Reviewed::ApiError.new(msg: message)
73
+ new_exception.set_backtrace(e.backtrace) # TODO not seeing in Airbrake
74
+ raise new_exception
79
75
  end
80
- response
81
76
  end
82
77
  end
83
78
  end
@@ -16,7 +16,8 @@ module Reviewed
16
16
 
17
17
  # Get request on resource#show
18
18
  def find(id, params={})
19
- object_from_response(:get, "#{path}/#{id}", params)
19
+ url_path = [path, CGI::escape(id.to_s)]
20
+ object_from_response(:get, url_path.join('/'), params)
20
21
  end
21
22
 
22
23
  # Get request on resource#index with query params
@@ -1,4 +1,4 @@
1
1
  module Reviewed
2
- VERSION = "0.1.32"
2
+ VERSION = "0.2.0"
3
3
  API_VERSION = 'v1'
4
4
  end
data/reviewed.gemspec CHANGED
@@ -22,6 +22,7 @@ Gem::Specification.new do |gem|
22
22
  gem.add_dependency 'hashie', '~> 1.2'
23
23
  gem.add_dependency 'rack'
24
24
 
25
+ gem.add_development_dependency 'rake'
25
26
  gem.add_development_dependency 'rspec', '>= 2.10'
26
27
  gem.add_development_dependency 'webmock', '>= 1.8'
27
28
  gem.add_development_dependency 'vcr', '>= 2.1'
data/spec/client_spec.rb CHANGED
@@ -147,6 +147,19 @@ describe Reviewed::Client do
147
147
  collection.count.should eql(20)
148
148
  end
149
149
  end
150
+
151
+
152
+ end
153
+ end
154
+
155
+ context 'with error' do
156
+
157
+ context 'bad response' do
158
+ it 'should raise a Reviewed::ApiError' do
159
+ client.connection.stub(:send).and_raise Faraday::Error::ClientError.new(true)
160
+ lambda { client.get('something that times out') }.should raise_error(Reviewed::ApiError)
161
+ end
150
162
  end
163
+
151
164
  end
152
165
  end
data/spec/request_spec.rb CHANGED
@@ -43,6 +43,11 @@ describe Reviewed::Request do
43
43
  request.should_receive(:object_from_response).with(:get, "articles/123", {})
44
44
  request.find(123)
45
45
  end
46
+
47
+ it 'cgi escapes id params' do
48
+ request.should_receive(:object_from_response).with(:get, "articles/Smith+%26+Wesson+v%2Fs+Colt%3A+Which+Makes+you+Manlier%3F", {})
49
+ request.find('Smith & Wesson v/s Colt: Which Makes you Manlier?')
50
+ end
46
51
  end
47
52
 
48
53
  describe '#where', vcr: true do
metadata CHANGED
@@ -1,7 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reviewed
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.32
4
+ version: 0.2.0
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Nick Plante
@@ -9,11 +10,12 @@ authors:
9
10
  autorequire:
10
11
  bindir: bin
11
12
  cert_chain: []
12
- date: 2013-03-22 00:00:00.000000000 Z
13
+ date: 2013-03-25 00:00:00.000000000 Z
13
14
  dependencies:
14
15
  - !ruby/object:Gem::Dependency
15
16
  name: activesupport
16
17
  requirement: !ruby/object:Gem::Requirement
18
+ none: false
17
19
  requirements:
18
20
  - - ! '>='
19
21
  - !ruby/object:Gem::Version
@@ -21,6 +23,7 @@ dependencies:
21
23
  type: :runtime
22
24
  prerelease: false
23
25
  version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
24
27
  requirements:
25
28
  - - ! '>='
26
29
  - !ruby/object:Gem::Version
@@ -28,6 +31,7 @@ dependencies:
28
31
  - !ruby/object:Gem::Dependency
29
32
  name: activemodel
30
33
  requirement: !ruby/object:Gem::Requirement
34
+ none: false
31
35
  requirements:
32
36
  - - ! '>='
33
37
  - !ruby/object:Gem::Version
@@ -35,6 +39,7 @@ dependencies:
35
39
  type: :runtime
36
40
  prerelease: false
37
41
  version_requirements: !ruby/object:Gem::Requirement
42
+ none: false
38
43
  requirements:
39
44
  - - ! '>='
40
45
  - !ruby/object:Gem::Version
@@ -42,6 +47,7 @@ dependencies:
42
47
  - !ruby/object:Gem::Dependency
43
48
  name: faraday
44
49
  requirement: !ruby/object:Gem::Requirement
50
+ none: false
45
51
  requirements:
46
52
  - - ! '>='
47
53
  - !ruby/object:Gem::Version
@@ -49,6 +55,7 @@ dependencies:
49
55
  type: :runtime
50
56
  prerelease: false
51
57
  version_requirements: !ruby/object:Gem::Requirement
58
+ none: false
52
59
  requirements:
53
60
  - - ! '>='
54
61
  - !ruby/object:Gem::Version
@@ -56,6 +63,7 @@ dependencies:
56
63
  - !ruby/object:Gem::Dependency
57
64
  name: faraday_middleware
58
65
  requirement: !ruby/object:Gem::Requirement
66
+ none: false
59
67
  requirements:
60
68
  - - ! '>='
61
69
  - !ruby/object:Gem::Version
@@ -63,6 +71,7 @@ dependencies:
63
71
  type: :runtime
64
72
  prerelease: false
65
73
  version_requirements: !ruby/object:Gem::Requirement
74
+ none: false
66
75
  requirements:
67
76
  - - ! '>='
68
77
  - !ruby/object:Gem::Version
@@ -70,6 +79,7 @@ dependencies:
70
79
  - !ruby/object:Gem::Dependency
71
80
  name: hashie
72
81
  requirement: !ruby/object:Gem::Requirement
82
+ none: false
73
83
  requirements:
74
84
  - - ~>
75
85
  - !ruby/object:Gem::Version
@@ -77,6 +87,7 @@ dependencies:
77
87
  type: :runtime
78
88
  prerelease: false
79
89
  version_requirements: !ruby/object:Gem::Requirement
90
+ none: false
80
91
  requirements:
81
92
  - - ~>
82
93
  - !ruby/object:Gem::Version
@@ -84,6 +95,7 @@ dependencies:
84
95
  - !ruby/object:Gem::Dependency
85
96
  name: rack
86
97
  requirement: !ruby/object:Gem::Requirement
98
+ none: false
87
99
  requirements:
88
100
  - - ! '>='
89
101
  - !ruby/object:Gem::Version
@@ -91,6 +103,23 @@ dependencies:
91
103
  type: :runtime
92
104
  prerelease: false
93
105
  version_requirements: !ruby/object:Gem::Requirement
106
+ none: false
107
+ requirements:
108
+ - - ! '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rake
113
+ requirement: !ruby/object:Gem::Requirement
114
+ none: false
115
+ requirements:
116
+ - - ! '>='
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ type: :development
120
+ prerelease: false
121
+ version_requirements: !ruby/object:Gem::Requirement
122
+ none: false
94
123
  requirements:
95
124
  - - ! '>='
96
125
  - !ruby/object:Gem::Version
@@ -98,6 +127,7 @@ dependencies:
98
127
  - !ruby/object:Gem::Dependency
99
128
  name: rspec
100
129
  requirement: !ruby/object:Gem::Requirement
130
+ none: false
101
131
  requirements:
102
132
  - - ! '>='
103
133
  - !ruby/object:Gem::Version
@@ -105,6 +135,7 @@ dependencies:
105
135
  type: :development
106
136
  prerelease: false
107
137
  version_requirements: !ruby/object:Gem::Requirement
138
+ none: false
108
139
  requirements:
109
140
  - - ! '>='
110
141
  - !ruby/object:Gem::Version
@@ -112,6 +143,7 @@ dependencies:
112
143
  - !ruby/object:Gem::Dependency
113
144
  name: webmock
114
145
  requirement: !ruby/object:Gem::Requirement
146
+ none: false
115
147
  requirements:
116
148
  - - ! '>='
117
149
  - !ruby/object:Gem::Version
@@ -119,6 +151,7 @@ dependencies:
119
151
  type: :development
120
152
  prerelease: false
121
153
  version_requirements: !ruby/object:Gem::Requirement
154
+ none: false
122
155
  requirements:
123
156
  - - ! '>='
124
157
  - !ruby/object:Gem::Version
@@ -126,6 +159,7 @@ dependencies:
126
159
  - !ruby/object:Gem::Dependency
127
160
  name: vcr
128
161
  requirement: !ruby/object:Gem::Requirement
162
+ none: false
129
163
  requirements:
130
164
  - - ! '>='
131
165
  - !ruby/object:Gem::Version
@@ -133,6 +167,7 @@ dependencies:
133
167
  type: :development
134
168
  prerelease: false
135
169
  version_requirements: !ruby/object:Gem::Requirement
170
+ none: false
136
171
  requirements:
137
172
  - - ! '>='
138
173
  - !ruby/object:Gem::Version
@@ -140,6 +175,7 @@ dependencies:
140
175
  - !ruby/object:Gem::Dependency
141
176
  name: guard-rspec
142
177
  requirement: !ruby/object:Gem::Requirement
178
+ none: false
143
179
  requirements:
144
180
  - - ! '>='
145
181
  - !ruby/object:Gem::Version
@@ -147,6 +183,7 @@ dependencies:
147
183
  type: :development
148
184
  prerelease: false
149
185
  version_requirements: !ruby/object:Gem::Requirement
186
+ none: false
150
187
  requirements:
151
188
  - - ! '>='
152
189
  - !ruby/object:Gem::Version
@@ -154,6 +191,7 @@ dependencies:
154
191
  - !ruby/object:Gem::Dependency
155
192
  name: pry
156
193
  requirement: !ruby/object:Gem::Requirement
194
+ none: false
157
195
  requirements:
158
196
  - - ! '>='
159
197
  - !ruby/object:Gem::Version
@@ -161,6 +199,7 @@ dependencies:
161
199
  type: :development
162
200
  prerelease: false
163
201
  version_requirements: !ruby/object:Gem::Requirement
202
+ none: false
164
203
  requirements:
165
204
  - - ! '>='
166
205
  - !ruby/object:Gem::Version
@@ -256,26 +295,27 @@ files:
256
295
  - spec/website_spec.rb
257
296
  homepage: ''
258
297
  licenses: []
259
- metadata: {}
260
298
  post_install_message:
261
299
  rdoc_options: []
262
300
  require_paths:
263
301
  - lib
264
302
  required_ruby_version: !ruby/object:Gem::Requirement
303
+ none: false
265
304
  requirements:
266
305
  - - ! '>='
267
306
  - !ruby/object:Gem::Version
268
307
  version: '0'
269
308
  required_rubygems_version: !ruby/object:Gem::Requirement
309
+ none: false
270
310
  requirements:
271
311
  - - ! '>='
272
312
  - !ruby/object:Gem::Version
273
313
  version: '0'
274
314
  requirements: []
275
315
  rubyforge_project:
276
- rubygems_version: 2.0.0
316
+ rubygems_version: 1.8.25
277
317
  signing_key:
278
- specification_version: 4
318
+ specification_version: 3
279
319
  summary: A Ruby Gem for Accessing the Reviewed.com API
280
320
  test_files:
281
321
  - spec/article_spec.rb
checksums.yaml DELETED
@@ -1,15 +0,0 @@
1
- ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- MWM3YWI3Zjg0MDA3N2ZlYzBjZjQ5MmYxNWFiOGY1NzU0YWJlMjlmMw==
5
- data.tar.gz: !binary |-
6
- MmZmZTMyMWM2MDg2ZTAzMzM1YWU4OGM5MzdhMDg2YmUxZmY2MzAzNg==
7
- !binary "U0hBNTEy":
8
- metadata.gz: !binary |-
9
- YTY4NmJmYjYxNmFmYTY3YTU3MDI4ZDg1OGM5MTA3MzY4Y2JkYmJlN2Y0MmZj
10
- ZGQyNmVjOTU2YTcyNjFjYjc1ZGFjNDFhNmFiZmExYTQ3YTVkZTBiZjJlMzFl
11
- MTI4Mzg0ODZmMDBlNjQwMTFkNzNjYmUxNDU0NDc0YmI2NmFlNWM=
12
- data.tar.gz: !binary |-
13
- MjMyYThmOGNkY2M0NjBmZDBiN2MwZTI0M2IwMjdhMTM1MTE4OTEzZGRjYWZk
14
- ZTJiZmEyMjEwMmQ0NDQ0MDBlNDBjM2EyNTFmZTQzODBiYzYyMDhmODEyMzBk
15
- NzlmNDg5ZGRjYzQ5Y2QwZDIyMjQxNmRhYTE0ZGYwNmZlZWE5ODM=