google_places 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/Gemfile.lock +1 -1
- data/google_places.gemspec +1 -1
- data/lib/google_places/error.rb +8 -0
- data/lib/google_places/request.rb +2 -2
- data/lib/google_places/review.rb +9 -8
- data/lib/google_places/spot.rb +2 -1
- data/spec/google_places/request_spec.rb +12 -0
- data/spec/vcr_cassettes/http_502.yml +46 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a7c7601aa9e3d41a1d901e95f3d6d8ff3537196b
|
4
|
+
data.tar.gz: 513249ec18cfb927b8cf8d48c8656a187168fbb5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0d7104e3321af46c15e18a1f54159ea7b54154db044fd54e1772ba7e341b85d9fa565d16dfa55e5e452c77e0056ce3a2d5f422955608f5a1cc72bdb7dc639502
|
7
|
+
data.tar.gz: c85de97b1526db8d96c84b97a79a4ab3f60ad893b7987f6ce4cbb6a35a2d5c9cbc86287bf65fdefd0f3ca479891bdc8198454c282dc703e380d33694e31eb1b9
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/google_places.gemspec
CHANGED
data/lib/google_places/error.rb
CHANGED
@@ -34,4 +34,12 @@ module GooglePlaces
|
|
34
34
|
|
35
35
|
class NotFoundError < HTTParty::ResponseError
|
36
36
|
end
|
37
|
+
|
38
|
+
# Thrown when the server returns any 5xx error
|
39
|
+
#
|
40
|
+
# This can be the case when:
|
41
|
+
# - There is a network problem between this gem and Google's API servers
|
42
|
+
# - Google's API is broken
|
43
|
+
class APIConnectionError < HTTParty::ResponseError
|
44
|
+
end
|
37
45
|
end
|
@@ -347,7 +347,8 @@ module GooglePlaces
|
|
347
347
|
# @raise [NotFoundError] when server response object includes 'NOT_FOUND'
|
348
348
|
# @return [String] the response from the server as JSON
|
349
349
|
def parsed_response
|
350
|
-
return @response.headers["location"] if @response.code >= 300
|
350
|
+
return @response.headers["location"] if @response.code >= 300 && @response.code < 400
|
351
|
+
raise APIConnectionError.new(@response) if @response.code >= 500 && @response.code < 600
|
351
352
|
case @response.parsed_response['status']
|
352
353
|
when 'OK', 'ZERO_RESULTS'
|
353
354
|
@response.parsed_response
|
@@ -363,6 +364,5 @@ module GooglePlaces
|
|
363
364
|
raise NotFoundError.new(@response)
|
364
365
|
end
|
365
366
|
end
|
366
|
-
|
367
367
|
end
|
368
368
|
end
|
data/lib/google_places/review.rb
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
module GooglePlaces
|
2
2
|
class Review
|
3
|
-
attr_accessor :rating, :type, :author_name, :author_url, :text, :time
|
3
|
+
attr_accessor :rating, :type, :author_name, :author_url, :text, :time, :profile_photo_url
|
4
4
|
|
5
|
-
def initialize(rating, type, author_name, author_url, text, time)
|
6
|
-
@rating
|
7
|
-
@type
|
8
|
-
@author_name
|
9
|
-
@author_url
|
10
|
-
@text
|
11
|
-
@time
|
5
|
+
def initialize(rating, type, author_name, author_url, text, time, profile_photo_url)
|
6
|
+
@rating = rating
|
7
|
+
@type = type
|
8
|
+
@author_name = author_name
|
9
|
+
@author_url = author_url
|
10
|
+
@text = text
|
11
|
+
@time = time
|
12
|
+
@profile_photo_url = profile_photo_url
|
12
13
|
end
|
13
14
|
end
|
14
15
|
end
|
data/lib/google_places/spot.rb
CHANGED
@@ -291,4 +291,16 @@ describe GooglePlaces::Request do
|
|
291
291
|
end
|
292
292
|
end
|
293
293
|
|
294
|
+
context 'with an HTTP 502 response', vcr: { cassette_name: 'http_502' } do
|
295
|
+
it 'correctly handles the exception' do
|
296
|
+
stub_const("GooglePlaces::Request::DETAILS_URL", 'http://httpstat.us/502')
|
297
|
+
|
298
|
+
expect(lambda {
|
299
|
+
GooglePlaces::Request.spot(
|
300
|
+
:reference => @reference,
|
301
|
+
:key => api_key
|
302
|
+
)
|
303
|
+
}).to raise_error GooglePlaces::APIConnectionError
|
304
|
+
end
|
305
|
+
end
|
294
306
|
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://httpstat.us/502?key=AIzaSyAKeN0XMV5LqJmqBrZZ1K8qMipFW7-Eybg&reference=CnRsAAAASc4grenwL0h3X5VPNp5fkDNfqbjt3iQtWIPlKS-3ms9GbnCxR_FLHO0B0ZKCgJSg19qymkeHagjQFB4aUL87yhp4mhFTc17DopK1oiYDaeGthztSjERic8TmFNe-6zOpKSdiZWKE6xlQvcbSiWIJchIQOEYZqunSSZqNDoBSs77bWRoUJcMMVANtSlhy0llKI0MI6VcC7DU
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept-Encoding:
|
11
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
12
|
+
Accept:
|
13
|
+
- "*/*"
|
14
|
+
User-Agent:
|
15
|
+
- Ruby
|
16
|
+
response:
|
17
|
+
status:
|
18
|
+
code: 502
|
19
|
+
message: Bad Gateway
|
20
|
+
headers:
|
21
|
+
Cache-Control:
|
22
|
+
- private
|
23
|
+
Content-Length:
|
24
|
+
- '15'
|
25
|
+
Content-Type:
|
26
|
+
- text/plain; charset=utf-8
|
27
|
+
Server:
|
28
|
+
- Microsoft-IIS/8.0
|
29
|
+
X-Aspnetmvc-Version:
|
30
|
+
- '5.1'
|
31
|
+
Access-Control-Allow-Origin:
|
32
|
+
- "*"
|
33
|
+
X-Aspnet-Version:
|
34
|
+
- 4.0.30319
|
35
|
+
X-Powered-By:
|
36
|
+
- ASP.NET
|
37
|
+
Set-Cookie:
|
38
|
+
- ARRAffinity=5f087fd6a40a6d05f0b0eb568d99070a0e7b27a443c43c64047aae88fa2e0bea;Path=/;HttpOnly;Domain=httpstat.us
|
39
|
+
Date:
|
40
|
+
- Tue, 07 Nov 2017 10:30:02 GMT
|
41
|
+
body:
|
42
|
+
encoding: UTF-8
|
43
|
+
string: 502 Bad Gateway
|
44
|
+
http_version:
|
45
|
+
recorded_at: Tue, 07 Nov 2017 10:30:03 GMT
|
46
|
+
recorded_with: VCR 2.9.3
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: google_places
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marcel de Graaf
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-01-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -119,6 +119,7 @@ files:
|
|
119
119
|
- spec/google_places/spot_spec.rb
|
120
120
|
- spec/spec_helper.rb
|
121
121
|
- spec/vcr_cassettes/GooglePlaces_Spot/List_spots_options/should_not_set_radius_to_nil_if_rankby_is_set_to_prominence.yml
|
122
|
+
- spec/vcr_cassettes/http_502.yml
|
122
123
|
- spec/vcr_cassettes/list_predictions.yml
|
123
124
|
- spec/vcr_cassettes/list_spots.yml
|
124
125
|
- spec/vcr_cassettes/list_spots_by_radar.yml
|
@@ -168,6 +169,7 @@ test_files:
|
|
168
169
|
- spec/google_places/spot_spec.rb
|
169
170
|
- spec/spec_helper.rb
|
170
171
|
- spec/vcr_cassettes/GooglePlaces_Spot/List_spots_options/should_not_set_radius_to_nil_if_rankby_is_set_to_prominence.yml
|
172
|
+
- spec/vcr_cassettes/http_502.yml
|
171
173
|
- spec/vcr_cassettes/list_predictions.yml
|
172
174
|
- spec/vcr_cassettes/list_spots.yml
|
173
175
|
- spec/vcr_cassettes/list_spots_by_radar.yml
|