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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8439d196c5b207a51f79c1c53b4a8fd91439ce54
4
- data.tar.gz: 1392714187eb2667d7ecc157e494c04785270140
3
+ metadata.gz: a7c7601aa9e3d41a1d901e95f3d6d8ff3537196b
4
+ data.tar.gz: 513249ec18cfb927b8cf8d48c8656a187168fbb5
5
5
  SHA512:
6
- metadata.gz: 42af9c2cb49adc5c1cba215d780926ef9b718f32c4c9a3ed70e861e1ca0a0ce6619a7f890dd718286c04f7459b5deccc2ced819ac340c85c50693df8998b5511
7
- data.tar.gz: 9c9b957daec2c8dc210cbb9f5945377cde979bc9e16a1ef6c765c31e4bd0a5251c1a14ffd0ffbd6bf9b0d63057b246c69fb019efa22b1b8a4ea0e9cbe31f0891
6
+ metadata.gz: 0d7104e3321af46c15e18a1f54159ea7b54154db044fd54e1772ba7e341b85d9fa565d16dfa55e5e452c77e0056ce3a2d5f422955608f5a1cc72bdb7dc639502
7
+ data.tar.gz: c85de97b1526db8d96c84b97a79a4ab3f60ad893b7987f6ce4cbb6a35a2d5c9cbc86287bf65fdefd0f3ca479891bdc8198454c282dc703e380d33694e31eb1b9
@@ -1,3 +1,8 @@
1
+ ## 1.1.0
2
+
3
+ - Include the profile_photo_url attribute for the GooglePlaces::Review object
4
+ - Gracefully handle HTTP 500 errors from the Google API
5
+
1
6
  ## 1.0.0
2
7
 
3
8
  - Upgraded httparty 0.14.0 -> 0.15.6
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- google_places (1.0.0)
4
+ google_places (1.1.0)
5
5
  httparty (>= 0.13.1)
6
6
 
7
7
  GEM
@@ -3,7 +3,7 @@ $:.push File.expand_path('../lib', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = 'google_places'
6
- s.version = '1.0.0'
6
+ s.version = '1.1.0'
7
7
  s.platform = Gem::Platform::RUBY
8
8
  s.authors = ['Marcel de Graaf']
9
9
  s.email = ['mail@marceldegraaf.net']
@@ -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 and @response.code < 400
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
@@ -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 = rating
7
- @type = type
8
- @author_name = author_name
9
- @author_url = author_url
10
- @text = text
11
- @time = 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
@@ -467,7 +467,8 @@ module GooglePlaces
467
467
  r['author_name'],
468
468
  r['author_url'],
469
469
  r['text'],
470
- r['time'].to_i
470
+ r['time'].to_i,
471
+ r['profile_photo_url']
471
472
  )
472
473
  }
473
474
  else []
@@ -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.0.0
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: 2017-10-17 00:00:00.000000000 Z
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