mapbox-sdk 2.3.0 → 2.3.3
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/CHANGELOG.md +12 -0
- data/Gemfile +2 -2
- data/README.md +8 -2
- data/lib/mapbox/geocoder.rb +1 -1
- data/lib/mapbox.rb +6 -6
- data/mapbox-sdk.gemspec +2 -2
- data/test/geocoding_test.rb +23 -8
- data/test/mapbox_test.rb +8 -0
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 485c58289f4baee1dc8d98e0c63642a77abc2b9290bda6f15afb20e8d8157bc3
|
4
|
+
data.tar.gz: 4aab789f653d516d1ae88811f598fd8190c7bfa6e6e3122b558eaa442144e677
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 33e2264dda2cdc27b191b1efe999db0596da3d5e861d6de00ab576e400764a2b0d23f9efed98a38cce292aa39ce0b73e4f837fb6c155cf6f54ca7a285078c51e
|
7
|
+
data.tar.gz: ebec6b814a78b45bb9517e3e66ae2c0edea63d91cae279ac328fd2de49b0cf5760c0b6e5f697095b9b563094a554777ad53072689a62bfe97b1377ac3243d3a8
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,18 @@ All notable changes to this project will be documented in this file.
|
|
4
4
|
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
5
5
|
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
6
6
|
|
7
|
+
## [2.3.3] - 2021-09-08
|
8
|
+
### Changed
|
9
|
+
- See https://github.com/mapbox/mapbox-sdk-rb/pull/55 / https://github.com/mapbox/mapbox-sdk-rb/issues/54
|
10
|
+
|
11
|
+
## [2.3.2] - 2020-11-23
|
12
|
+
### Changed
|
13
|
+
- Fixed URI.encode obsolete warnings in Ruby 2.7
|
14
|
+
|
15
|
+
## [2.3.1] - 2020-11-07
|
16
|
+
### Changed
|
17
|
+
- Update to restclient 2.1.0
|
18
|
+
|
7
19
|
## [2.3.0] - 2019-01-16
|
8
20
|
### Added
|
9
21
|
- Matrix endpoint, docs, and tests
|
data/Gemfile
CHANGED
@@ -3,11 +3,11 @@ gemspec
|
|
3
3
|
|
4
4
|
if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('1.9.3')
|
5
5
|
gem 'i18n', '< 0.7'
|
6
|
-
gem 'rest-client', '~> 2.0
|
6
|
+
gem 'rest-client', '~> 2.1.0'
|
7
7
|
gem "activesupport", ">= 4.1.11"
|
8
8
|
gem 'rake', '10.1.0'
|
9
9
|
end
|
10
10
|
|
11
11
|
group :development, :test do
|
12
12
|
gem "coveralls", :require => false
|
13
|
-
end
|
13
|
+
end
|
data/README.md
CHANGED
@@ -25,10 +25,16 @@ gem install mapbox-sdk
|
|
25
25
|
* [Map Matching](https://docs.mapbox.com/api/navigation/#map-matching): [[docs](https://github.com/mapbox/mapbox-sdk-rb/blob/master/docs/mapmatching.md)]
|
26
26
|
* Profiles for driving, driving-traffic, walking, and cycling
|
27
27
|
* [Optimization](https://docs.mapbox.com/api/navigation/#optimization): [[docs](https://github.com/mapbox/mapbox-sdk-rb/blob/master/docs/optimization.md)]
|
28
|
-
* Profiles for driving, driving-traffic, walking, and cycling
|
28
|
+
* Profiles for driving, driving-traffic, walking, and cycling
|
29
29
|
|
30
30
|
## Testing
|
31
31
|
|
32
|
-
|
32
|
+
You'll need to [create an access token](https://account.mapbox.com/access-tokens/create) in order to run tests.
|
33
|
+
|
34
|
+
Then you can run the entire test suite with the following command:
|
35
|
+
|
36
|
+
```
|
37
|
+
MapboxAccessToken=<YOUR_ACCESS_TOKEN> bundle exec ruby -Itest test/all_tests.rb
|
38
|
+
```
|
33
39
|
|
34
40
|
Heavily influenced by Stripe's Ruby client, and includes its MIT license.
|
data/lib/mapbox/geocoder.rb
CHANGED
data/lib/mapbox.rb
CHANGED
@@ -11,7 +11,7 @@ module Mapbox
|
|
11
11
|
LONGITUDE_KEY = 'longitude'.freeze
|
12
12
|
|
13
13
|
class << self
|
14
|
-
attr_accessor :access_token, :api_base, :request_opts
|
14
|
+
attr_accessor :access_token, :api_base, :request_opts, :request_timeout, :request_open_timeout
|
15
15
|
end
|
16
16
|
|
17
17
|
def self.request(method, url, api_key, params={}, headers={}, api_base_url=nil)
|
@@ -33,7 +33,7 @@ module Mapbox
|
|
33
33
|
case method.to_s.downcase.to_sym
|
34
34
|
when :get, :head, :delete
|
35
35
|
# Make params into GET parameters
|
36
|
-
url += "#{URI.parse(url).query ? '&' : '?'}#{
|
36
|
+
url += "#{URI.parse(url).query ? '&' : '?'}#{URI.encode_www_form(params)}" if params && params.any?
|
37
37
|
payload = nil
|
38
38
|
end
|
39
39
|
|
@@ -42,10 +42,10 @@ module Mapbox
|
|
42
42
|
|
43
43
|
@request_opts.update(
|
44
44
|
:method => method,
|
45
|
-
:open_timeout => 30,
|
45
|
+
:open_timeout => @request_open_timeout || 30,
|
46
46
|
:payload => payload,
|
47
47
|
:url => url,
|
48
|
-
:timeout => 80)
|
48
|
+
:timeout => @request_timeout || 80)
|
49
49
|
|
50
50
|
begin
|
51
51
|
response = execute_request(@request_opts)
|
@@ -78,7 +78,7 @@ module Mapbox
|
|
78
78
|
end
|
79
79
|
|
80
80
|
def self.url_encode(key)
|
81
|
-
URI.
|
81
|
+
URI.encode_www_form_component(key.to_s)
|
82
82
|
end
|
83
83
|
|
84
84
|
def self.execute_request(opts)
|
@@ -184,4 +184,4 @@ require 'mapbox/tilequery'
|
|
184
184
|
require 'mapbox/isochrone'
|
185
185
|
require 'mapbox/matrix'
|
186
186
|
require 'mapbox/map_matching'
|
187
|
-
require 'mapbox/optimization'
|
187
|
+
require 'mapbox/optimization'
|
data/mapbox-sdk.gemspec
CHANGED
@@ -2,7 +2,7 @@ $:.unshift(File.join(File.dirname(__FILE__), 'lib'))
|
|
2
2
|
|
3
3
|
spec = Gem::Specification.new do |s|
|
4
4
|
s.name = 'mapbox-sdk'
|
5
|
-
s.version = '2.3.
|
5
|
+
s.version = '2.3.3'
|
6
6
|
s.summary = 'Ruby bindings for the Mapbox API'
|
7
7
|
s.description = ''
|
8
8
|
s.authors = ['Tom MacWright']
|
@@ -10,7 +10,7 @@ spec = Gem::Specification.new do |s|
|
|
10
10
|
s.homepage = 'https://mapbox.com/developers'
|
11
11
|
s.license = 'MIT'
|
12
12
|
|
13
|
-
s.add_dependency('rest-client', '~> 2.0
|
13
|
+
s.add_dependency('rest-client', '~> 2.1.0')
|
14
14
|
|
15
15
|
s.add_development_dependency('mocha', '~> 0.13.2')
|
16
16
|
s.add_development_dependency('shoulda', '~> 3.4.0')
|
data/test/geocoding_test.rb
CHANGED
@@ -5,49 +5,58 @@ require 'shoulda'
|
|
5
5
|
|
6
6
|
module Mapbox
|
7
7
|
class GeocodingTest < Test::Unit::TestCase
|
8
|
-
|
8
|
+
|
9
|
+
def setup
|
9
10
|
Mapbox.access_token = ENV["MapboxAccessToken"]
|
11
|
+
end
|
12
|
+
|
13
|
+
def teardown
|
14
|
+
Mapbox.request_open_timeout = nil
|
15
|
+
Mapbox.request_timeout = nil
|
16
|
+
end
|
17
|
+
|
18
|
+
should "#geocode_forward" do
|
10
19
|
result = Mapbox::Geocoder.geocode_forward("Chester, NJ")
|
11
20
|
assert result
|
12
21
|
end
|
13
22
|
|
23
|
+
should "set_default_timeouts" do
|
24
|
+
result = Mapbox::Geocoder.geocode_forward("Chester, NJ")
|
25
|
+
assert Mapbox.request_opts[:timeout] = 80
|
26
|
+
assert Mapbox.request_opts[:open_timeout] = 30
|
27
|
+
end
|
28
|
+
|
14
29
|
should "#geocode_forward (rounded proximity to 3 decimal places)" do
|
15
|
-
Mapbox.access_token = ENV["MapboxAccessToken"]
|
16
30
|
result = Mapbox::Geocoder.geocode_forward("Chester, NJ", {:proximity => {:longitude => 0.1234567, :latitude => -10.987654}})
|
17
31
|
assert result
|
18
32
|
assert Mapbox.request_opts[:url].include? '?proximity=0.123%2C-10.988&'
|
19
33
|
end
|
20
34
|
|
21
35
|
should "#geocode_forward (include bbox param)" do
|
22
|
-
Mapbox.access_token = ENV["MapboxAccessToken"]
|
23
36
|
result = Mapbox::Geocoder.geocode_forward("Washington", {:bbox => [-78.3284,38.6039,-78.0428,38.7841]})
|
24
37
|
assert result
|
25
38
|
assert Mapbox.request_opts[:url].include? '?bbox=-78.3284%2C38.6039%2C-78.0428%2C38.7841';
|
26
39
|
end
|
27
40
|
|
28
41
|
should "#geocode_forward (include extra param)" do
|
29
|
-
Mapbox.access_token = ENV["MapboxAccessToken"]
|
30
42
|
result = Mapbox::Geocoder.geocode_forward("Washington", {:bbox => [-78.3284,38.6039,-78.0428,38.7841], :foo_key => "foo_val", :bar_key => "bar_val"})
|
31
43
|
assert result
|
32
44
|
assert Mapbox.request_opts[:url].include? '?foo_key=foo_val&bar_key=bar_val';
|
33
45
|
end
|
34
46
|
|
35
47
|
should "#geocode_forward (include country param)" do
|
36
|
-
Mapbox.access_token = ENV["MapboxAccessToken"]
|
37
48
|
result = Mapbox::Geocoder.geocode_forward("Washington", {:country => "ca"})
|
38
49
|
assert result
|
39
50
|
assert Mapbox.request_opts[:url].include? '?country=ca';
|
40
51
|
end
|
41
52
|
|
42
53
|
should "#geocode_forward (include types param)" do
|
43
|
-
Mapbox.access_token = ENV["MapboxAccessToken"]
|
44
54
|
result = Mapbox::Geocoder.geocode_forward("Washington", {:types => ['poi.landmark', 'address'], :foo_key => "foo_val", :bar_key => "bar_val"})
|
45
55
|
assert result
|
46
56
|
assert Mapbox.request_opts[:url].include? '?foo_key=foo_val&bar_key=bar_val&types=poi.landmark%2Caddress';
|
47
57
|
end
|
48
58
|
|
49
59
|
should "#geocode_reverse" do
|
50
|
-
Mapbox.access_token = ENV["MapboxAccessToken"]
|
51
60
|
result = Mapbox::Geocoder.geocode_reverse({
|
52
61
|
:latitude => 38,
|
53
62
|
:longitude => -100
|
@@ -56,7 +65,6 @@ module Mapbox
|
|
56
65
|
end
|
57
66
|
|
58
67
|
should "#geocode_reverse (rounded coordinates to 5 decimal places)" do
|
59
|
-
Mapbox.access_token = ENV["MapboxAccessToken"]
|
60
68
|
result = Mapbox::Geocoder.geocode_reverse({
|
61
69
|
:latitude => 1.23456789,
|
62
70
|
:longitude => -99.8765432
|
@@ -66,5 +74,12 @@ module Mapbox
|
|
66
74
|
end
|
67
75
|
end
|
68
76
|
|
77
|
+
should "set_custom_timeouts" do
|
78
|
+
Mapbox.request_timeout = 10
|
79
|
+
Mapbox.request_open_timeout = 5
|
80
|
+
result = Mapbox::Geocoder.geocode_forward("Chester, NJ", {:proximity => {:longitude => 0.1234567, :latitude => -10.987654}})
|
81
|
+
assert Mapbox.request_opts[:timeout] == 10
|
82
|
+
assert Mapbox.request_opts[:open_timeout] == 5
|
83
|
+
end
|
69
84
|
end
|
70
85
|
end
|
data/test/mapbox_test.rb
CHANGED
@@ -14,6 +14,14 @@ module Mapbox
|
|
14
14
|
should "allow access token to be set" do
|
15
15
|
Mapbox.access_token = "foo"
|
16
16
|
end
|
17
|
+
|
18
|
+
should "allow request_timeout to be set" do
|
19
|
+
Mapbox.request_timeout = 5
|
20
|
+
end
|
21
|
+
|
22
|
+
should "allow request_open_timeout to be set" do
|
23
|
+
Mapbox.request_open_timeout = 5
|
24
|
+
end
|
17
25
|
end
|
18
26
|
|
19
27
|
class HashUtilTest < Test::Unit::TestCase
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mapbox-sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.3.
|
4
|
+
version: 2.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom MacWright
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-09-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.0
|
19
|
+
version: 2.1.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 2.0
|
26
|
+
version: 2.1.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: mocha
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -141,7 +141,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
141
141
|
- !ruby/object:Gem::Version
|
142
142
|
version: '0'
|
143
143
|
requirements: []
|
144
|
-
rubygems_version: 3.
|
144
|
+
rubygems_version: 3.2.25
|
145
145
|
signing_key:
|
146
146
|
specification_version: 4
|
147
147
|
summary: Ruby bindings for the Mapbox API
|