azimuth 1.0.0 → 1.0.2
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/azimuth.gemspec +1 -0
- data/lib/azimuth/client/route_matrix.rb +7 -1
- data/lib/azimuth/request.rb +17 -3
- data/lib/azimuth/version.rb +1 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 36431dab57eede26a587b0bee380def8511ca099
|
4
|
+
data.tar.gz: 8ea98108ff7bc77ae9c8e0d96a85b35e6f972e59
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 80cf1c7446af92381dff7c62fc1f18d32689bd9a8788c07adef615fbd9bed86e3f7f1c875395740b867eaf50cda274c17f5b32152f3c1e0966c9b2a033ee2ee8
|
7
|
+
data.tar.gz: deb7272b65f0c57958cc283a5440053de76f77b0d08f5999060c0b57a020466103f5232ff29fd2ee8797c115c992ef9dcbbd2168593e53c7b2df670691c5d844
|
data/azimuth.gemspec
CHANGED
@@ -22,7 +22,7 @@ module Azimuth
|
|
22
22
|
private
|
23
23
|
|
24
24
|
def format_response(response)
|
25
|
-
response
|
25
|
+
delete_first_location_from_response(response) unless response.allToAll
|
26
26
|
|
27
27
|
response.locations.each_with_index.map do |location, i|
|
28
28
|
Hashie::Mash.new(
|
@@ -33,6 +33,12 @@ module Azimuth
|
|
33
33
|
)
|
34
34
|
end
|
35
35
|
end
|
36
|
+
|
37
|
+
def delete_first_location_from_response(response)
|
38
|
+
response.locations.delete_at(0)
|
39
|
+
response.time.delete_at(0)
|
40
|
+
response.distance.delete_at(0)
|
41
|
+
end
|
36
42
|
end
|
37
43
|
end
|
38
44
|
end
|
data/lib/azimuth/request.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
|
+
require 'active_support/core_ext/string/inflections'
|
2
|
+
|
1
3
|
module Azimuth
|
2
4
|
# Methods for HTTP requests
|
3
5
|
module Request
|
4
6
|
# Make a HTTP POST request.
|
5
7
|
#
|
6
8
|
# @param path [String] The path, relative to api_endpoint
|
7
|
-
# @param
|
9
|
+
# @param params [Hash] body params for request
|
8
10
|
# @return [Hashie::Mash]
|
9
11
|
def post(path, options={})
|
10
12
|
request(:post, path, options)
|
@@ -12,7 +14,9 @@ module Azimuth
|
|
12
14
|
|
13
15
|
private
|
14
16
|
|
15
|
-
def request(method, path,
|
17
|
+
def request(method, path, params)
|
18
|
+
camelize_options_keys(params[:options])
|
19
|
+
|
16
20
|
response = connection.send(method) do |request|
|
17
21
|
request.params['key'] = self.api_key
|
18
22
|
|
@@ -20,11 +24,21 @@ module Azimuth
|
|
20
24
|
when :post
|
21
25
|
request.headers['Content-Type'] = 'application/json'
|
22
26
|
request.path = path
|
23
|
-
request.body = MultiJson.dump(
|
27
|
+
request.body = MultiJson.dump(params) unless params.empty?
|
24
28
|
end
|
25
29
|
end
|
26
30
|
|
27
31
|
response.body
|
28
32
|
end
|
33
|
+
|
34
|
+
def camelize_options_keys(options)
|
35
|
+
return unless options
|
36
|
+
|
37
|
+
camelized_options = options.inject({}) do |opt, v|
|
38
|
+
opt.merge!(v.first.to_s.camelize(:lower) => v.last)
|
39
|
+
end
|
40
|
+
|
41
|
+
options.replace(camelized_options)
|
42
|
+
end
|
29
43
|
end
|
30
44
|
end
|
data/lib/azimuth/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: azimuth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aylic Petit
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-01-
|
11
|
+
date: 2014-01-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -94,6 +94,20 @@ dependencies:
|
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: 1.8.4
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: active_support
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 3.0.0
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 3.0.0
|
97
111
|
description: Simple Ruby wrapper for the MapQuest Direction API.
|
98
112
|
email:
|
99
113
|
- sush@users.noreply.github.com
|