azimuth 1.0.0 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2bb19f0b0c81b19c9ef79e3e5ecd08850c9c302c
4
- data.tar.gz: 9d58a7bfda4e2ff8b6a3d822e4e2e016d9f04b90
3
+ metadata.gz: 36431dab57eede26a587b0bee380def8511ca099
4
+ data.tar.gz: 8ea98108ff7bc77ae9c8e0d96a85b35e6f972e59
5
5
  SHA512:
6
- metadata.gz: eafec56b6419352f70e9ffee73cd8ad57428bb38934212d777f2e9ac865b3fec7b6a3b88e95082e849657e59973ed80ecd225c116bdda9e5cec23475d8299e42
7
- data.tar.gz: 19966e521427518e548a14b9a23663290b505efe5f0bdef8ff94a57f3b2090ef3d8f52ca03644083fd047ec37a1d4099a572dbd825c509a194c20f040ccbb531
6
+ metadata.gz: 80cf1c7446af92381dff7c62fc1f18d32689bd9a8788c07adef615fbd9bed86e3f7f1c875395740b867eaf50cda274c17f5b32152f3c1e0966c9b2a033ee2ee8
7
+ data.tar.gz: deb7272b65f0c57958cc283a5440053de76f77b0d08f5999060c0b57a020466103f5232ff29fd2ee8797c115c992ef9dcbbd2168593e53c7b2df670691c5d844
@@ -28,4 +28,5 @@ Gem::Specification.new do |gem|
28
28
  gem.add_dependency 'hashie', '~>2.0.5'
29
29
  gem.add_dependency 'json', '~>1.8.1'
30
30
  gem.add_dependency 'multi_json', '~>1.8.4'
31
+ gem.add_dependency 'active_support', '~>3.0.0'
31
32
  end
@@ -22,7 +22,7 @@ module Azimuth
22
22
  private
23
23
 
24
24
  def format_response(response)
25
- response.locations.delete_at(0) unless response.allToAll
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
@@ -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 options [Hash] body params for request
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, options)
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(options) unless options.empty?
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
@@ -1,5 +1,5 @@
1
1
  module Azimuth
2
2
  # Current version
3
3
  # @return [String]
4
- VERSION = '1.0.0'.freeze
4
+ VERSION = '1.0.2'.freeze
5
5
  end
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.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-13 00:00:00.000000000 Z
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