mapbox-sdk 2.3.2 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 672927337ebb6e2225839694318310798e63a8f4cc64100d96a67d67a2cde23e
4
- data.tar.gz: 4fea4ca533cf9e8b6b9ff7118e2abffe36ff8d9b72758adabc21391e279dead0
3
+ metadata.gz: 485c58289f4baee1dc8d98e0c63642a77abc2b9290bda6f15afb20e8d8157bc3
4
+ data.tar.gz: 4aab789f653d516d1ae88811f598fd8190c7bfa6e6e3122b558eaa442144e677
5
5
  SHA512:
6
- metadata.gz: 8a271a83fcb6f562421aceb5c45c0d66bef03fe6d59ef171f3d325936dd9cd01a935e29fd51404a40e39b59d5a9b43d40c9f1fd1d48054d7befff0588e66a43e
7
- data.tar.gz: a016890aca123c692ec7a72b03cb3bf7395551c958775affde6feed96ad7d25428aa108118cc99615463d94049a1fec7d2b97f814054a6b2bdab9025b81dca75
6
+ metadata.gz: 33e2264dda2cdc27b191b1efe999db0596da3d5e861d6de00ab576e400764a2b0d23f9efed98a38cce292aa39ce0b73e4f837fb6c155cf6f54ca7a285078c51e
7
+ data.tar.gz: ebec6b814a78b45bb9517e3e66ae2c0edea63d91cae279ac328fd2de49b0cf5760c0b6e5f697095b9b563094a554777ad53072689a62bfe97b1377ac3243d3a8
data/CHANGELOG.md CHANGED
@@ -4,6 +4,10 @@ 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
+
7
11
  ## [2.3.2] - 2020-11-23
8
12
  ### Changed
9
13
  - Fixed URI.encode obsolete warnings in Ruby 2.7
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)
@@ -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)
@@ -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.2'
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']
@@ -5,49 +5,58 @@ require 'shoulda'
5
5
 
6
6
  module Mapbox
7
7
  class GeocodingTest < Test::Unit::TestCase
8
- should "#geocode_forward" do
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.2
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: 2020-11-23 00:00:00.000000000 Z
11
+ date: 2021-09-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -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.1.4
144
+ rubygems_version: 3.2.25
145
145
  signing_key:
146
146
  specification_version: 4
147
147
  summary: Ruby bindings for the Mapbox API