google_maps_service_ruby 0.6.1 → 0.6.2

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
  SHA256:
3
- metadata.gz: 7380aebcb539550614c663f694e974648e3764efa021fe1ecea338162dd3e8fa
4
- data.tar.gz: 36906b8ec79ab32c96ef41627afd424b5b358371f41902b6ea1a8139b83090a5
3
+ metadata.gz: 25cb368b535afc02deeda844ba39c3129173217bc66ecaaa0f62d06fa20c1914
4
+ data.tar.gz: b31f5a94a276b608df9f3e24eaecccd0cf21436f3f4a8361d42058a588531318
5
5
  SHA512:
6
- metadata.gz: 9e8ed9c8a7cbba09a7f626a029bf989face0512d94c2606b5335650ea0183f8865e33d092e44d13c84dc7e9e1944d7da7f48c76bc846d05295377f9994693499
7
- data.tar.gz: 6fb2876a34508764a60fa218f48ed687a7998053c0e0e241c0e1a9ce3aae5e2f11e3fa47a7d272ffcef4cf1aeb16efa1a5925a4efbee259ff32730cb3b47e42c
6
+ metadata.gz: 175a5f27bf2c23e6d9958eda7b686a3be90a53d29e90fbf1d6fe54bc790c6266f8caa6a0c7b7319a6ea32f442b8b4a21ac66b785ec71b8f8ab32753c3db62eec
7
+ data.tar.gz: dee6fc2abdd6ffa26bed8c4ef20374962b0a539f12faa4b00b33cc3843055f3cabf50ced8f13472201e936a11e9cf0f7980eedc402d78152c3cc01f6cb298eb1
data/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.6.2 - 2023-03-18
6
+
7
+ * Add support for ruby 3.2
8
+ * Allow directions to return full response from API with response_slice option
9
+ * Allow geocode and reverse_geocode to return full response from API with response_slice option
10
+
5
11
  ## 0.6.1 - 2023-03-18
6
12
 
7
13
  * Fix gem name in README file
@@ -55,13 +55,15 @@ module GoogleMapsService::Apis
55
55
  # `rail` is equivalent to `["train", "tram", "subway"]`.
56
56
  # @param [String] transit_routing_preference Specifies preferences for transit
57
57
  # requests. Valid values are `less_walking` or `fewer_transfers`.
58
+ # @param [Symbol] response_slice Specify subset of response to return. Defaults to :routes for
59
+ # backwards compatibility. Use :all to get complete response.
58
60
  #
59
61
  # @return [Array] Array of routes.
60
62
  def directions(origin, destination,
61
63
  mode: nil, waypoints: nil, alternatives: false, avoid: nil,
62
64
  language: nil, units: nil, region: nil, departure_time: nil,
63
65
  arrival_time: nil, optimize_waypoints: false, transit_mode: nil,
64
- transit_routing_preference: nil)
66
+ transit_routing_preference: nil, response_slice: :routes)
65
67
 
66
68
  params = {
67
69
  origin: GoogleMapsService::Convert.waypoint(origin),
@@ -93,7 +95,11 @@ module GoogleMapsService::Apis
93
95
  params[:transit_mode] = GoogleMapsService::Convert.join_list("|", transit_mode) if transit_mode
94
96
  params[:transit_routing_preference] = transit_routing_preference if transit_routing_preference
95
97
 
96
- get("/maps/api/directions/json", params)[:routes]
98
+ if response_slice == :all
99
+ get("/maps/api/directions/json", params)
100
+ else
101
+ get("/maps/api/directions/json", params)[response_slice]
102
+ end
97
103
  end
98
104
  end
99
105
  end
@@ -34,9 +34,11 @@ module GoogleMapsService::Apis
34
34
  # @param [String] region The region code, specified as a ccTLD (_top-level domain_)
35
35
  # two-character value.
36
36
  # @param [String] language The language in which to return results.
37
+ # @param [Symbol] response_slice Specify subset of response to return. Defaults to :results for
38
+ # backwards compatibility. Use :all to get complete response.
37
39
  #
38
40
  # @return [Array] Array of geocoding results.
39
- def geocode(address, components: nil, bounds: nil, region: nil, language: nil)
41
+ def geocode(address, components: nil, bounds: nil, region: nil, language: nil, response_slice: :results)
40
42
  params = {}
41
43
 
42
44
  params[:address] = address if address
@@ -45,7 +47,11 @@ module GoogleMapsService::Apis
45
47
  params[:region] = region if region
46
48
  params[:language] = language if language
47
49
 
48
- get("/maps/api/geocode/json", params)[:results]
50
+ if response_slice == :all
51
+ get("/maps/api/geocode/json", params)
52
+ else
53
+ get("/maps/api/geocode/json", params)[response_slice]
54
+ end
49
55
  end
50
56
 
51
57
  # Reverse geocoding is the process of converting geographic coordinates into a
@@ -65,9 +71,11 @@ module GoogleMapsService::Apis
65
71
  # @param [String, Array<String>] location_type One or more location types to restrict results to.
66
72
  # @param [String, Array<String>] result_type One or more address types to restrict results to.
67
73
  # @param [String] language The language in which to return results.
74
+ # @param [Symbol] response_slice Specify subset of response to return. Defaults to :results for
75
+ # backwards compatibility. Use :all to get complete response.
68
76
  #
69
77
  # @return [Array] Array of reverse geocoding results.
70
- def reverse_geocode(latlng, location_type: nil, result_type: nil, language: nil)
78
+ def reverse_geocode(latlng, location_type: nil, result_type: nil, language: nil, response_slice: :results)
71
79
  params = {
72
80
  latlng: GoogleMapsService::Convert.latlng(latlng)
73
81
  }
@@ -76,7 +84,11 @@ module GoogleMapsService::Apis
76
84
  params[:location_type] = GoogleMapsService::Convert.join_list("|", location_type) if location_type
77
85
  params[:language] = language if language
78
86
 
79
- get("/maps/api/geocode/json", params)[:results]
87
+ if response_slice == :all
88
+ get("/maps/api/geocode/json", params)
89
+ else
90
+ get("/maps/api/geocode/json", params)[response_slice]
91
+ end
80
92
  end
81
93
  end
82
94
  end
@@ -32,7 +32,7 @@ module GoogleMapsService
32
32
  shift += 5
33
33
  break if b < 0x1f
34
34
  end
35
- lat += (result & 1) != 0 ? (~result >> 1) : (result >> 1)
35
+ lat += ((result & 1) != 0) ? (~result >> 1) : (result >> 1)
36
36
 
37
37
  result = 1
38
38
  shift = 0
@@ -43,7 +43,7 @@ module GoogleMapsService
43
43
  shift += 5
44
44
  break if b < 0x1f
45
45
  end
46
- lng += (result & 1) != 0 ? ~(result >> 1) : (result >> 1)
46
+ lng += ((result & 1) != 0) ? ~(result >> 1) : (result >> 1)
47
47
 
48
48
  points << {lat: lat * 1e-5, lng: lng * 1e-5}
49
49
  end
@@ -71,7 +71,7 @@ module GoogleMapsService
71
71
  d_lng = lng - last_lng
72
72
 
73
73
  [d_lat, d_lng].each do |v|
74
- v = v < 0 ? ~(v << 1) : (v << 1)
74
+ v = (v < 0) ? ~(v << 1) : (v << 1)
75
75
  while v >= 0x20
76
76
  result += ((0x20 | (v & 0x1f)) + 63).chr
77
77
  v >>= 5
@@ -1,6 +1,6 @@
1
1
  module GoogleMapsService
2
2
  # GoogleMapsService gem version
3
- VERSION = "0.6.1"
3
+ VERSION = "0.6.2"
4
4
 
5
5
  # Current operating system
6
6
  # @private
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google_maps_service_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lang Sharpe
@@ -203,7 +203,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
203
203
  - !ruby/object:Gem::Version
204
204
  version: '0'
205
205
  requirements: []
206
- rubygems_version: 3.1.4
206
+ rubygems_version: 3.4.6
207
207
  signing_key:
208
208
  specification_version: 4
209
209
  summary: Google Maps API Client