mapbox-sdk 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +9 -0
- data/Gemfile.lock +64 -0
- data/LICENSE +37 -0
- data/README.md +38 -0
- data/Rakefile +7 -0
- data/lib/mapbox.rb +171 -0
- data/lib/mapbox/api_operations.rb +39 -0
- data/lib/mapbox/authentication_error.rb +7 -0
- data/lib/mapbox/directions.rb +17 -0
- data/lib/mapbox/geocoder.rb +21 -0
- data/mapbox-sdk.gemspec +25 -0
- data/test/directions_test.rb +23 -0
- data/test/geocoding_test.rb +23 -0
- data/test/mapbox_test.rb +18 -0
- metadata +145 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5ada80d6e1cbf4bce52c8963bdcd9eb0d6c7ad93
|
4
|
+
data.tar.gz: 4c58511165153eca7a4bb787ae979f75ebf277d7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0f8ddaff0bb1a510dba43c5b7b4a5ff9b13d230b390a9d734df095279cffbefa61d86ef04c220e53973241419dc9daafdd4fd7d47bf1bfa23b016e22ea7783d1
|
7
|
+
data.tar.gz: 6c92af8cd540921a908634beba3cbb784e4bb2205d71889a758ee31992359f3c21e099b56b0434f814d84b20bc4ae5bc56994cf557c5dcc082a194652f94500a
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
mapbox (1.0.0)
|
5
|
+
json (~> 1.8.1)
|
6
|
+
rest-client (~> 1.4)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
activesupport (4.2.3)
|
12
|
+
i18n (~> 0.7)
|
13
|
+
json (~> 1.7, >= 1.7.7)
|
14
|
+
minitest (~> 5.1)
|
15
|
+
thread_safe (~> 0.3, >= 0.3.4)
|
16
|
+
tzinfo (~> 1.1)
|
17
|
+
bourne (1.5.0)
|
18
|
+
mocha (>= 0.13.2, < 0.15)
|
19
|
+
domain_name (0.5.24)
|
20
|
+
unf (>= 0.0.5, < 1.0.0)
|
21
|
+
http-cookie (1.0.2)
|
22
|
+
domain_name (~> 0.5)
|
23
|
+
i18n (0.7.0)
|
24
|
+
json (1.8.3)
|
25
|
+
metaclass (0.0.4)
|
26
|
+
mime-types (2.6.1)
|
27
|
+
minitest (5.7.0)
|
28
|
+
mocha (0.13.3)
|
29
|
+
metaclass (~> 0.0.1)
|
30
|
+
netrc (0.10.3)
|
31
|
+
power_assert (0.2.4)
|
32
|
+
rake (10.4.2)
|
33
|
+
rest-client (1.8.0)
|
34
|
+
http-cookie (>= 1.0.2, < 2.0)
|
35
|
+
mime-types (>= 1.16, < 3.0)
|
36
|
+
netrc (~> 0.7)
|
37
|
+
shoulda (3.4.0)
|
38
|
+
shoulda-context (~> 1.0, >= 1.0.1)
|
39
|
+
shoulda-matchers (~> 1.0, >= 1.4.1)
|
40
|
+
shoulda-context (1.2.1)
|
41
|
+
shoulda-matchers (1.5.6)
|
42
|
+
activesupport (>= 3.0.0)
|
43
|
+
bourne (~> 1.3)
|
44
|
+
test-unit (3.1.2)
|
45
|
+
power_assert
|
46
|
+
thread_safe (0.3.5)
|
47
|
+
tzinfo (1.2.2)
|
48
|
+
thread_safe (~> 0.1)
|
49
|
+
unf (0.1.4)
|
50
|
+
unf_ext
|
51
|
+
unf_ext (0.0.7.1)
|
52
|
+
|
53
|
+
PLATFORMS
|
54
|
+
ruby
|
55
|
+
|
56
|
+
DEPENDENCIES
|
57
|
+
mapbox!
|
58
|
+
mocha (~> 0.13.2)
|
59
|
+
rake
|
60
|
+
shoulda (~> 3.4.0)
|
61
|
+
test-unit
|
62
|
+
|
63
|
+
BUNDLED WITH
|
64
|
+
1.10.6
|
data/LICENSE
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
Copyright (c) 2015, Mapbox
|
2
|
+
|
3
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
4
|
+
purpose with or without fee is hereby granted, provided that the above
|
5
|
+
copyright notice and this permission notice appear in all copies.
|
6
|
+
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
8
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
9
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
10
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
11
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
12
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
13
|
+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
14
|
+
|
15
|
+
---
|
16
|
+
|
17
|
+
The MIT License
|
18
|
+
|
19
|
+
Copyright (c) 2011- Stripe, Inc. (https://stripe.com)
|
20
|
+
|
21
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
22
|
+
of this software and associated documentation files (the "Software"), to deal
|
23
|
+
in the Software without restriction, including without limitation the rights
|
24
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
25
|
+
copies of the Software, and to permit persons to whom the Software is
|
26
|
+
furnished to do so, subject to the following conditions:
|
27
|
+
|
28
|
+
The above copyright notice and this permission notice shall be included in
|
29
|
+
all copies or substantial portions of the Software.
|
30
|
+
|
31
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
32
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
33
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
34
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
35
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
36
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
37
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# mapbox-sdk-ruby
|
2
|
+
|
3
|
+
The `mapbox-sdk` gem. A ruby interface to [Mapbox APIs](https://www.mapbox.com/developers/api/).
|
4
|
+
|
5
|
+
## Services
|
6
|
+
|
7
|
+
* [Geocoding](https://www.mapbox.com/developers/api/geocoding/)
|
8
|
+
* Forward (place names ⇢ longitude, latitude)
|
9
|
+
* Reverse (longitude, latitude ⇢ place names)
|
10
|
+
* [Directions](https://www.mapbox.com/developers/api/directions/)
|
11
|
+
* Profiles for driving, walking, and cycling
|
12
|
+
|
13
|
+
## Example
|
14
|
+
|
15
|
+
```rb
|
16
|
+
require "mapbox-sdk"
|
17
|
+
Mapbox.access_token = "YOUR_ACCESS_TOKEN"
|
18
|
+
|
19
|
+
# Reverse geocoding
|
20
|
+
placenames = Mapbox::Geocoder.geocode_reverse({
|
21
|
+
"latitude" => 38,
|
22
|
+
"longitude" => -100
|
23
|
+
})
|
24
|
+
|
25
|
+
# Forward geocoding
|
26
|
+
places = Mapbox::Geocoder.geocode_forward("Chester, NJ")
|
27
|
+
|
28
|
+
# Directions
|
29
|
+
drivingDirections = Mapbox::Directions.directions([{
|
30
|
+
"longitude" => -100,
|
31
|
+
"latitude" => 38
|
32
|
+
}, {
|
33
|
+
"longitude" => -90,
|
34
|
+
"latitude" => 38
|
35
|
+
}])
|
36
|
+
```
|
37
|
+
|
38
|
+
Heavily influenced by Stripe's Ruby client, and includes its MIT license.
|
data/Rakefile
ADDED
data/lib/mapbox.rb
ADDED
@@ -0,0 +1,171 @@
|
|
1
|
+
require 'rest-client'
|
2
|
+
require 'json'
|
3
|
+
require 'mapbox/api_operations'
|
4
|
+
require 'mapbox/authentication_error'
|
5
|
+
|
6
|
+
# services
|
7
|
+
require 'mapbox/geocoder'
|
8
|
+
require 'mapbox/directions'
|
9
|
+
|
10
|
+
module Mapbox
|
11
|
+
@api_base = 'https://api.mapbox.com'
|
12
|
+
|
13
|
+
class << self
|
14
|
+
attr_accessor :access_token, :api_base
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.request(method, url, api_key, params={}, headers={}, api_base_url=nil)
|
18
|
+
api_base_url = api_base_url || @api_base
|
19
|
+
params = params || {}
|
20
|
+
|
21
|
+
unless access_token ||= @access_token
|
22
|
+
raise AuthenticationError.new('No API key provided. ' \
|
23
|
+
'Set your API key using "Mapbox.access_token = <access_token>". ' \
|
24
|
+
'You can generate API keys from the Mapbox web interface. ' \
|
25
|
+
'See https://mapbox.com/developers for details, or email help@mapbox.com ' \
|
26
|
+
'if you have any questions.')
|
27
|
+
end
|
28
|
+
|
29
|
+
url = api_base_url + url
|
30
|
+
|
31
|
+
params['access_token'] = access_token
|
32
|
+
|
33
|
+
case method.to_s.downcase.to_sym
|
34
|
+
when :get, :head, :delete
|
35
|
+
# Make params into GET parameters
|
36
|
+
url += "#{URI.parse(url).query ? '&' : '?'}#{uri_encode(params)}" if params && params.any?
|
37
|
+
payload = nil
|
38
|
+
end
|
39
|
+
|
40
|
+
request_opts = {:verify_ssl => OpenSSL::SSL::VERIFY_PEER,
|
41
|
+
:ssl_ca_file => @ssl_bundle_path}
|
42
|
+
|
43
|
+
request_opts.update(
|
44
|
+
:method => method,
|
45
|
+
:open_timeout => 30,
|
46
|
+
:payload => payload,
|
47
|
+
:url => url,
|
48
|
+
:timeout => 80)
|
49
|
+
|
50
|
+
begin
|
51
|
+
response = execute_request(request_opts)
|
52
|
+
rescue SocketError => e
|
53
|
+
handle_restclient_error(e, api_base_url)
|
54
|
+
rescue NoMethodError => e
|
55
|
+
# Work around RestClient bug
|
56
|
+
if e.message =~ /\WRequestFailed\W/
|
57
|
+
e = StandardError.new('Unexpected HTTP response code')
|
58
|
+
handle_restclient_error(e, api_base_url)
|
59
|
+
else
|
60
|
+
raise
|
61
|
+
end
|
62
|
+
rescue RestClient::ExceptionWithResponse => e
|
63
|
+
if e.response
|
64
|
+
handle_api_error(e, e.response)
|
65
|
+
else
|
66
|
+
handle_restclient_error(e, api_base_url)
|
67
|
+
end
|
68
|
+
rescue RestClient::Exception, Errno::ECONNREFUSED => e
|
69
|
+
handle_restclient_error(e, api_base_url)
|
70
|
+
end
|
71
|
+
|
72
|
+
[parse(response), api_key]
|
73
|
+
end
|
74
|
+
|
75
|
+
def self.uri_encode(params)
|
76
|
+
params.
|
77
|
+
map { |k,v| "#{k}=#{url_encode(v)}" }.join('&')
|
78
|
+
end
|
79
|
+
|
80
|
+
def self.url_encode(key)
|
81
|
+
URI.escape(key.to_s, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))
|
82
|
+
end
|
83
|
+
|
84
|
+
def self.execute_request(opts)
|
85
|
+
RestClient::Request.execute(opts)
|
86
|
+
end
|
87
|
+
|
88
|
+
def self.parse(response)
|
89
|
+
begin
|
90
|
+
# Would use :symbolize_names => true, but apparently there is
|
91
|
+
# some library out there that makes symbolize_names not work.
|
92
|
+
response = JSON.parse(response.body)
|
93
|
+
rescue JSON::ParserError
|
94
|
+
raise general_api_error(response.code, response.body)
|
95
|
+
end
|
96
|
+
|
97
|
+
response
|
98
|
+
end
|
99
|
+
|
100
|
+
def self.general_api_error(rcode, rbody)
|
101
|
+
StandardError.new("Invalid response object from API: #{rbody.inspect} " +
|
102
|
+
"(HTTP response code was #{rcode})")
|
103
|
+
end
|
104
|
+
|
105
|
+
def self.handle_api_error(rcode, rbody)
|
106
|
+
begin
|
107
|
+
error_obj = JSON.parse(rbody)
|
108
|
+
error = error_obj[:error] or raise StandardError.new # escape from parsing
|
109
|
+
|
110
|
+
rescue JSON::ParserError, StandardError
|
111
|
+
raise general_api_error(rcode, rbody)
|
112
|
+
end
|
113
|
+
|
114
|
+
case rcode
|
115
|
+
when 400, 404
|
116
|
+
raise invalid_request_error error, rcode, rbody, error_obj
|
117
|
+
when 401
|
118
|
+
raise authentication_error error, rcode, rbody, error_obj
|
119
|
+
else
|
120
|
+
raise api_error error, rcode, rbody, error_obj
|
121
|
+
end
|
122
|
+
|
123
|
+
end
|
124
|
+
|
125
|
+
def self.invalid_request_error(error, rcode, rbody, error_obj)
|
126
|
+
StandardError.new(error[:message], error[:param], rcode,
|
127
|
+
rbody, error_obj)
|
128
|
+
end
|
129
|
+
|
130
|
+
def self.authentication_error(error, rcode, rbody, error_obj)
|
131
|
+
AuthenticationError.new(error[:message], rcode, rbody, error_obj)
|
132
|
+
end
|
133
|
+
|
134
|
+
def self.api_error(error, rcode, rbody, error_obj)
|
135
|
+
StandardError.new(error[:message], rcode, rbody, error_obj)
|
136
|
+
end
|
137
|
+
|
138
|
+
def self.handle_restclient_error(e, api_base_url=nil)
|
139
|
+
api_base_url = @api_base unless api_base_url
|
140
|
+
connection_message = "Please check your internet connection and try again. " \
|
141
|
+
"If this problem persists, you should check Mapbox's service status at " \
|
142
|
+
"https://status.mapbox.com/, or let us know at help@mapbox.com."
|
143
|
+
|
144
|
+
case e
|
145
|
+
when RestClient::RequestTimeout
|
146
|
+
message = "Could not connect to Mapbox (#{api_base_url}). #{connection_message}"
|
147
|
+
|
148
|
+
when RestClient::ServerBrokeConnection
|
149
|
+
message = "The connection to the server (#{api_base_url}) broke before the " \
|
150
|
+
"request completed. #{connection_message}"
|
151
|
+
|
152
|
+
when RestClient::SSLCertificateNotVerified
|
153
|
+
message = "Could not verify Mapbox's SSL certificate. " \
|
154
|
+
"Please make sure that your network is not intercepting certificates. " \
|
155
|
+
"(Try going to https://api.mapbox.com/ in your browser.) " \
|
156
|
+
"If this problem persists, let us know at help@mapbox.com."
|
157
|
+
|
158
|
+
when SocketError
|
159
|
+
message = "Unexpected error communicating when trying to connect to Mapbox. " \
|
160
|
+
"You may be seeing this message because your DNS is not working. " \
|
161
|
+
"To check, try running 'host mapbox.com' from the command line."
|
162
|
+
|
163
|
+
else
|
164
|
+
message = "Unexpected error communicating with Mapbox. " \
|
165
|
+
"If this problem persists, let us know at help@mapbox.com."
|
166
|
+
|
167
|
+
end
|
168
|
+
|
169
|
+
raise StandardError.new(message + "\n\n(Network error: #{e.message})")
|
170
|
+
end
|
171
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Mapbox
|
2
|
+
module APIOperations
|
3
|
+
module Request
|
4
|
+
module ClassMethods
|
5
|
+
OPTS_KEYS_TO_PERSIST = Set[:access_token, :api_base]
|
6
|
+
|
7
|
+
def request(method, url, params={}, opts={})
|
8
|
+
headers = opts.clone
|
9
|
+
access_token = headers.delete(:access_token)
|
10
|
+
api_base = headers.delete(:api_base)
|
11
|
+
# Assume all remaining opts must be headers
|
12
|
+
|
13
|
+
response, opts[:api_key] = Mapbox.request(method, url, access_token, params, headers, api_base)
|
14
|
+
|
15
|
+
# Hash#select returns an array before 1.9
|
16
|
+
opts_to_persist = {}
|
17
|
+
opts.each do |k, v|
|
18
|
+
if OPTS_KEYS_TO_PERSIST.include?(k)
|
19
|
+
opts_to_persist[k] = v
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
[response, opts_to_persist]
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.included(base)
|
28
|
+
base.extend(ClassMethods)
|
29
|
+
end
|
30
|
+
|
31
|
+
protected
|
32
|
+
|
33
|
+
def request(method, url, params={}, opts={})
|
34
|
+
opts = @opts.merge(opts)
|
35
|
+
self.class.request(method, url, params, opts)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'rest-client'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
module Mapbox
|
5
|
+
class Directions
|
6
|
+
include Mapbox::APIOperations::Request
|
7
|
+
def self.directions(waypoints, profile='mapbox.driving')
|
8
|
+
formatted_waypoints = waypoints.map { |point|
|
9
|
+
"#{point['longitude']},#{point['latitude']}"
|
10
|
+
}.join(';')
|
11
|
+
return request(
|
12
|
+
:get,
|
13
|
+
"/v4/directions/#{profile}/#{formatted_waypoints}.json",
|
14
|
+
nil)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'rest-client'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
module Mapbox
|
5
|
+
class Geocoder
|
6
|
+
include Mapbox::APIOperations::Request
|
7
|
+
def self.geocode_forward(query, proximity=nil, dataset='mapbox.places')
|
8
|
+
return request(
|
9
|
+
:get,
|
10
|
+
"/v4/geocode/#{dataset}/#{URI.escape(query)}.json",
|
11
|
+
nil)
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.geocode_reverse(location, dataset='mapbox.places')
|
15
|
+
return request(
|
16
|
+
:get,
|
17
|
+
"/v4/geocode/#{dataset}/#{location["longitude"]},#{location["latitude"]}.json",
|
18
|
+
nil)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/mapbox-sdk.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
$:.unshift(File.join(File.dirname(__FILE__), 'lib'))
|
2
|
+
|
3
|
+
spec = Gem::Specification.new do |s|
|
4
|
+
s.name = 'mapbox-sdk'
|
5
|
+
s.version = '1.0.0'
|
6
|
+
s.summary = 'Ruby bindings for the Mapbox API'
|
7
|
+
s.description = ''
|
8
|
+
s.authors = ['Tom MacWright']
|
9
|
+
s.email = ['tom@mapbox.org']
|
10
|
+
s.homepage = 'https://mapbox.com/developers'
|
11
|
+
s.license = 'MIT'
|
12
|
+
|
13
|
+
s.add_dependency('rest-client', '~> 1.4')
|
14
|
+
s.add_dependency('json', '~> 1.8.1')
|
15
|
+
|
16
|
+
s.add_development_dependency('mocha', '~> 0.13.2')
|
17
|
+
s.add_development_dependency('shoulda', '~> 3.4.0')
|
18
|
+
s.add_development_dependency('test-unit')
|
19
|
+
s.add_development_dependency('rake')
|
20
|
+
|
21
|
+
s.files = `git ls-files`.split("\n")
|
22
|
+
s.test_files = `git ls-files -- test/*`.split("\n")
|
23
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
24
|
+
s.require_paths = ['lib']
|
25
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'mapbox'
|
2
|
+
require 'test/unit'
|
3
|
+
require 'mocha/setup'
|
4
|
+
require 'shoulda'
|
5
|
+
|
6
|
+
module Mapbox
|
7
|
+
class DirectionsTest < Test::Unit::TestCase
|
8
|
+
should "#directions" do
|
9
|
+
Mapbox.access_token = ENV["MapboxAccessToken"]
|
10
|
+
result = Mapbox::Directions.directions([
|
11
|
+
{
|
12
|
+
"longitude" => -100,
|
13
|
+
"latitude" => 38
|
14
|
+
},
|
15
|
+
{
|
16
|
+
"longitude" => -90,
|
17
|
+
"latitude" => 38
|
18
|
+
}
|
19
|
+
])
|
20
|
+
assert result
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'mapbox'
|
2
|
+
require 'test/unit'
|
3
|
+
require 'mocha/setup'
|
4
|
+
require 'shoulda'
|
5
|
+
|
6
|
+
module Mapbox
|
7
|
+
class GeocodingTest < Test::Unit::TestCase
|
8
|
+
should "#geocode_forward" do
|
9
|
+
Mapbox.access_token = ENV["MapboxAccessToken"]
|
10
|
+
result = Mapbox::Geocoder.geocode_forward("Chester, NJ")
|
11
|
+
assert result
|
12
|
+
end
|
13
|
+
|
14
|
+
should "#geocode_reverse" do
|
15
|
+
Mapbox.access_token = ENV["MapboxAccessToken"]
|
16
|
+
result = Mapbox::Geocoder.geocode_reverse({
|
17
|
+
"latitude" => 38,
|
18
|
+
"longitude" => -100
|
19
|
+
})
|
20
|
+
assert result
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/test/mapbox_test.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'mapbox'
|
2
|
+
require 'test/unit'
|
3
|
+
require 'mocha/setup'
|
4
|
+
require 'shoulda'
|
5
|
+
|
6
|
+
module Mapbox
|
7
|
+
class ModuleTest < Test::Unit::TestCase
|
8
|
+
should "throw if access_token is not defined" do
|
9
|
+
assert_raise {
|
10
|
+
Mapbox.request()
|
11
|
+
}
|
12
|
+
end
|
13
|
+
|
14
|
+
should "allow access token to be set" do
|
15
|
+
Mapbox.access_token = "foo"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
metadata
ADDED
@@ -0,0 +1,145 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mapbox-sdk
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Tom MacWright
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-07-23 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rest-client
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.4'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.4'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: json
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.8.1
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.8.1
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: mocha
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.13.2
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.13.2
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: shoulda
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 3.4.0
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 3.4.0
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: test-unit
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rake
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: ''
|
98
|
+
email:
|
99
|
+
- tom@mapbox.org
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- Gemfile
|
105
|
+
- Gemfile.lock
|
106
|
+
- LICENSE
|
107
|
+
- README.md
|
108
|
+
- Rakefile
|
109
|
+
- lib/mapbox.rb
|
110
|
+
- lib/mapbox/api_operations.rb
|
111
|
+
- lib/mapbox/authentication_error.rb
|
112
|
+
- lib/mapbox/directions.rb
|
113
|
+
- lib/mapbox/geocoder.rb
|
114
|
+
- mapbox-sdk.gemspec
|
115
|
+
- test/directions_test.rb
|
116
|
+
- test/geocoding_test.rb
|
117
|
+
- test/mapbox_test.rb
|
118
|
+
homepage: https://mapbox.com/developers
|
119
|
+
licenses:
|
120
|
+
- MIT
|
121
|
+
metadata: {}
|
122
|
+
post_install_message:
|
123
|
+
rdoc_options: []
|
124
|
+
require_paths:
|
125
|
+
- lib
|
126
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - '>='
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '0'
|
131
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
132
|
+
requirements:
|
133
|
+
- - '>='
|
134
|
+
- !ruby/object:Gem::Version
|
135
|
+
version: '0'
|
136
|
+
requirements: []
|
137
|
+
rubyforge_project:
|
138
|
+
rubygems_version: 2.0.14
|
139
|
+
signing_key:
|
140
|
+
specification_version: 4
|
141
|
+
summary: Ruby bindings for the Mapbox API
|
142
|
+
test_files:
|
143
|
+
- test/directions_test.rb
|
144
|
+
- test/geocoding_test.rb
|
145
|
+
- test/mapbox_test.rb
|