what3words 3.0.0 → 3.1.0
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 +4 -4
- data/README.md +244 -45
- data/lib/what3words/api.rb +175 -190
- data/lib/what3words/version.rb +1 -1
- metadata +9 -20
- data/.editorconfig +0 -17
- data/.gitignore +0 -17
- data/.travis.yml +0 -7
- data/Gemfile +0 -4
- data/LICENSE.txt +0 -22
- data/Rakefile +0 -14
- data/spec/config.sample.yaml +0 -1
- data/spec/lib/what3words/what3words_api_spec.rb +0 -297
- data/spec/spec_helper.rb +0 -9
- data/what3words.gemspec +0 -31
data/lib/what3words/api.rb
CHANGED
@@ -1,21 +1,18 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'rest-client'
|
4
|
+
require 'json'
|
4
5
|
require File.expand_path('../version', __FILE__)
|
5
6
|
require 'what3words/version'
|
6
7
|
|
7
8
|
module What3Words
|
8
9
|
# What3Words v3 API wrapper
|
9
|
-
class API
|
10
|
-
# This class provides an interface to the what3words API
|
11
|
-
# at https://developer.what3words.com/public-api/docs
|
10
|
+
class API
|
12
11
|
class Error < RuntimeError; end
|
13
12
|
class ResponseError < Error; end
|
14
13
|
class WordError < Error; end
|
15
14
|
|
16
|
-
REGEX_3_WORD_ADDRESS =
|
17
|
-
REGEX_STRICT = /^\p{L}{3,}+\.\p{L}{3,}+\.\p{L}{3,}+$/u.freeze
|
18
|
-
|
15
|
+
REGEX_3_WORD_ADDRESS = /^\/{0,3}(?:[^0-9`~!@#$%^&*()+\-_=\[\{\]}\\|'<,.>?\/\";:£§º©®\s]{1,}[.\uFF61\u3002\uFF65\u30FB\uFE12\u17D4\u0964\u1362\u3002][^0-9`~!@#$%^&*()+\-_=\[\{\]}\\|'<,.>?\/\";:£§º©®\s]{1,}[.\uFF61\u3002\uFF65\u30FB\uFE12\u17D4\u0964\u1362\u3002][^0-9`~!@#$%^&*()+\-_=\[\{\]}\\|'<,.>?\/\";:£§º©®\s]{1,}|'<,.>?\/\";:£§º©®\s]+[.\uFF61\u3002\uFF65\u30FB\uFE12\u17D4\u0964\u1362\u3002][^0-9`~!@#$%^&*()+\-_=\[\{\]}\\|'<,.>?\/\";:£§º©®\s]+|[^0-9`~!@#$%^&*()+\-_=\[\{\]}\\|'<,.>?\/\";:£§º©®\s]+([\u0020\u00A0][^0-9`~!@#$%^&*()+\-_=\[\{\]}\\|'<,.>?\/\";:£§º©®\s]+){1,3}[.\uFF61\u3002\uFF65\u30FB\uFE12\u17D4\u0964\u1362\u3002][^0-9`~!@#$%^&*()+\-_=\[\{\]}\\|'<,.>?\/\";:£§º©®\s]+([\u0020\u00A0][^0-9`~!@#$%^&*()+\-_=\[\{\]}\\|'<,.>?\/\";:£§º©®\s]+){1,3}[.\uFF61\u3002\uFF65\u30FB\uFE12\u17D4\u0964\u1362\u3002][^0-9`~!@#$%^&*()+\-_=\[\{\]}\\|'<,.>?\/\";:£§º©®\s]+([\u0020\u00A0][^0-9`~!@#$%^&*()+\-_=\[\{\]}\\|'<,.>?\/\";:£§º©®\s]+){1,3})$/u.freeze
|
19
16
|
BASE_URL = 'https://api.what3words.com/v3/'
|
20
17
|
|
21
18
|
ENDPOINTS = {
|
@@ -35,229 +32,217 @@ module What3Words
|
|
35
32
|
attr_reader :key
|
36
33
|
|
37
34
|
def convert_to_coordinates(words, params = {})
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
35
|
+
"""
|
36
|
+
Take a 3 word address and turn it into a pair of coordinates.
|
37
|
+
|
38
|
+
Params
|
39
|
+
------
|
40
|
+
:param string words: A 3 word address as a string
|
41
|
+
:param string format: Return data format type; can be one of json (the default), geojson
|
42
|
+
:rtype: Hash
|
43
|
+
"""
|
44
|
+
words_string = get_words_string(words)
|
43
45
|
request_params = assemble_convert_to_coordinates_request_params(words_string, params)
|
44
|
-
|
45
|
-
response
|
46
|
+
request!(:convert_to_coordinates, request_params)
|
46
47
|
end
|
47
48
|
|
48
49
|
def convert_to_3wa(position, params = {})
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
50
|
+
"""
|
51
|
+
Take latitude and longitude coordinates and turn them into a 3 word address.
|
52
|
+
|
53
|
+
Params
|
54
|
+
------
|
55
|
+
:param array position: The coordinates of the location to convert to 3 word address
|
56
|
+
:param string format: Return data format type; can be one of json (the default), geojson
|
57
|
+
:param string language: A supported 3 word address language as an ISO 639-1 2 letter code.
|
58
|
+
:rtype: Hash
|
59
|
+
"""
|
54
60
|
request_params = assemble_convert_to_3wa_request_params(position, params)
|
55
|
-
|
56
|
-
response
|
61
|
+
request!(:convert_to_3wa, request_params)
|
57
62
|
end
|
58
63
|
|
59
64
|
def grid_section(bbox, params = {})
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
+
"""
|
66
|
+
Returns a section of the 3m x 3m what3words grid for a given area.
|
67
|
+
|
68
|
+
Params
|
69
|
+
------
|
70
|
+
:param string bbox: Bounding box, specified by the northeast and southwest corner coordinates,
|
71
|
+
:param string format: Return data format type; can be one of json (the default), geojson
|
72
|
+
:rtype: Hash
|
73
|
+
"""
|
65
74
|
request_params = assemble_grid_request_params(bbox, params)
|
66
|
-
|
67
|
-
response
|
75
|
+
request!(:grid_section, request_params)
|
68
76
|
end
|
69
77
|
|
70
78
|
def available_languages
|
71
|
-
|
72
|
-
|
79
|
+
"""
|
80
|
+
Retrieve a list of available 3 word languages.
|
81
|
+
|
82
|
+
:rtype: Hash
|
83
|
+
"""
|
73
84
|
request_params = assemble_common_request_params({})
|
74
|
-
|
75
|
-
response
|
85
|
+
request!(:available_languages, request_params)
|
76
86
|
end
|
77
87
|
|
78
88
|
def autosuggest(input, params = {})
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
# For convenience, longitude is allowed to wrap around 180 degrees. For example 181 is equivalent to -179.
|
98
|
-
# @:param clip-to-polygon: Restrict autosuggest results to a polygon, specified by a list of coordinates.
|
99
|
-
# The polygon should be closed, i.e. the first element should be repeated as the
|
100
|
-
# last element; also the list should contain at least 4 entries.
|
101
|
-
# The API is currently limited to accepting up to 25 pairs.
|
102
|
-
# @:param string input-type: For power users, used to specify voice input mode.
|
103
|
-
# Can be text (default), vocon-hybrid, nmdp-asr or generic-voice.
|
104
|
-
# @:param string prefer-land: Makes autosuggest prefer results on land to those in the sea.
|
105
|
-
# @:param string language: A supported 3 word address language as an ISO 639-1 2 letter code.
|
106
|
-
# This setting is on by default. Use false to disable this setting and receive more suggestions in the sea.
|
107
|
-
|
108
|
-
# API Reference: https://docs.what3words.com/api/v3/#autosuggest
|
89
|
+
"""
|
90
|
+
Returns a list of 3 word addresses based on user input and other parameters.
|
91
|
+
|
92
|
+
Params
|
93
|
+
------
|
94
|
+
:param string input: The full or partial 3 word address to obtain suggestions for.
|
95
|
+
:param int n_results: The number of AutoSuggest results to return.
|
96
|
+
:param array focus: A location, specified as a latitude,longitude used to refine the results.
|
97
|
+
:param int n_focus_results: Specifies the number of results (must be <= n_results) within the results set which will have a focus.
|
98
|
+
:param string clip_to_country: Restricts autosuggest to only return results inside the countries specified by comma-separated list of uppercase ISO 3166-1 alpha-2 country codes.
|
99
|
+
:param array clip_to_bounding_box: Restrict autosuggest results to a bounding box, specified by coordinates.
|
100
|
+
:param array clip_to_circle: Restrict autosuggest results to a circle, specified by the center of the circle, latitude and longitude, and a distance in kilometres which represents the radius.
|
101
|
+
:param array clip_to_polygon: Restrict autosuggest results to a polygon, specified by a list of coordinates.
|
102
|
+
:param string input_type: For power users, used to specify voice input mode. Can be text (default), vocon-hybrid, nmdp-asr or generic-voice.
|
103
|
+
:param string prefer_land: Makes autosuggest prefer results on land to those in the sea.
|
104
|
+
:param string language: A supported 3 word address language as an ISO 639-1 2 letter code.
|
105
|
+
:rtype: Hash
|
106
|
+
"""
|
109
107
|
request_params = assemble_autosuggest_request_params(input, params)
|
110
|
-
|
111
|
-
|
108
|
+
request!(:autosuggest, request_params)
|
109
|
+
end
|
110
|
+
|
111
|
+
def isPossible3wa(text)
|
112
|
+
"""
|
113
|
+
Determines if the string passed in is the form of a three word address.
|
114
|
+
This does not validate whether it is a real address as it returns true for x.x.x
|
115
|
+
|
116
|
+
Params
|
117
|
+
------
|
118
|
+
:param string text: text to check
|
119
|
+
:rtype: Boolean
|
120
|
+
"""
|
121
|
+
regex_match = REGEX_3_WORD_ADDRESS
|
122
|
+
!(text.match(regex_match).nil?)
|
123
|
+
end
|
124
|
+
|
125
|
+
def findPossible3wa(text)
|
126
|
+
"""
|
127
|
+
Searches the string passed in for all substrings in the form of a three word address.
|
128
|
+
This does not validate whether it is a real address as it will return x.x.x as a result
|
129
|
+
|
130
|
+
Params
|
131
|
+
------
|
132
|
+
:param string text: text to check
|
133
|
+
:rtype: Array
|
134
|
+
"""
|
135
|
+
regex_search = /[^0-9`~!@#$%^&*()+\-_=\[\{\]}\\|'<,.>?\/\";:£§º©®\s]{1,}[.\uFF61\u3002\uFF65\u30FB\uFE12\u17D4\u0964\u1362\u3002][^0-9`~!@#$%^&*()+\-_=\[\{\]}\\|'<,.>?\/\";:£§º©®\s]{1,}[.\uFF61\u3002\uFF65\u30FB\uFE12\u17D4\u0964\u1362\u3002][^0-9`~!@#$%^&*()+\-_=\[\{\]}\\|'<,.>?\/\";:£§º©®\s]{1,}/
|
136
|
+
text.scan(regex_search)
|
137
|
+
end
|
138
|
+
|
139
|
+
def didYouMean(text)
|
140
|
+
"""
|
141
|
+
Determines if the string passed in is almost in the form of a three word address.
|
142
|
+
This will return True for values such as 'filled-count-soap' and 'filled count soap'
|
143
|
+
|
144
|
+
Params
|
145
|
+
------
|
146
|
+
:param string text: text to check
|
147
|
+
:rtype: Boolean
|
148
|
+
"""
|
149
|
+
regex_match = /^\/?[^0-9`~!@#$%^&*()+\-_=\[\{\]}\\|'<,.>?\/\";:£§º©®\s]{1,}[.\uFF61\u3002\uFF65\u30FB\uFE12\u17D4\u0964\u1362\u3002 ,\\\-\/+'&\\:;|\u3000]{1,2}[^0-9`~!@#$%^&*()+\-_=\[\{\]}\\|'<,.>?\/\";:£§º©®\s]{1,}[.\uFF61\u3002\uFF65\u30FB\uFE12\u17D4\u0964\u1362\u3002 ,\\\-\/+'&\\:;|\u3000]{1,2}[^0-9`~!@#$%^&*()+\-_=\[\{\]}\\|'<,.>?\/\";:£§º©®\s]{1,}$/
|
150
|
+
!(text.match(regex_match).nil?)
|
151
|
+
end
|
152
|
+
|
153
|
+
def isValid3wa(text)
|
154
|
+
"""
|
155
|
+
Determines if the string passed in is a real three word address. It calls the API
|
156
|
+
to verify it refers to an actual place on earth.
|
157
|
+
|
158
|
+
Params
|
159
|
+
------
|
160
|
+
:param String text: text to check
|
161
|
+
|
162
|
+
:rtype: Boolean
|
163
|
+
"""
|
164
|
+
if isPossible3wa(text)
|
165
|
+
result = autosuggest(text, 'n-results': 1)
|
166
|
+
if result[:suggestions] && result[:suggestions].length > 0
|
167
|
+
return result[:suggestions][0][:words] == text
|
168
|
+
end
|
169
|
+
end
|
170
|
+
false
|
112
171
|
end
|
113
172
|
|
114
|
-
|
115
|
-
# Return common request params
|
116
|
-
# @:param api_key: A valid API key
|
117
|
-
# @:param string language: A supported 3 word address language as an ISO 639-1 2 letter code.
|
118
|
-
# @:param string format: Return data format type; can be one of json (the default), geojson
|
119
|
-
h = { key: key }
|
120
|
-
h[:language] = params[:language] if params[:language]
|
121
|
-
h[:format] = params[:format] if params[:format]
|
122
|
-
h
|
123
|
-
end
|
124
|
-
private :assemble_common_request_params
|
173
|
+
private
|
125
174
|
|
126
|
-
def
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
h.merge(assemble_common_request_params(params))
|
131
|
-
end
|
132
|
-
private :assemble_convert_to_coordinates_request_params
|
175
|
+
def request!(endpoint_name, params)
|
176
|
+
headers = { "X-W3W-Wrapper": "what3words-Ruby/#{WRAPPER_VERSION}" }
|
177
|
+
response = RestClient.get(endpoint(endpoint_name), params: params, headers: headers)
|
178
|
+
parsed_response = JSON.parse(response.body)
|
133
179
|
|
134
|
-
|
135
|
-
# Return request params for the convert to 3wa function
|
136
|
-
# @:param coordinates: the coordinates of the location to convert to 3 word address
|
137
|
-
h = { coordinates: position.join(',') }
|
138
|
-
h.merge(assemble_common_request_params(params))
|
139
|
-
end
|
140
|
-
private :assemble_convert_to_3wa_request_params
|
180
|
+
raise ResponseError, "#{parsed_response['code']}: #{parsed_response['message']}" if parsed_response['error'].to_s.strip != ''
|
141
181
|
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
# southwest corner coordinates, for which the grid should be returned.
|
146
|
-
h = { 'bounding-box': bbox }
|
147
|
-
h.merge(assemble_common_request_params(params))
|
182
|
+
deep_symbolize_keys(parsed_response)
|
183
|
+
rescue RestClient::ExceptionWithResponse => e
|
184
|
+
handle_rest_client_error(e)
|
148
185
|
end
|
149
|
-
private :assemble_grid_request_params
|
150
186
|
|
151
|
-
def
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
# at least one character from the third word.
|
156
|
-
# @:param int n_results: The number of AutoSuggest results to return.
|
157
|
-
# A maximum of 100 results can be specified, if a number greater than this is requested,
|
158
|
-
# this will be truncated to the maximum. The default is 3.
|
159
|
-
# @:param int n_focus_results: Specifies the number of results (must be <= n_results)
|
160
|
-
# within the results set which will have a focus. Defaults to n_results.
|
161
|
-
# This allows you to run autosuggest with a mix of
|
162
|
-
# focussed and unfocussed results, to give you a "blend" of the two.
|
163
|
-
# @:param string clip-to-country: Restricts autosuggest to only return results inside
|
164
|
-
# the countries specified by comma-separated list of uppercase ISO 3166-1
|
165
|
-
# alpha-2 country codes (for example, to restrict to Belgium and the UK,
|
166
|
-
# use clip_to_country="GB,BE").
|
167
|
-
# @:param clip-to-bounding-box: Restrict autosuggest results to a bounding box, specified by coordinates.
|
168
|
-
# @:param clip-to-circle: Restrict autosuggest results to a circle, specified by
|
169
|
-
# the center of the circle, latitude and longitude, and a distance in kilometres
|
170
|
-
# which represents the radius. For convenience, longitude
|
171
|
-
# is allowed to wrap around 180 degrees. For example 181 is equivalent to -179.
|
172
|
-
# @:param clip-to-polygon: Restrict autosuggest results to a polygon, specified by a list of coordinates.
|
173
|
-
# The polygon should be closed, i.e. the first element should be repeated as the
|
174
|
-
# last element; also the list should contain at least 4 entries.
|
175
|
-
# The API is currently limited to accepting up to 25 pairs.
|
176
|
-
# @:param string input-type: For power users, used to specify voice input mode.
|
177
|
-
# Can be text (default), vocon-hybrid, nmdp-asr or generic-voice.
|
178
|
-
# @:param string prefer-land: Makes autosuggest prefer results on land to those in the sea.
|
179
|
-
h = { input: input }
|
180
|
-
h[:'n-results'] = params[:'n-results'].to_i if params[:'n-results']
|
181
|
-
h[:focus] = params[:focus].join(',') if params[:focus].respond_to? :join
|
182
|
-
h[:'n-focus-results'] = params[:'n-focus-results'].to_i if params[:'n-focus-results']
|
183
|
-
h[:'clip-to-country'] = params[:'clip-to-country'] if params[:'clip-to-country'].respond_to? :to_str
|
184
|
-
h[:'clip-to-bounding-box'] = params[:'clip-to-bounding-box'].join(',') if params[:'clip-to-bounding-box'].respond_to? :join
|
185
|
-
h[:'clip-to-circle'] = params[:'clip-to-circle'].join(',') if params[:'clip-to-circle'].respond_to? :join
|
186
|
-
h[:'clip-to-polygon'] = params[:'clip-to-polygon'].join(',') if params[:'clip-to-polygon'].respond_to? :join
|
187
|
-
h[:'input-type'] = params[:'input-type'] if params[:'input-type'].respond_to? :to_str
|
188
|
-
h[:'prefer-land'] = params[:'prefer-land'] if params[:'prefer-land']
|
189
|
-
h.merge(assemble_common_request_params(params))
|
187
|
+
def handle_rest_client_error(error)
|
188
|
+
parsed_response = JSON.parse(error.response)
|
189
|
+
raise ResponseError, "#{parsed_response['code']}: #{parsed_response['message']}" if parsed_response['error']
|
190
|
+
raise error
|
190
191
|
end
|
191
|
-
private :assemble_autosuggest_request_params
|
192
|
-
|
193
|
-
def request!(endpoint_name, params)
|
194
|
-
# Defines HTTP request methods
|
195
|
-
# puts endpoint(endpoint_name).inspect
|
196
|
-
# puts params.inspect
|
197
|
-
begin
|
198
|
-
headers = { "X-W3W-Wrapper": "what3words-Ruby/#{WRAPPER_VERSION}" }
|
199
|
-
response = RestClient.get endpoint(endpoint_name), params: params, headers: headers
|
200
|
-
rescue => e
|
201
|
-
# puts e.inspect
|
202
|
-
# puts e.methods.sort
|
203
|
-
response = e.response
|
204
|
-
end
|
205
|
-
# puts '#{response.to_str}'
|
206
|
-
# puts 'Response status: #{response.code}'
|
207
|
-
response = JSON.parse(response.body)
|
208
|
-
# puts response.inspect
|
209
192
|
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
193
|
+
def get_words_string(words)
|
194
|
+
words_string = words.is_a?(Array) ? words.join('.') : words.to_s
|
195
|
+
check_words(words_string)
|
196
|
+
words_string
|
197
|
+
end
|
215
198
|
|
199
|
+
def check_words(words)
|
200
|
+
raise WordError, "#{words} is not a valid 3 word address" unless REGEX_3_WORD_ADDRESS.match?(words)
|
216
201
|
end
|
217
|
-
private :request!
|
218
202
|
|
219
|
-
def
|
220
|
-
|
221
|
-
if words.respond_to? :to_str
|
222
|
-
w = words
|
223
|
-
elsif words.respond_to? :join
|
224
|
-
w = words.join('.')
|
225
|
-
else
|
226
|
-
raise Error, "Cannot get words string for #{words.inspect}"
|
227
|
-
end
|
228
|
-
check_words w
|
203
|
+
def assemble_common_request_params(params)
|
204
|
+
{ key: key }.merge(params.slice(:language, :format))
|
229
205
|
end
|
230
|
-
private :get_words_string
|
231
206
|
|
232
|
-
def
|
233
|
-
|
234
|
-
|
235
|
-
end
|
207
|
+
def assemble_convert_to_coordinates_request_params(words_string, params)
|
208
|
+
{ words: words_string }.merge(assemble_common_request_params(params))
|
209
|
+
end
|
236
210
|
|
237
|
-
|
211
|
+
def assemble_convert_to_3wa_request_params(position, params)
|
212
|
+
{ coordinates: position.join(',') }.merge(assemble_common_request_params(params))
|
238
213
|
end
|
239
|
-
private :check_words
|
240
|
-
|
241
|
-
def deep_symbolize_keys(i)
|
242
|
-
if i.is_a? Hash
|
243
|
-
ni = {}
|
244
|
-
i.each { |k, v| ni[k.respond_to?(:to_sym) ? k.to_sym : k] = deep_symbolize_keys(v) }
|
245
|
-
elsif i.is_a? Array
|
246
|
-
ni = i.map(&method(:deep_symbolize_keys))
|
247
|
-
else
|
248
|
-
ni = i
|
249
|
-
end
|
250
214
|
|
251
|
-
|
215
|
+
def assemble_grid_request_params(bbox, params)
|
216
|
+
{ 'bounding-box': bbox }.merge(assemble_common_request_params(params))
|
252
217
|
end
|
253
218
|
|
254
|
-
def
|
255
|
-
|
219
|
+
def assemble_autosuggest_request_params(input, params)
|
220
|
+
result = { input: input }
|
221
|
+
result[:'n-results'] = params[:'n-results'].to_i if params[:'n-results']
|
222
|
+
result[:focus] = params[:focus].join(',') if params[:focus].respond_to?(:join)
|
223
|
+
result[:'n-focus-results'] = params[:'n-focus-results'].to_i if params[:'n-focus-results']
|
224
|
+
result[:'clip-to-country'] = params[:'clip-to-country'] if params[:'clip-to-country'].respond_to?(:to_str)
|
225
|
+
result[:'clip-to-bounding-box'] = params[:'clip-to-bounding-box'].join(',') if params[:'clip-to-bounding-box'].respond_to?(:join)
|
226
|
+
result[:'clip-to-circle'] = params[:'clip-to-circle'].join(',') if params[:'clip-to-circle'].respond_to?(:join)
|
227
|
+
result[:'clip-to-polygon'] = params[:'clip-to-polygon'].join(',') if params[:'clip-to-polygon'].respond_to?(:join)
|
228
|
+
result[:'input-type'] = params[:'input-type'] if params[:'input-type'].respond_to?(:to_str)
|
229
|
+
result[:'prefer-land'] = params[:'prefer-land'] if params[:'prefer-land']
|
230
|
+
result.merge(assemble_common_request_params(params))
|
231
|
+
end
|
232
|
+
|
233
|
+
def deep_symbolize_keys(value)
|
234
|
+
case value
|
235
|
+
when Hash
|
236
|
+
value.transform_keys(&:to_sym).transform_values { |v| deep_symbolize_keys(v) }
|
237
|
+
when Array
|
238
|
+
value.map { |v| deep_symbolize_keys(v) }
|
239
|
+
else
|
240
|
+
value
|
241
|
+
end
|
256
242
|
end
|
257
|
-
private :base_url
|
258
243
|
|
259
244
|
def endpoint(name)
|
260
|
-
|
245
|
+
BASE_URL + ENDPOINTS.fetch(name)
|
261
246
|
end
|
262
247
|
end
|
263
248
|
end
|
data/lib/what3words/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: what3words
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- what3words
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-07-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -100,31 +100,23 @@ dependencies:
|
|
100
100
|
- - "~>"
|
101
101
|
- !ruby/object:Gem::Version
|
102
102
|
version: '3.0'
|
103
|
-
description: A Ruby wrapper
|
103
|
+
description: A Ruby wrapper for the what3words API
|
104
104
|
email:
|
105
105
|
- development@what3words.com
|
106
106
|
executables: []
|
107
107
|
extensions: []
|
108
108
|
extra_rdoc_files: []
|
109
109
|
files:
|
110
|
-
- ".editorconfig"
|
111
|
-
- ".gitignore"
|
112
|
-
- ".travis.yml"
|
113
|
-
- Gemfile
|
114
|
-
- LICENSE.txt
|
115
110
|
- README.md
|
116
|
-
- Rakefile
|
117
111
|
- lib/what3words.rb
|
118
112
|
- lib/what3words/api.rb
|
119
113
|
- lib/what3words/version.rb
|
120
|
-
|
121
|
-
- spec/lib/what3words/what3words_api_spec.rb
|
122
|
-
- spec/spec_helper.rb
|
123
|
-
- what3words.gemspec
|
124
|
-
homepage: http://rubygems.org/gems/what3words
|
114
|
+
homepage: https://github.com/what3words/w3w-ruby-wrapper
|
125
115
|
licenses:
|
126
116
|
- MIT
|
127
|
-
metadata:
|
117
|
+
metadata:
|
118
|
+
documentation_uri: https://www.rubydoc.info/gems/what3words
|
119
|
+
source_code_uri: https://github.com/what3words/w3w-ruby-wrapper
|
128
120
|
post_install_message:
|
129
121
|
rdoc_options: []
|
130
122
|
require_paths:
|
@@ -140,11 +132,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
140
132
|
- !ruby/object:Gem::Version
|
141
133
|
version: '0'
|
142
134
|
requirements: []
|
143
|
-
rubygems_version: 3.0.3
|
135
|
+
rubygems_version: 3.0.3.1
|
144
136
|
signing_key:
|
145
137
|
specification_version: 4
|
146
138
|
summary: Ruby wrapper for the what3words API
|
147
|
-
test_files:
|
148
|
-
- spec/config.sample.yaml
|
149
|
-
- spec/lib/what3words/what3words_api_spec.rb
|
150
|
-
- spec/spec_helper.rb
|
139
|
+
test_files: []
|
data/.editorconfig
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
# EditorConfig is awesome: http://EditorConfig.org
|
2
|
-
|
3
|
-
# top-most EditorConfig file
|
4
|
-
root = true
|
5
|
-
|
6
|
-
# Unix-style newlines with a newline ending every file
|
7
|
-
[*]
|
8
|
-
end_of_line = lf
|
9
|
-
insert_final_newline = true
|
10
|
-
trim_trailing_whitespace = true
|
11
|
-
|
12
|
-
# Set default charset
|
13
|
-
charset = utf-8
|
14
|
-
|
15
|
-
# Indentation
|
16
|
-
indent_style = space
|
17
|
-
indent_size = 2
|
data/.gitignore
DELETED
data/.travis.yml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
rvm:
|
3
|
-
- 2.4
|
4
|
-
script: rake rubocop spec
|
5
|
-
notifications:
|
6
|
-
slack:
|
7
|
-
secure: DvejcrOH6RdAdrGEPLUrnia9cES8iCHVlVSFAMwx2vaR/I3T9bfUiHnb3VHfiqx4cvDL+9wT3opG0sZkUCFJGqzA3E//VObKNXjwUFCUptFG68qgR7LZ3vDatWlUqU+32gWeYaHM3FpNP2E/IARjphaiF3jRUZbronqVzJZN2MbMsUYBeGq7v0AaLkgbxVgOWtBnMVcBPOnarEJqHyJlqQ2unYnIy+GNoOFtPMPNZobYTf0zxrycldYpP937yT4CTsY3I7RxuEtnY2sPYW+eFBESGLg6EfnjeOruROY+b9cSHIh1Qzr7Oup6a+oQ3+vCvLbYsGpEO04RTeTTtOGc7aRlUylmvuFPi7qQwOTZ+4KD5aIBh4p7bQiPfvAeqDU4pVJxPHHZirgjFpUpAvofj48SvDgwX9cFyAhAlDZ9qBOctmhphW9KNkcAW4MY421AdVAjFWwc5CU8G5oPdKcyWam3ZB3nHwKgZm6LLAcZgbG0rjZT+iPeQBvTKH3kPx7E1CkxZNkEralHJ3l+bDwY3GdzsgcMpT3bWNl3pLszFzgXljDScMU8my1+xjDQINEnI3TCJA4MhKkzYkRgfrEBkgPb2SiF7qnhbyMzSFbCU4jsM1MLQZolNG9EsjsxJLuL4YTC2wKOHajViUUeaCNIcNU5UXBQuit93RyMu7RrLRM=
|
data/Gemfile
DELETED
data/LICENSE.txt
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
Copyright (c) 2016, 2017 What3Words Limited
|
2
|
-
|
3
|
-
MIT License
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
-
a copy of this software and associated documentation files (the
|
7
|
-
"Software"), to deal in the Software without restriction, including
|
8
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
-
permit persons to whom the Software is furnished to do so, subject to
|
11
|
-
the following conditions:
|
12
|
-
|
13
|
-
The above copyright notice and this permission notice shall be
|
14
|
-
included in all copies or substantial portions of the Software.
|
15
|
-
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'bundler/gem_tasks'
|
4
|
-
|
5
|
-
begin
|
6
|
-
require 'rubocop/rake_task'
|
7
|
-
RuboCop::RakeTask.new(:rubocop) do |t|
|
8
|
-
t.options = ['--display-cop-names']
|
9
|
-
end
|
10
|
-
require 'rspec/core/rake_task'
|
11
|
-
RSpec::Core::RakeTask.new(:spec)
|
12
|
-
rescue LoadError => e
|
13
|
-
print e
|
14
|
-
end
|
data/spec/config.sample.yaml
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
# config.sample.yaml
|