google_maps_service_ruby 0.6.0 → 0.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 415ae9b2aa464a0f888c4b02e95f75fc454e12f3121e9dc2447a06d0363793f5
4
- data.tar.gz: 649de39c9865615d4d3470d4d63d9292439f1bace619e34b4f383c0c2621147f
3
+ metadata.gz: 25cb368b535afc02deeda844ba39c3129173217bc66ecaaa0f62d06fa20c1914
4
+ data.tar.gz: b31f5a94a276b608df9f3e24eaecccd0cf21436f3f4a8361d42058a588531318
5
5
  SHA512:
6
- metadata.gz: 34aeb8db29dd50e34bf1f6463850a1ce70fed572c8b0f9632cbba8ae196f0933d76b1c6639adc2f5ebeb291a3d719162431c83d4a2261f1c1b2957a15f96930f
7
- data.tar.gz: 84c498f60f473840963491dd83dc6513d6bd28a5d882ade7c1019eabe0fad304d81dd8ffba68920ca4fdf6ae83aabfdcaac332489489ac94d5783ae897d74805
6
+ metadata.gz: 175a5f27bf2c23e6d9958eda7b686a3be90a53d29e90fbf1d6fe54bc790c6266f8caa6a0c7b7319a6ea32f442b8b4a21ac66b785ec71b8f8ab32753c3db62eec
7
+ data.tar.gz: dee6fc2abdd6ffa26bed8c4ef20374962b0a539f12faa4b00b33cc3843055f3cabf50ced8f13472201e936a11e9cf0f7980eedc402d78152c3cc01f6cb298eb1
data/CHANGELOG.md CHANGED
@@ -2,6 +2,16 @@
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
+
11
+ ## 0.6.1 - 2023-03-18
12
+
13
+ * Fix gem name in README file
14
+
5
15
  ## 0.6.0 - 2022-10-16
6
16
 
7
17
  * Rename gem to google_maps_service_ruby
data/README.md CHANGED
@@ -84,7 +84,7 @@ Your API key should be 40 characters long, and begin with `AIza`.
84
84
 
85
85
  Add this line to your application's Gemfile:
86
86
 
87
- gem 'google_maps_service'
87
+ gem 'google_maps_service_ruby'
88
88
 
89
89
  And then execute:
90
90
 
@@ -92,7 +92,7 @@ And then execute:
92
92
 
93
93
  Or install it yourself as:
94
94
 
95
- gem install google_maps_service
95
+ gem install google_maps_service_ruby
96
96
 
97
97
  In your Ruby code, add this line to load this gem:
98
98
 
@@ -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.0"
3
+ VERSION = "0.6.2"
4
4
 
5
5
  # Current operating system
6
6
  # @private
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google_maps_service_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lang Sharpe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-10-16 00:00:00.000000000 Z
11
+ date: 2023-03-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json
@@ -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