what3words 3.2.0 → 3.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -1
- data/lib/what3words/api.rb +23 -5
- data/lib/what3words/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f248d7e71dde2539d4ff68361b8560a14d751f708f94dfa8764fbe7d049204c2
|
4
|
+
data.tar.gz: 60bc224aa58cfc974cb13398bfe350183f08c7e1b6975ed8358285a165bcf342
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 88a70bb9e8776928983187642b612cccde290e09605d23ad9e56d448cc75fa980f53fbb97bf9a69b9785ce293a35fe07a789842279110a17532210e7a3010ca6
|
7
|
+
data.tar.gz: 737b661041690c70ee27dc19a9f7e5096f6440577ca36a0a618d97459e183d411019d85a18608c5ca2f71af73a91bc7cc966a1fe88261b67522de246c02f79d2
|
data/README.md
CHANGED
@@ -15,7 +15,7 @@ The library is available through [RubyGems](https://rubygems.org/gems/what3words
|
|
15
15
|
You can simply add this line to your application's Gemfile:
|
16
16
|
|
17
17
|
```
|
18
|
-
gem 'what3words', '~> 3.
|
18
|
+
gem 'what3words', '~> 3.3'
|
19
19
|
```
|
20
20
|
|
21
21
|
And then execute:
|
@@ -438,6 +438,7 @@ Anyone and everyone is welcome to contribute.
|
|
438
438
|
|
439
439
|
# Revision History
|
440
440
|
|
441
|
+
* `v3.3.0` 12/08/24 - Update error message to handle c2c calls and dependencies
|
441
442
|
* `v3.2.0` 17/07/24 - Update regex patterns
|
442
443
|
* `v3.1.0` 16/07/24 - Update tests and code to host the regex functions
|
443
444
|
* `v3.0.0` 12/05/22 - Update endpoints and tests to API v3, added HTTP headers
|
data/lib/what3words/api.rb
CHANGED
@@ -9,7 +9,8 @@ module What3Words
|
|
9
9
|
# What3Words v3 API wrapper
|
10
10
|
class API
|
11
11
|
class Error < RuntimeError; end
|
12
|
-
class ResponseError < Error; end
|
12
|
+
# class ResponseError < Error; end
|
13
|
+
class ResponseError < StandardError; end
|
13
14
|
class WordError < Error; end
|
14
15
|
|
15
16
|
REGEX_3_WORD_ADDRESS = /^\/*(?:[^0-9`~!@#$%^&*()+\-_=\[\{\]}\\|'<>.,?\/\";:£§º©®\s]{1,}[.。。・・︒។։။۔።।][^0-9`~!@#$%^&*()+\-_=\[\{\]}\\|'<>.,?\/\";:£§º©®\s]{1,}[.。。・・︒។։။۔።।][^0-9`~!@#$%^&*()+\-_=\[\{\]}\\|'<>.,?\/\";:£§º©®\s]{1,}|[<.,>?\/\";:£§º©®\s]+[.。。・・︒។։။۔።।][^0-9`~!@#$%^&*()+\-_=\[\{\]}\\|'<>.,?\/\";:£§º©®\s]+|[^0-9`~!@#$%^&*()+\-_=\[\{\]}\\|'<>.,?\/\";:£§º©®\s]+([\u0020\u00A0][^0-9`~!@#$%^&*()+\-_=\[\{\]}\\|'<>.,?\/\";:£§º©®\s]+){1,3}[.。。・・︒។։။۔።।][^0-9`~!@#$%^&*()+\-_=\[\{\]}\\|'<>.,?\/\";:£§º©®\s]+([\u0020\u00A0][^0-9`~!@#$%^&*()+\-_=\[\{\]}\\|'<>.,?\/\";:£§º©®\s]+){1,3}[.。。・・︒។։။۔።।][^0-9`~!@#$%^&*()+\-_=\[\{\]}\\|'<>.,?\/\";:£§º©®\s]+([\u0020\u00A0][^0-9`~!@#$%^&*()+\-_=\[\{\]}\\|'<>.,?\/\";:£§º©®\s]+){1,3})$/u.freeze
|
@@ -177,17 +178,34 @@ module What3Words
|
|
177
178
|
response = RestClient.get(endpoint(endpoint_name), params: params, headers: headers)
|
178
179
|
parsed_response = JSON.parse(response.body)
|
179
180
|
|
180
|
-
|
181
|
+
if parsed_response['error']
|
182
|
+
error_code = parsed_response['error']['code']
|
183
|
+
error_message = parsed_response['error']['message']
|
184
|
+
raise ResponseError, "#{error_code}: #{error_message}"
|
185
|
+
end
|
181
186
|
|
182
187
|
deep_symbolize_keys(parsed_response)
|
183
188
|
rescue RestClient::ExceptionWithResponse => e
|
184
189
|
handle_rest_client_error(e)
|
190
|
+
rescue RestClient::Exception => e
|
191
|
+
raise ResponseError, "RestClient error: #{e.message}"
|
185
192
|
end
|
186
193
|
|
187
194
|
def handle_rest_client_error(error)
|
188
|
-
|
189
|
-
|
190
|
-
|
195
|
+
response = error.response
|
196
|
+
begin
|
197
|
+
parsed_response = JSON.parse(response.body)
|
198
|
+
rescue JSON::ParserError
|
199
|
+
raise ResponseError, "Invalid JSON response: #{response}"
|
200
|
+
end
|
201
|
+
|
202
|
+
if parsed_response['error']
|
203
|
+
error_code = parsed_response['error']['code']
|
204
|
+
error_message = parsed_response['error']['message']
|
205
|
+
raise ResponseError, "#{error_code}: #{error_message}"
|
206
|
+
else
|
207
|
+
raise ResponseError, "Unknown error: #{response}"
|
208
|
+
end
|
191
209
|
end
|
192
210
|
|
193
211
|
def get_words_string(words)
|
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.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- what3words
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-08-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -50,14 +50,14 @@ dependencies:
|
|
50
50
|
requirements:
|
51
51
|
- - "~>"
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: '
|
53
|
+
version: '12.3'
|
54
54
|
type: :development
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
57
|
requirements:
|
58
58
|
- - "~>"
|
59
59
|
- !ruby/object:Gem::Version
|
60
|
-
version: '
|
60
|
+
version: '12.3'
|
61
61
|
- !ruby/object:Gem::Dependency
|
62
62
|
name: rspec
|
63
63
|
requirement: !ruby/object:Gem::Requirement
|
@@ -78,14 +78,14 @@ dependencies:
|
|
78
78
|
requirements:
|
79
79
|
- - "~>"
|
80
80
|
- !ruby/object:Gem::Version
|
81
|
-
version: 0.
|
81
|
+
version: 0.49.0
|
82
82
|
type: :development
|
83
83
|
prerelease: false
|
84
84
|
version_requirements: !ruby/object:Gem::Requirement
|
85
85
|
requirements:
|
86
86
|
- - "~>"
|
87
87
|
- !ruby/object:Gem::Version
|
88
|
-
version: 0.
|
88
|
+
version: 0.49.0
|
89
89
|
- !ruby/object:Gem::Dependency
|
90
90
|
name: webmock
|
91
91
|
requirement: !ruby/object:Gem::Requirement
|