what3words 2.0.4 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +2 -2
- data/Gemfile +3 -1
- data/LICENSE.txt +1 -1
- data/README.md +175 -69
- data/Rakefile +9 -4
- data/lib/what3words/api.rb +160 -75
- data/lib/what3words/version.rb +4 -1
- data/lib/what3words.rb +4 -2
- data/spec/lib/what3words/what3words_api_spec.rb +248 -66
- data/spec/spec_helper.rb +5 -3
- data/what3words.gemspec +20 -16
- metadata +31 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: a4a3183f709f4e5dedca75618f0a486d62f6e4d99f1e2d8709a1cc16837fefa8
|
4
|
+
data.tar.gz: 0700e12fafc5949b57f03bb750f2c01efc86a2df198eca6dc71b36472957f561
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 05f7639c6f66e11eb961629696cea9b6f79ea2d1df3ccf4eaf0fb061b2e247ce806d5cf9e0abe94f92ce04b3acefc83ee4179c91c54a1fc3f171fd37fa22c1d0
|
7
|
+
data.tar.gz: 1559cbe46257ab28cf6a97b08c52a4ffc47544e3e71a6215e845d36246b79845e08afcb783478a8ba08cf399cabc9e2abba995f9b410380cc2a34a2820a765da
|
data/.travis.yml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
language: ruby
|
2
2
|
rvm:
|
3
|
-
- 2.
|
4
|
-
script: rake spec
|
3
|
+
- 2.4
|
4
|
+
script: rake rubocop spec
|
5
5
|
notifications:
|
6
6
|
slack:
|
7
7
|
secure: DvejcrOH6RdAdrGEPLUrnia9cES8iCHVlVSFAMwx2vaR/I3T9bfUiHnb3VHfiqx4cvDL+9wT3opG0sZkUCFJGqzA3E//VObKNXjwUFCUptFG68qgR7LZ3vDatWlUqU+32gWeYaHM3FpNP2E/IARjphaiF3jRUZbronqVzJZN2MbMsUYBeGq7v0AaLkgbxVgOWtBnMVcBPOnarEJqHyJlqQ2unYnIy+GNoOFtPMPNZobYTf0zxrycldYpP937yT4CTsY3I7RxuEtnY2sPYW+eFBESGLg6EfnjeOruROY+b9cSHIh1Qzr7Oup6a+oQ3+vCvLbYsGpEO04RTeTTtOGc7aRlUylmvuFPi7qQwOTZ+4KD5aIBh4p7bQiPfvAeqDU4pVJxPHHZirgjFpUpAvofj48SvDgwX9cFyAhAlDZ9qBOctmhphW9KNkcAW4MY421AdVAjFWwc5CU8G5oPdKcyWam3ZB3nHwKgZm6LLAcZgbG0rjZT+iPeQBvTKH3kPx7E1CkxZNkEralHJ3l+bDwY3GdzsgcMpT3bWNl3pLszFzgXljDScMU8my1+xjDQINEnI3TCJA4MhKkzYkRgfrEBkgPb2SiF7qnhbyMzSFbCU4jsM1MLQZolNG9EsjsxJLuL4YTC2wKOHajViUUeaCNIcNU5UXBQuit93RyMu7RrLRM=
|
data/Gemfile
CHANGED
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -1,71 +1,94 @@
|
|
1
1
|
# <img src="https://what3words.com/assets/images/w3w_square_red.png" width="32" height="32" alt="what3words"> what3words Ruby wrapper
|
2
|
-
![Build Status](https://travis-ci.org/what3words/w3w-ruby-wrapper.svg?branch=master)
|
3
2
|
|
4
|
-
|
3
|
+
[![Build Status](https://travis-ci.org/what3words/w3w-ruby-wrapper.svg?branch=master)](https://travis-ci.org/what3words/w3w-ruby-wrapper)
|
4
|
+
|
5
|
+
The Ruby wrapper is useful for Ruby developers who wish to seamlessly integrate the [what3words Public API](https://developer.what3words.com/public-api) into their Ruby applications, without the hassle of having to manage the low level API calls themselves.
|
6
|
+
|
7
|
+
The what3words API is a fast, simple interface which allows you to convert 3 word addresses such as `///index.home.raft` to latitude and longitude coordinates such as `-0.203586, 51.521251` and vice versa. It features a powerful autosuggest function, which can validate and autocorrect user input and limit it to certain geographic areas (this powers the search box on our map site). It allows you to request a section of the what3words grid (which can be requested as GeoJSON for easy display on online maps), and to request the list of all languages supported by what3words. For advanced users, autosuggest can be used to post-process voice output.
|
8
|
+
|
9
|
+
All coordinates are latitude,longitude pairs in standard `WGS-84` (as commonly used worldwide in GPS systems). All latitudes must be in the range of `-90 to 90 (inclusive)`.
|
5
10
|
|
6
11
|
## Installation
|
7
12
|
|
8
|
-
|
13
|
+
The library is available through [RubyGems](https://rubygems.org/gems/what3words).
|
9
14
|
|
10
|
-
|
15
|
+
You can simply add this line to your application's Gemfile:
|
16
|
+
|
17
|
+
```
|
18
|
+
gem 'what3words', '~> 3.0'
|
19
|
+
```
|
11
20
|
|
12
21
|
And then execute:
|
13
22
|
|
23
|
+
```shell
|
14
24
|
$ bundle
|
25
|
+
```
|
15
26
|
|
16
27
|
Or install it yourself as:
|
17
28
|
|
29
|
+
```shell
|
18
30
|
$ gem install what3words
|
31
|
+
```
|
19
32
|
|
20
33
|
## Usage
|
21
34
|
|
22
|
-
Sign up for an API key at
|
35
|
+
Sign up for an API key at [https://developer.what3words.com](https://developer.what3words.com)
|
23
36
|
|
24
|
-
See https://docs.what3words.com/api/
|
25
|
-
passed to the API calls
|
37
|
+
See [https://developer.what3words.com/public-api/docs](https://developer.what3words.com/public-api/docs) for all parameters that can be passed to the API calls.
|
26
38
|
|
27
39
|
If not using Bundler, require it:
|
28
40
|
|
29
|
-
|
41
|
+
```ruby
|
42
|
+
require 'what3words'
|
43
|
+
```
|
30
44
|
|
31
45
|
Then:
|
32
46
|
|
47
|
+
```ruby
|
33
48
|
what3words = What3Words::API.new(:key => "YOURAPIKEY")
|
49
|
+
```
|
34
50
|
|
35
|
-
|
51
|
+
Convert to Coordinates: convert a 3 word address into GPS coordinates (WGS84)
|
36
52
|
|
37
|
-
|
38
|
-
|
53
|
+
```ruby
|
54
|
+
what3words.convert_to_coordinates 'prom.cape.pump'
|
55
|
+
# => {:country=>"GB", :square=>{:southwest=>{:lng=>-0.195426, :lat=>51.484449}, :northeast=>{:lng=>-0.195383, :lat=>51.484476}}, :nearestPlace=>"Kensington, London", :coordinates=>{:lng=>-0.195405, :lat=>51.484463}, :words=>"prom.cape.pump", :language=>"en", :map=>"https://w3w.co/prom.cape.pump"}
|
56
|
+
```
|
39
57
|
|
40
58
|
## API
|
41
|
-
###
|
42
|
-
Convert a 3 word address into GPS coordinates and return 3 words for the same position
|
59
|
+
### Convert to Coordinates
|
60
|
+
Convert a 3 word address into GPS coordinates and return 3 words for the same position.
|
43
61
|
|
44
|
-
|
45
|
-
|
62
|
+
```ruby
|
63
|
+
what3words.convert_to_coordinates "prom.cape.pump"
|
64
|
+
# => {:country=>"GB", :square=>{:southwest=>{:lng=>-0.195426, :lat=>51.484449}, :northeast=>{:lng=>-0.195383, :lat=>51.484476}}, :nearestPlace=>"Kensington, London", :coordinates=>{:lng=>-0.195405, :lat=>51.484463}, :words=>"prom.cape.pump", :language=>"en", :map=>"https://w3w.co/prom.cape.pump"}
|
65
|
+
```
|
66
|
+
Supported keyword params for `convert_to_coordinates` call:
|
46
67
|
|
47
|
-
|
68
|
+
* `words` A 3 word address as a string
|
69
|
+
* `format` Return data format type. It can be one of json (the default) or geojson
|
48
70
|
|
49
|
-
* `lang` (defaults to language of 3 words) - optional language code (only use this if you want to return 3 words in a different language to the language submitted)
|
50
|
-
* `format` Return data format type; can be one of json (the default), geojson or xml
|
51
|
-
* `display` Return display type; can be one of full (the default) or terse
|
52
71
|
|
53
|
-
###
|
54
|
-
|
72
|
+
### Convert to 3WA
|
73
|
+
Convert position information, latitude and longitude coordinates, into a 3 word address.
|
55
74
|
|
56
|
-
|
57
|
-
|
75
|
+
```ruby
|
76
|
+
what3words.convert_to_3wa [29.567041, 106.587875]
|
77
|
+
# => {:country=>"CN", :square=>{:southwest=>{:lng=>106.58786, :lat=>29.567028}, :northeast=>{:lng=>106.587891, :lat=>29.567055}}, :nearestPlace=>"Chongqing", :coordinates=>{:lng=>106.587875, :lat=>29.567041}, :words=>"disclose.strain.redefined", :language=>"en", :map=>"https://w3w.co/disclose.strain.redefined"}
|
78
|
+
```
|
58
79
|
|
59
80
|
Convert position information to a 3 word address in a specific language
|
60
81
|
|
61
|
-
|
62
|
-
|
82
|
+
```ruby
|
83
|
+
what3words.convert_to_3wa [29.567041, 106.587875], language: 'fr'
|
84
|
+
# => :country=>"CN", :square=>{:southwest=>{:lng=>106.58786, :lat=>29.567028}, :northeast=>{:lng=>106.587891, :lat=>29.567055}}, :nearestPlace=>"Chongqing", :coordinates=>{:lng=>106.587875, :lat=>29.567041}, :words=>"courgette.rabotons.infrason", :language=>"fr", :map=>"https://w3w.co/courgette.rabotons.infrason"}
|
85
|
+
```
|
63
86
|
|
64
|
-
Supported keyword params for `
|
87
|
+
Supported keyword params for `convert_to_3wa` call:
|
65
88
|
|
66
|
-
* `
|
67
|
-
* `
|
68
|
-
* `
|
89
|
+
* `coordinates` The coordinates of the location to convert to 3 word address
|
90
|
+
* `language` (defaults to en) - A supported 3 word address language as an ISO 639-1 2 letter code
|
91
|
+
* `format` Return data format type. It can be one of json (the default) or geojson
|
69
92
|
|
70
93
|
### Autosuggest
|
71
94
|
Returns a list of 3 word addresses based on user input and other parameters.
|
@@ -78,73 +101,156 @@ This resource provides corrections for the following types of input error:
|
|
78
101
|
|
79
102
|
The autosuggest resource determines possible corrections to the supplied 3 word address string based on the probability of the input errors listed above and returns a ranked list of suggestions. This resource can also take into consideration the geographic proximity of possible corrections to a given location to further improve the suggestions returned.
|
80
103
|
|
81
|
-
|
104
|
+
See [https://developer.what3words.com/public-api/docs#autosuggest](https://developer.what3words.com/public-api/docs#autosuggest) for detailed information
|
82
105
|
|
83
|
-
Gets suggestions in
|
106
|
+
Gets suggestions in french for this address:
|
84
107
|
|
85
|
-
|
86
|
-
|
108
|
+
```ruby
|
109
|
+
what3words.autosuggest 'trop.caler.perdre', language: 'fr'
|
110
|
+
# => {:suggestions=>[{:country=>"FR", :nearestPlace=>"Saint-Lary-Soulan, Hautes-Pyrénées", :words=>"trier.caler.perdre", :rank=>1, :language=>"fr"}, {:country=>"ET", :nearestPlace=>"Asbe Teferi, Oromiya", :words=>"trôler.caler.perdre", :rank=>2, :language=>"fr"}, {:country=>"CN", :nearestPlace=>"Ulanhot, Inner Mongolia", :words=>"froc.caler.perdre", :rank=>3, :language=>"fr"}]}
|
111
|
+
```
|
87
112
|
|
88
|
-
|
89
|
-
|
90
|
-
|
113
|
+
Gets suggestions for a different number of suggestions, i.e. 10 for this address:
|
114
|
+
|
115
|
+
```ruby
|
116
|
+
what3words.autosuggest 'disclose.strain.redefin', language: 'en', 'n-results': 10
|
117
|
+
# => {:suggestions=>[{:country=>"SO", :nearestPlace=>"Jamaame, Lower Juba", :words=>"disclose.strain.redefine", :rank=>1, :language=>"en"}, {:country=>"ZW", :nearestPlace=>"Mutoko, Mashonaland East", :words=>"discloses.strain.redefine", :rank=>2, :language=>"en"}, {:country=>"MM", :nearestPlace=>"Mogok, Mandalay", :words=>"disclose.strains.redefine", :rank=>3, :language=>"en"}, {:country=>"CN", :nearestPlace=>"Chongqing", :words=>"disclose.strain.redefined", :rank=>4, :language=>"en"}, {:country=>"ZM", :nearestPlace=>"Binga, Matabeleland North", :words=>"disclosing.strain.redefine", :rank=>5, :language=>"en"}, {:country=>"XH", :nearestPlace=>"Leh, Ladakh", :words=>"disclose.straining.redefine", :rank=>6, :language=>"en"}, {:country=>"US", :nearestPlace=>"Kamas, Utah", :words=>"disclose.strain.redefining", :rank=>7, :language=>"en"}, {:country=>"GN", :nearestPlace=>"Boké", :words=>"disclose.strained.redefine", :rank=>8, :language=>"en"}, {:country=>"BO", :nearestPlace=>"Pailón, Santa Cruz", :words=>"discloses.strains.redefine", :rank=>9, :language=>"en"}, {:country=>"US", :nearestPlace=>"McGrath, Alaska", :words=>"discloses.strain.redefined", :rank=>10, :language=>"en"}]}
|
118
|
+
```
|
119
|
+
|
120
|
+
Gets suggestions for a different number of focus results for this address:
|
121
|
+
|
122
|
+
```ruby
|
123
|
+
what3words.autosuggest 'disclose.strain.redefin', language: 'en', 'n-focus-results': 3
|
124
|
+
# => {:suggestions=>[{:country=>"SO", :nearestPlace=>"Jamaame, Lower Juba", :words=>"disclose.strain.redefine", :rank=>1, :language=>"en"}, {:country=>"ZW", :nearestPlace=>"Mutoko, Mashonaland East", :words=>"discloses.strain.redefine", :rank=>2, :language=>"en"}, {:country=>"MM", :nearestPlace=>"Mogok, Mandalay", :words=>"disclose.strains.redefine", :rank=>3, :language=>"en"}]}
|
125
|
+
```
|
126
|
+
|
127
|
+
Gets suggestions for a voice input type mode, i.e. generic-voice, for this address:
|
128
|
+
|
129
|
+
```ruby
|
130
|
+
what3words.autosuggest 'fun with code', 'input-type': 'generic-voice', language: 'en'
|
131
|
+
# => {:suggestions=>[{:country=>"US", :nearestPlace=>"Homer, Alaska", :words=>"fund.with.code", :rank=>1, :language=>"en"}, {:country=>"AU", :nearestPlace=>"Kumpupintil, Western Australia", :words=>"funk.with.code", :rank=>2, :language=>"en"}, {:country=>"US", :nearestPlace=>"Charleston, West Virginia", :words=>"fund.with.cove", :rank=>3, :language=>"en"}]}
|
132
|
+
```
|
133
|
+
|
134
|
+
Gets suggestions for a restricted area by clipping to conutry for this address:
|
135
|
+
|
136
|
+
```ruby
|
137
|
+
what3words.autosuggest 'disclose.strain.redefin', 'clip-to-country': 'GB,BE'
|
138
|
+
# => {:suggestions=>[{:country=>"GB", :nearestPlace=>"Nether Stowey, Somerset", :words=>"disclose.retrain.redefined", :rank=>1, :language=>"en"}, {:country=>"BE", :nearestPlace=>"Zemst, Flanders", :words=>"disclose.strain.reckon", :rank=>2, :language=>"en"}, {:country=>"GB", :nearestPlace=>"Waddington, Lincolnshire", :words=>"discloses.trains.redefined", :rank=>3, :language=>"en"}]}
|
139
|
+
```
|
91
140
|
|
92
|
-
|
93
|
-
|
141
|
+
Gets suggestions for a restricted area by clipping to a bounding-box for this address:
|
142
|
+
|
143
|
+
```ruby
|
144
|
+
what3words.autosuggest 'disclose.strain.redefin', 'clip-to-bounding-box': [51.521, -0.343, 52.6, 2.3324]
|
145
|
+
# => {:suggestions=>[{:country=>"GB", :nearestPlace=>"Saxmundham, Suffolk", :words=>"discloses.strain.reddish", :rank=>1, :language=>"en"}]}
|
146
|
+
```
|
94
147
|
|
95
|
-
The specified 3 word address may either be a full 3 word address or a partial 3 word address containing the first 2 words in full and at least 1 character of the 3rd word. The standardblend resource provides the search logic that powers the search box on map.what3words.com and in the what3words mobile apps.
|
96
148
|
|
97
|
-
|
149
|
+
Gets suggestions for a restricted area by clipping to a circle in km for this address:
|
150
|
+
|
151
|
+
```ruby
|
152
|
+
what3words.autosuggest 'disclose.strain.redefin', 'clip-to-circle': [51.521, -0.343, 142]
|
153
|
+
# => {:suggestions=>[{:country=>"GB", :nearestPlace=>"Market Harborough, Leicestershire", :words=>"discloses.strain.reduce", :rank=>1, :language=>"en"}]}
|
154
|
+
```
|
155
|
+
|
156
|
+
Gets suggestions for a restricted area by clipping to a polygon for this address:
|
157
|
+
|
158
|
+
```ruby
|
159
|
+
what3words.autosuggest 'disclose.strain.redefin', 'clip-to-polygon': [51.521, -0.343, 52.6, 2.3324, 54.234, 8.343, 51.521, -0.343]
|
160
|
+
# => {:suggestions=>[{:country=>"GB", :nearestPlace=>"Saxmundham, Suffolk", :words=>"discloses.strain.reddish", :rank=>1, :language=>"en"}]}
|
161
|
+
```
|
98
162
|
|
99
|
-
Gets
|
163
|
+
Gets suggestions for a restricted area by clipping to a polygon for this address:
|
100
164
|
|
101
|
-
|
102
|
-
|
165
|
+
```ruby
|
166
|
+
what3words.w3w.autosuggest 'disclose.strain.redefin', 'prefer-land': false, 'n-results': 10
|
167
|
+
# => {:suggestions=>[{:country=>"SO", :nearestPlace=>"Jamaame, Lower Juba", :words=>"disclose.strain.redefine", :rank=>1, :language=>"en"}, {:country=>"ZW", :nearestPlace=>"Mutoko, Mashonaland East", :words=>"discloses.strain.redefine", :rank=>2, :language=>"en"}, {:country=>"MM", :nearestPlace=>"Mogok, Mandalay", :words=>"disclose.strains.redefine", :rank=>3, :language=>"en"}, {:country=>"CN", :nearestPlace=>"Chongqing", :words=>"disclose.strain.redefined", :rank=>4, :language=>"en"}, {:country=>"ZM", :nearestPlace=>"Binga, Matabeleland North", :words=>"disclosing.strain.redefine", :rank=>5, :language=>"en"}, {:country=>"XH", :nearestPlace=>"Leh, Ladakh", :words=>"disclose.straining.redefine", :rank=>6, :language=>"en"}, {:country=>"US", :nearestPlace=>"Kamas, Utah", :words=>"disclose.strain.redefining", :rank=>7, :language=>"en"}, {:country=>"GN", :nearestPlace=>"Boké", :words=>"disclose.strained.redefine", :rank=>8, :language=>"en"}, {:country=>"BO", :nearestPlace=>"Pailón, Santa Cruz", :words=>"discloses.strains.redefine", :rank=>9, :language=>"en"}, {:country=>"US", :nearestPlace=>"McGrath, Alaska", :words=>"discloses.strain.redefined", :rank=>10, :language=>"en"}]}
|
168
|
+
```
|
103
169
|
|
104
|
-
Supported keyword params for `
|
105
|
-
* `
|
106
|
-
* `
|
170
|
+
Supported keyword params for `autosuggest` call:
|
171
|
+
* `input` The full or partial 3 word address to obtain suggestions for. At minimum this must be the first two complete words plus at least one character from the third word.
|
172
|
+
* `language` A supported 3 word address language as an ISO 639-1 2 letter code. This setting is on by default. Use false to disable this setting and receive more suggestions in the sea.
|
173
|
+
* `n_results` The number of AutoSuggest results to return. A maximum of 100 results can be specified, if a number greater than this is requested, this will be truncated to the maximum. The default is 3.
|
174
|
+
* `n_focus_results` Specifies the number of results (must be <= n_results) within the results set which will have a focus. Defaults to n_results. This allows you to run autosuggest with a mix of focussed and unfocussed results, to give you a "blend" of the two.
|
175
|
+
* `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 (for example, to restrict to Belgium and the UK, use clip_to_country="GB,BE").
|
176
|
+
* `clip-to-bounding-box` Restrict autosuggest results to a bounding box, specified by coordinates.
|
177
|
+
* `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. For convenience, longitude is allowed to wrap around 180 degrees. For example 181 is equivalent to -179.
|
178
|
+
* `clip-to-polygon` Restrict autosuggest results to a polygon, specified by a list of coordinates. The polygon should be closed, i.e. the first element should be repeated as the last element; also the list should contain at least 4 entries. The API is currently limited to accepting up to 25 pairs.
|
179
|
+
* `input-type` For power users, used to specify voice input mode. Can be text (default), vocon-hybrid, nmdp-asr or generic-voice.
|
180
|
+
* `prefer-land` Makes autosuggest prefer results on land to those in the sea.
|
107
181
|
|
108
182
|
### Grid
|
109
183
|
Returns a section of the 3m x 3m what3words grid for a given area.
|
110
184
|
|
111
|
-
|
185
|
+
See [https://developer.what3words.com/public-api/docs#grid-section](https://developer.what3words.com/public-api/docs#grid-section) for detailed information.
|
112
186
|
|
113
|
-
Gets grid for these bounding box northeast 52.208867,0.117540,
|
187
|
+
Gets grid for these bounding box northeast 52.208867,0.117540,52.207988,0.116126.
|
114
188
|
|
115
|
-
|
116
|
-
|
189
|
+
```ruby
|
190
|
+
what3words.grid_section '52.208867,0.117540,52.207988,0.116126'
|
191
|
+
# => {:lines=>[{:start=>{:lng=>0.116126, :lat=>52.20801}, :end=>{:lng=>0.11754, :lat=>52.20801}}, {:start=>{:lng=>0.116126, :lat=>52.208037}, :end=>{:lng=>0.11754, :lat=>52.208037}}, {:start=>{:lng=>0.116126, :lat=>52.208064}, :end=>{:lng=>0.11754, :lat=>52.208064}}, ___...___ ]}
|
192
|
+
```
|
117
193
|
|
118
|
-
Supported keyword params for `
|
119
|
-
* `
|
120
|
-
* `
|
194
|
+
Supported keyword params for `grid_section` call:
|
195
|
+
* `bounding-box` The bounding box is specified by the northeast and southwest corner coordinates, for which the grid should be returned
|
196
|
+
* `format` Return data format type. It can be one of json (the default) or geojson
|
121
197
|
|
122
198
|
### Get Languages
|
123
|
-
|
124
|
-
|
125
|
-
what3words.languages
|
126
|
-
# => {:languages=>[{:name=>"German", :native_name=>"Deutsch", :code=>"de"}, {:name=>"Italian", :native_name=>"Italiano", :code=>"it"}, {:name=>"Turkish", :native_name=>"Türkçe", :code=>"tr"}, {:name=>"Portuguese", :native_name=>"Português", :code=>"pt"}, {:name=>"French", :native_name=>"français, langue française", :code=>"fr"}, {:name=>"Swedish", :native_name=>"svenska", :code=>"sv"}, {:name=>"English", :native_name=>"English", :code=>"en"}, {:name=>"Russian", :native_name=>"русский язык", :code=>"ru"}, {:name=>"Spanish", :native_name=>"español", :code=>"es"}, {:name=>"Swahili", :native_name=>"Kiswahili", :code=>"sw"}], :status=>{:status=>200, :reason=>"OK"}, :thanks=>"Thanks from all of us at index.home.raft for using a what3words API"}
|
199
|
+
Retrieve a list of available 3 word languages.
|
127
200
|
|
128
|
-
|
129
|
-
|
130
|
-
|
201
|
+
```ruby
|
202
|
+
what3words.available_languages
|
203
|
+
# => {:languages=>[{:nativeName=>"Deutsch", :code=>"de", :name=>"German"}, {:nativeName=>"हिन्दी", :code=>"hi", :name=>"Hindi"}, {:nativeName=>"Português", :code=>"pt", :name=>"Portuguese"}, {:nativeName=>"Magyar", :code=>"hu", :name=>"Hungarian"}, {:nativeName=>"Українська", :code=>"uk", :name=>"Ukrainian"}, {:nativeName=>"Bahasa Indonesia", :code=>"id", :name=>"Bahasa Indonesia"}, {:nativeName=>"اردو", :code=>"ur", :name=>"Urdu"}, ___...___]}
|
204
|
+
```
|
131
205
|
|
132
|
-
|
133
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
134
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
135
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
136
|
-
5. Create new Pull Request
|
206
|
+
See [https://developer.what3words.com/public-api/docs#available-languages](https://developer.what3words.com/public-api/docs#available-languages) for the original API call documentation.
|
137
207
|
|
138
|
-
|
208
|
+
## Testing
|
139
209
|
|
140
210
|
* Prerequisite : we are using [bundler](https://rubygems.org/gems/bundler) `$ gem install bundler`
|
141
211
|
|
142
|
-
* W3W-API-KEY
|
212
|
+
* W3W-API-KEY: For safe storage of your API key on your computer, you can define that API key using your system’s environment variables.
|
143
213
|
```bash
|
144
214
|
$ export W3W_API_KEY=<Secret API Key>
|
145
215
|
```
|
146
216
|
|
147
|
-
* on
|
217
|
+
* on your cloned folder
|
148
218
|
1. `$ cd w3w-ruby-wrapper`
|
149
219
|
1. `$ bundle update`
|
150
|
-
1. `$ rake spec`
|
220
|
+
1. `$ rake rubocop spec`
|
221
|
+
|
222
|
+
To run the tests, type on your terminal:
|
223
|
+
```bash
|
224
|
+
$ bundle exec rspec
|
225
|
+
```
|
226
|
+
|
227
|
+
## Issues
|
228
|
+
|
229
|
+
Find a bug or want to request a new feature? Please let us know by submitting an issue.
|
230
|
+
|
231
|
+
## Contributing
|
232
|
+
Anyone and everyone is welcome to contribute.
|
233
|
+
|
234
|
+
1. Fork it (http://github.com/what3words/w3w-ruby-wrapper and click "Fork")
|
235
|
+
1. Create your feature branch (`git checkout -b my-new-feature`)
|
236
|
+
1. Commit your changes (`git commit -am 'Add some feature'`)
|
237
|
+
1. Don't forget to update README and bump [version](./lib/what3words/version.rb) using [semver](https://semver.org/)
|
238
|
+
1. Push to the branch (`git push origin my-new-feature`)
|
239
|
+
1. Create new Pull Request
|
240
|
+
|
241
|
+
# Revision History
|
242
|
+
|
243
|
+
* `v3.0.0` 12/05/22 - Update endpoints and tests to API v3, added HTTP headers
|
244
|
+
* `v2.2.0` 03/01/18 - Enforce Ruby 2.4 Support - Thanks to PR from Dimitrios Zorbas [@Zorbash](https://github.com/zorbash)
|
245
|
+
* `v2.1.1` 22/05/17 - Update gemspec to use rubocop 0.48.1, and fixes spec accordingly
|
246
|
+
* `v2.1.0` 28/03/17 - Added multilingual version of `autosuggest` and `standardblend`
|
247
|
+
* `v2.0.4` 27/03/17 - Updated README with `languages` method result updated from live result
|
248
|
+
* `v2.0.3` 24/10/16 - Fixed `display` in `assemble_common_request_params`
|
249
|
+
* `v2.0.2` 10/06/16 - Added travis-ci builds
|
250
|
+
* `v2.0.0` 10/06/16 - Updated wrapper to use what3words API v2
|
251
|
+
|
252
|
+
## Licensing
|
253
|
+
|
254
|
+
The MIT License (MIT)
|
255
|
+
|
256
|
+
A copy of the license is available in the repository's [license](LICENSE.txt) file.
|
data/Rakefile
CHANGED
@@ -1,9 +1,14 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'bundler/gem_tasks'
|
2
4
|
|
3
5
|
begin
|
6
|
+
require 'rubocop/rake_task'
|
7
|
+
RuboCop::RakeTask.new(:rubocop) do |t|
|
8
|
+
t.options = ['--display-cop-names']
|
9
|
+
end
|
4
10
|
require 'rspec/core/rake_task'
|
5
|
-
|
6
11
|
RSpec::Core::RakeTask.new(:spec)
|
7
|
-
rescue LoadError
|
8
|
-
|
12
|
+
rescue LoadError => e
|
13
|
+
print e
|
9
14
|
end
|