azimuth 1.0.2 → 1.0.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.
- data/azimuth.gemspec +0 -1
- data/lib/azimuth/client/route_matrix.rb +3 -3
- data/lib/azimuth/request.rb +2 -12
- data/lib/azimuth/version.rb +1 -1
- data/lib/core_ext/hash.rb +17 -0
- data/spec/lib/core_ext/hash_spec.rb +25 -0
- metadata +50 -44
- checksums.yaml +0 -7
data/azimuth.gemspec
CHANGED
@@ -35,9 +35,9 @@ module Azimuth
|
|
35
35
|
end
|
36
36
|
|
37
37
|
def delete_first_location_from_response(response)
|
38
|
-
|
39
|
-
|
40
|
-
|
38
|
+
[:locations, :time, :distance].each do |info|
|
39
|
+
response.public_send(info).delete_at(0)
|
40
|
+
end
|
41
41
|
end
|
42
42
|
end
|
43
43
|
end
|
data/lib/azimuth/request.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'core_ext/hash'
|
2
2
|
|
3
3
|
module Azimuth
|
4
4
|
# Methods for HTTP requests
|
@@ -15,7 +15,7 @@ module Azimuth
|
|
15
15
|
private
|
16
16
|
|
17
17
|
def request(method, path, params)
|
18
|
-
|
18
|
+
params[:options].camelize_keys! if params[:options]
|
19
19
|
|
20
20
|
response = connection.send(method) do |request|
|
21
21
|
request.params['key'] = self.api_key
|
@@ -30,15 +30,5 @@ module Azimuth
|
|
30
30
|
|
31
31
|
response.body
|
32
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
|
43
33
|
end
|
44
34
|
end
|
data/lib/azimuth/version.rb
CHANGED
@@ -0,0 +1,17 @@
|
|
1
|
+
# @private
|
2
|
+
class Hash
|
3
|
+
def camelize_keys!
|
4
|
+
self.keys.each_with_index do |key, i|
|
5
|
+
|
6
|
+
value = delete(key)
|
7
|
+
|
8
|
+
camelized_key = key.to_s.split('_').each_with_index do |s, idx|
|
9
|
+
next if idx.zero?
|
10
|
+
|
11
|
+
s.capitalize!
|
12
|
+
end.join('').to_sym
|
13
|
+
|
14
|
+
self[camelized_key] = value
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Hash do
|
4
|
+
describe '#camelize_keys!' do
|
5
|
+
context 'with underscores keys' do
|
6
|
+
let(:hash) { { first_key: 1 } }
|
7
|
+
|
8
|
+
before { hash.camelize_keys! }
|
9
|
+
|
10
|
+
it 'camelized hash keys' do
|
11
|
+
expect(hash.keys.first).to eql(:firstKey)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
context 'with camelized keys' do
|
16
|
+
let(:hash) { { firstKey: 1 } }
|
17
|
+
|
18
|
+
before { hash.camelize_keys! }
|
19
|
+
|
20
|
+
it 'keeps keys camelized' do
|
21
|
+
expect(hash.keys.first).to eql(:firstKey)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
metadata
CHANGED
@@ -1,113 +1,112 @@
|
|
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.3
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- Aylic Petit
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date: 2014-01-
|
12
|
+
date: 2014-01-20 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: bundler
|
15
16
|
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
16
18
|
requirements:
|
17
|
-
- -
|
19
|
+
- - ~>
|
18
20
|
- !ruby/object:Gem::Version
|
19
21
|
version: '1.0'
|
20
22
|
type: :development
|
21
23
|
prerelease: false
|
22
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
23
26
|
requirements:
|
24
|
-
- -
|
27
|
+
- - ~>
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: '1.0'
|
27
30
|
- !ruby/object:Gem::Dependency
|
28
31
|
name: faraday
|
29
32
|
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
30
34
|
requirements:
|
31
|
-
- -
|
35
|
+
- - ~>
|
32
36
|
- !ruby/object:Gem::Version
|
33
37
|
version: 0.8.9
|
34
38
|
type: :runtime
|
35
39
|
prerelease: false
|
36
40
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
37
42
|
requirements:
|
38
|
-
- -
|
43
|
+
- - ~>
|
39
44
|
- !ruby/object:Gem::Version
|
40
45
|
version: 0.8.9
|
41
46
|
- !ruby/object:Gem::Dependency
|
42
47
|
name: faraday_middleware
|
43
48
|
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
44
50
|
requirements:
|
45
|
-
- -
|
51
|
+
- - ~>
|
46
52
|
- !ruby/object:Gem::Version
|
47
53
|
version: 0.9.0
|
48
54
|
type: :runtime
|
49
55
|
prerelease: false
|
50
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
51
58
|
requirements:
|
52
|
-
- -
|
59
|
+
- - ~>
|
53
60
|
- !ruby/object:Gem::Version
|
54
61
|
version: 0.9.0
|
55
62
|
- !ruby/object:Gem::Dependency
|
56
63
|
name: hashie
|
57
64
|
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
58
66
|
requirements:
|
59
|
-
- -
|
67
|
+
- - ~>
|
60
68
|
- !ruby/object:Gem::Version
|
61
69
|
version: 2.0.5
|
62
70
|
type: :runtime
|
63
71
|
prerelease: false
|
64
72
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
65
74
|
requirements:
|
66
|
-
- -
|
75
|
+
- - ~>
|
67
76
|
- !ruby/object:Gem::Version
|
68
77
|
version: 2.0.5
|
69
78
|
- !ruby/object:Gem::Dependency
|
70
79
|
name: json
|
71
80
|
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
72
82
|
requirements:
|
73
|
-
- -
|
83
|
+
- - ~>
|
74
84
|
- !ruby/object:Gem::Version
|
75
85
|
version: 1.8.1
|
76
86
|
type: :runtime
|
77
87
|
prerelease: false
|
78
88
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
79
90
|
requirements:
|
80
|
-
- -
|
91
|
+
- - ~>
|
81
92
|
- !ruby/object:Gem::Version
|
82
93
|
version: 1.8.1
|
83
94
|
- !ruby/object:Gem::Dependency
|
84
95
|
name: multi_json
|
85
96
|
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
86
98
|
requirements:
|
87
|
-
- -
|
99
|
+
- - ~>
|
88
100
|
- !ruby/object:Gem::Version
|
89
101
|
version: 1.8.4
|
90
102
|
type: :runtime
|
91
103
|
prerelease: false
|
92
104
|
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
93
106
|
requirements:
|
94
|
-
- -
|
107
|
+
- - ~>
|
95
108
|
- !ruby/object:Gem::Version
|
96
109
|
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
|
111
110
|
description: Simple Ruby wrapper for the MapQuest Direction API.
|
112
111
|
email:
|
113
112
|
- sush@users.noreply.github.com
|
@@ -115,57 +114,63 @@ executables: []
|
|
115
114
|
extensions: []
|
116
115
|
extra_rdoc_files: []
|
117
116
|
files:
|
118
|
-
-
|
119
|
-
- CONTRIBUTING.md
|
117
|
+
- .yardopts
|
120
118
|
- LICENSE
|
121
119
|
- README.md
|
120
|
+
- CONTRIBUTING.md
|
122
121
|
- Rakefile
|
123
122
|
- azimuth.gemspec
|
124
|
-
- lib/azimuth.rb
|
125
|
-
- lib/azimuth/
|
123
|
+
- spec/lib/azimuth/client/route_matrix_spec.rb
|
124
|
+
- spec/lib/azimuth/client_spec.rb
|
125
|
+
- spec/lib/azimuth/request_spec.rb
|
126
|
+
- spec/lib/azimuth_spec.rb
|
127
|
+
- spec/lib/core_ext/hash_spec.rb
|
128
|
+
- spec/spec_helper.rb
|
129
|
+
- spec/support/shared_examples/error.rb
|
130
|
+
- spec/support/shared_examples/route_matrix_request.rb
|
126
131
|
- lib/azimuth/client/route_matrix.rb
|
132
|
+
- lib/azimuth/client.rb
|
127
133
|
- lib/azimuth/configuration.rb
|
128
134
|
- lib/azimuth/connection.rb
|
129
135
|
- lib/azimuth/error.rb
|
130
136
|
- lib/azimuth/request.rb
|
131
137
|
- lib/azimuth/response/raise_error.rb
|
132
138
|
- lib/azimuth/version.rb
|
139
|
+
- lib/azimuth.rb
|
140
|
+
- lib/core_ext/hash.rb
|
133
141
|
- spec/cassettes/Azimuth_Client_RouteMatrix/_route_matrix/behaves_like_a_route_matrix_request/returns_locations_coordinates.yml
|
134
142
|
- spec/cassettes/Azimuth_Client_RouteMatrix/_route_matrix/behaves_like_a_route_matrix_request/returns_locations_distances_to_destination.yml
|
135
143
|
- spec/cassettes/Azimuth_Client_RouteMatrix/_route_matrix/behaves_like_a_route_matrix_request/returns_locations_driving_times_to_destination.yml
|
136
144
|
- spec/cassettes/Azimuth_Client_RouteMatrix/_route_matrix/with_all_to_all_options/it_returns_destination_informations.yml
|
137
145
|
- spec/cassettes/Azimuth_Client_RouteMatrix/_route_matrix/with_many_to_one_options/does_not_return_destination_informations.yml
|
138
146
|
- spec/cassettes/Azimuth_Client_RouteMatrix/_route_matrix/with_no_optionnal_options/does_not_return_destination_informations.yml
|
139
|
-
- spec/lib/azimuth/client/route_matrix_spec.rb
|
140
|
-
- spec/lib/azimuth/client_spec.rb
|
141
|
-
- spec/lib/azimuth/request_spec.rb
|
142
|
-
- spec/lib/azimuth_spec.rb
|
143
|
-
- spec/spec_helper.rb
|
144
|
-
- spec/support/shared_examples/error.rb
|
145
|
-
- spec/support/shared_examples/route_matrix_request.rb
|
146
147
|
homepage: https://github.com/sush/azimuth
|
147
148
|
licenses:
|
148
149
|
- MIT
|
149
|
-
metadata: {}
|
150
150
|
post_install_message:
|
151
151
|
rdoc_options: []
|
152
152
|
require_paths:
|
153
153
|
- lib
|
154
154
|
required_ruby_version: !ruby/object:Gem::Requirement
|
155
|
+
none: false
|
155
156
|
requirements:
|
156
|
-
- -
|
157
|
+
- - ! '>='
|
157
158
|
- !ruby/object:Gem::Version
|
158
159
|
version: 1.9.2
|
159
160
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
161
|
+
none: false
|
160
162
|
requirements:
|
161
|
-
- -
|
163
|
+
- - ! '>='
|
162
164
|
- !ruby/object:Gem::Version
|
163
165
|
version: '0'
|
166
|
+
segments:
|
167
|
+
- 0
|
168
|
+
hash: 2134473011234115090
|
164
169
|
requirements: []
|
165
170
|
rubyforge_project:
|
166
|
-
rubygems_version:
|
171
|
+
rubygems_version: 1.8.23
|
167
172
|
signing_key:
|
168
|
-
specification_version:
|
173
|
+
specification_version: 3
|
169
174
|
summary: MapQuest Direction API Ruby wrapper
|
170
175
|
test_files:
|
171
176
|
- spec/cassettes/Azimuth_Client_RouteMatrix/_route_matrix/behaves_like_a_route_matrix_request/returns_locations_coordinates.yml
|
@@ -178,6 +183,7 @@ test_files:
|
|
178
183
|
- spec/lib/azimuth/client_spec.rb
|
179
184
|
- spec/lib/azimuth/request_spec.rb
|
180
185
|
- spec/lib/azimuth_spec.rb
|
186
|
+
- spec/lib/core_ext/hash_spec.rb
|
181
187
|
- spec/spec_helper.rb
|
182
188
|
- spec/support/shared_examples/error.rb
|
183
189
|
- spec/support/shared_examples/route_matrix_request.rb
|
checksums.yaml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz: 36431dab57eede26a587b0bee380def8511ca099
|
4
|
-
data.tar.gz: 8ea98108ff7bc77ae9c8e0d96a85b35e6f972e59
|
5
|
-
SHA512:
|
6
|
-
metadata.gz: 80cf1c7446af92381dff7c62fc1f18d32689bd9a8788c07adef615fbd9bed86e3f7f1c875395740b867eaf50cda274c17f5b32152f3c1e0966c9b2a033ee2ee8
|
7
|
-
data.tar.gz: deb7272b65f0c57958cc283a5440053de76f77b0d08f5999060c0b57a020466103f5232ff29fd2ee8797c115c992ef9dcbbd2168593e53c7b2df670691c5d844
|