gistance 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -3
- data/gistance.gemspec +3 -3
- data/lib/gistance/configuration.rb +2 -2
- data/lib/gistance/request.rb +1 -1
- data/lib/gistance/version.rb +1 -1
- data/spec/cassettes/Gistance_Client_DistanceMatrix/_distance_matrix/returns_an_array_of_destination_addresses.yml +2 -2
- data/spec/cassettes/Gistance_Client_DistanceMatrix/_distance_matrix/returns_an_array_of_origin_addresses.yml +2 -2
- data/spec/cassettes/Gistance_Client_DistanceMatrix/_distance_matrix/returns_the_destination_address.yml +2 -2
- data/spec/cassettes/Gistance_Client_DistanceMatrix/_distance_matrix/returns_the_distance_between_origin_and_destination.yml +2 -2
- data/spec/cassettes/Gistance_Client_DistanceMatrix/_distance_matrix/returns_the_origin_address.yml +2 -2
- data/spec/cassettes/Gistance_Client_DistanceMatrix/_distance_matrix/returns_the_travel_duration_between_origin_and_destination.yml +2 -2
- data/spec/lib/gistance/client_spec.rb +5 -5
- data/spec/lib/gistance/request_spec.rb +17 -2
- data/spec/spec_helper.rb +1 -1
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 19bd9d56947e3ca6c8928a676f133748aac382ed
|
4
|
+
data.tar.gz: 6e17c917f886d710220754edd936bbf586ccf9c3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2c24751f2975401787661da72216a95ca9c8770768b742c3c8ba525920cd5ea4872c41f22de23d3cfe848cfd6c32f5f0a9f2ab3d81768c845d1f45ffd8311932
|
7
|
+
data.tar.gz: 778c86fec5a8e26cba1cdb898d00e6a839fcec26b1ef1ceb6f8c5afe35e6a6204ef72399f3e45730d9613a1f8194ce9ed7b091c4adf40ec5a7751e621407384e
|
data/README.md
CHANGED
@@ -33,7 +33,7 @@ API methods are available as module methods
|
|
33
33
|
```ruby
|
34
34
|
Gistance.configure do |c|
|
35
35
|
c.api_key = 'YOUR_API_KEY'
|
36
|
-
c.
|
36
|
+
c.units = 'imperial' # default to metric
|
37
37
|
c.language = 'fr' # default to en
|
38
38
|
c.sensor = true # default to false
|
39
39
|
end
|
@@ -44,13 +44,13 @@ or as client instance methods
|
|
44
44
|
```ruby
|
45
45
|
Gistance::Client.new(
|
46
46
|
api_key: 'YOUR_API_KEY',
|
47
|
-
|
47
|
+
units: 'imperial',
|
48
48
|
language: 'fr',
|
49
49
|
sensor: true
|
50
50
|
)
|
51
51
|
```
|
52
52
|
|
53
|
-
The `
|
53
|
+
The `units`, `language` and `sensor` parameters can be set globally or can be provided for every request if passed as parameters.
|
54
54
|
|
55
55
|
## Authentication
|
56
56
|
|
data/gistance.gemspec
CHANGED
@@ -22,9 +22,9 @@ Gem::Specification.new do |gem|
|
|
22
22
|
gem.require_paths = ['lib']
|
23
23
|
gem.test_files = Dir.glob('spec/**/*')
|
24
24
|
|
25
|
-
gem.add_dependency 'faraday', '~>
|
26
|
-
gem.add_dependency 'faraday_middleware', '~> 0.9.
|
25
|
+
gem.add_dependency 'faraday', '~>0.9.1'
|
26
|
+
gem.add_dependency 'faraday_middleware', '~> 0.9.1'
|
27
27
|
gem.add_dependency 'hashie', '~>2.0.5'
|
28
28
|
gem.add_dependency 'json', '~>1.8.1'
|
29
|
-
gem.add_dependency 'multi_json', '~>1.
|
29
|
+
gem.add_dependency 'multi_json', '~>1.11.0'
|
30
30
|
end
|
@@ -6,7 +6,7 @@ module Gistance
|
|
6
6
|
:api_endpoint,
|
7
7
|
:api_key,
|
8
8
|
:language,
|
9
|
-
:
|
9
|
+
:units,
|
10
10
|
:sensor,
|
11
11
|
:business
|
12
12
|
].freeze
|
@@ -36,7 +36,7 @@ module Gistance
|
|
36
36
|
self.api_endpoint = DEFAULT_API_ENDPOINT
|
37
37
|
self.api_key = nil
|
38
38
|
self.language = 'en'
|
39
|
-
self.
|
39
|
+
self.units = 'metric'
|
40
40
|
self.sensor = false
|
41
41
|
self.business = nil
|
42
42
|
end
|
data/lib/gistance/request.rb
CHANGED
@@ -17,7 +17,7 @@ module Gistance
|
|
17
17
|
|
18
18
|
def request(method, options)
|
19
19
|
response = connection.send(method) do |request|
|
20
|
-
[:language, :
|
20
|
+
[:language, :units, :sensor].each do |option|
|
21
21
|
request.params[option] = options.delete(option) || self.public_send(option)
|
22
22
|
end
|
23
23
|
|
data/lib/gistance/version.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
http_interactions:
|
3
3
|
- request:
|
4
4
|
method: get
|
5
|
-
uri: https://maps.googleapis.com/maps/api/distancematrix/json?destinations=48.857066,%202.341138&language=en&origins=10%2BPlace%2Bde%2Bla%2BConcorde,%2B75008%2BParis,%2BFrance&sensor=false&
|
5
|
+
uri: https://maps.googleapis.com/maps/api/distancematrix/json?destinations=48.857066,%202.341138&language=en&origins=10%2BPlace%2Bde%2Bla%2BConcorde,%2B75008%2BParis,%2BFrance&sensor=false&units=metric
|
6
6
|
body:
|
7
7
|
encoding: US-ASCII
|
8
8
|
string: ''
|
@@ -61,6 +61,6 @@ http_interactions:
|
|
61
61
|
],
|
62
62
|
"status" : "OK"
|
63
63
|
}
|
64
|
-
http_version:
|
64
|
+
http_version:
|
65
65
|
recorded_at: Wed, 02 Apr 2014 22:24:10 GMT
|
66
66
|
recorded_with: VCR 2.9.0
|
@@ -2,7 +2,7 @@
|
|
2
2
|
http_interactions:
|
3
3
|
- request:
|
4
4
|
method: get
|
5
|
-
uri: https://maps.googleapis.com/maps/api/distancematrix/json?destinations=48.857066,%202.341138&language=en&origins=10%2BPlace%2Bde%2Bla%2BConcorde,%2B75008%2BParis,%2BFrance&sensor=false&
|
5
|
+
uri: https://maps.googleapis.com/maps/api/distancematrix/json?destinations=48.857066,%202.341138&language=en&origins=10%2BPlace%2Bde%2Bla%2BConcorde,%2B75008%2BParis,%2BFrance&sensor=false&units=metric
|
6
6
|
body:
|
7
7
|
encoding: US-ASCII
|
8
8
|
string: ''
|
@@ -61,6 +61,6 @@ http_interactions:
|
|
61
61
|
],
|
62
62
|
"status" : "OK"
|
63
63
|
}
|
64
|
-
http_version:
|
64
|
+
http_version:
|
65
65
|
recorded_at: Wed, 02 Apr 2014 22:24:10 GMT
|
66
66
|
recorded_with: VCR 2.9.0
|
@@ -2,7 +2,7 @@
|
|
2
2
|
http_interactions:
|
3
3
|
- request:
|
4
4
|
method: get
|
5
|
-
uri: https://maps.googleapis.com/maps/api/distancematrix/json?destinations=48.857066,%202.341138&language=en&origins=10%2BPlace%2Bde%2Bla%2BConcorde,%2B75008%2BParis,%2BFrance&sensor=false&
|
5
|
+
uri: https://maps.googleapis.com/maps/api/distancematrix/json?destinations=48.857066,%202.341138&language=en&origins=10%2BPlace%2Bde%2Bla%2BConcorde,%2B75008%2BParis,%2BFrance&sensor=false&units=metric
|
6
6
|
body:
|
7
7
|
encoding: US-ASCII
|
8
8
|
string: ''
|
@@ -61,6 +61,6 @@ http_interactions:
|
|
61
61
|
],
|
62
62
|
"status" : "OK"
|
63
63
|
}
|
64
|
-
http_version:
|
64
|
+
http_version:
|
65
65
|
recorded_at: Wed, 02 Apr 2014 22:24:11 GMT
|
66
66
|
recorded_with: VCR 2.9.0
|
@@ -2,7 +2,7 @@
|
|
2
2
|
http_interactions:
|
3
3
|
- request:
|
4
4
|
method: get
|
5
|
-
uri: https://maps.googleapis.com/maps/api/distancematrix/json?destinations=48.857066,%202.341138&language=en&origins=10%2BPlace%2Bde%2Bla%2BConcorde,%2B75008%2BParis,%2BFrance&sensor=false&
|
5
|
+
uri: https://maps.googleapis.com/maps/api/distancematrix/json?destinations=48.857066,%202.341138&language=en&origins=10%2BPlace%2Bde%2Bla%2BConcorde,%2B75008%2BParis,%2BFrance&sensor=false&units=metric
|
6
6
|
body:
|
7
7
|
encoding: US-ASCII
|
8
8
|
string: ''
|
@@ -61,6 +61,6 @@ http_interactions:
|
|
61
61
|
],
|
62
62
|
"status" : "OK"
|
63
63
|
}
|
64
|
-
http_version:
|
64
|
+
http_version:
|
65
65
|
recorded_at: Wed, 02 Apr 2014 22:24:10 GMT
|
66
66
|
recorded_with: VCR 2.9.0
|
data/spec/cassettes/Gistance_Client_DistanceMatrix/_distance_matrix/returns_the_origin_address.yml
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
http_interactions:
|
3
3
|
- request:
|
4
4
|
method: get
|
5
|
-
uri: https://maps.googleapis.com/maps/api/distancematrix/json?destinations=48.857066,%202.341138&language=en&origins=10%2BPlace%2Bde%2Bla%2BConcorde,%2B75008%2BParis,%2BFrance&sensor=false&
|
5
|
+
uri: https://maps.googleapis.com/maps/api/distancematrix/json?destinations=48.857066,%202.341138&language=en&origins=10%2BPlace%2Bde%2Bla%2BConcorde,%2B75008%2BParis,%2BFrance&sensor=false&units=metric
|
6
6
|
body:
|
7
7
|
encoding: US-ASCII
|
8
8
|
string: ''
|
@@ -61,6 +61,6 @@ http_interactions:
|
|
61
61
|
],
|
62
62
|
"status" : "OK"
|
63
63
|
}
|
64
|
-
http_version:
|
64
|
+
http_version:
|
65
65
|
recorded_at: Wed, 02 Apr 2014 22:24:09 GMT
|
66
66
|
recorded_with: VCR 2.9.0
|
@@ -2,7 +2,7 @@
|
|
2
2
|
http_interactions:
|
3
3
|
- request:
|
4
4
|
method: get
|
5
|
-
uri: https://maps.googleapis.com/maps/api/distancematrix/json?destinations=48.857066,%202.341138&language=en&origins=10%2BPlace%2Bde%2Bla%2BConcorde,%2B75008%2BParis,%2BFrance&sensor=false&
|
5
|
+
uri: https://maps.googleapis.com/maps/api/distancematrix/json?destinations=48.857066,%202.341138&language=en&origins=10%2BPlace%2Bde%2Bla%2BConcorde,%2B75008%2BParis,%2BFrance&sensor=false&units=metric
|
6
6
|
body:
|
7
7
|
encoding: US-ASCII
|
8
8
|
string: ''
|
@@ -61,6 +61,6 @@ http_interactions:
|
|
61
61
|
],
|
62
62
|
"status" : "OK"
|
63
63
|
}
|
64
|
-
http_version:
|
64
|
+
http_version:
|
65
65
|
recorded_at: Wed, 02 Apr 2014 22:24:11 GMT
|
66
66
|
recorded_with: VCR 2.9.0
|
@@ -52,17 +52,17 @@ describe Gistance::Client do
|
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
55
|
-
describe '
|
56
|
-
it 'sets
|
55
|
+
describe 'units' do
|
56
|
+
it 'sets units' do
|
57
57
|
client = Gistance::Client.new
|
58
58
|
|
59
|
-
expect(client.
|
59
|
+
expect(client.units).to eql 'metric'
|
60
60
|
end
|
61
61
|
|
62
62
|
it 'overrides module configuration' do
|
63
|
-
client = Gistance::Client.new(
|
63
|
+
client = Gistance::Client.new(units: 'imperial')
|
64
64
|
|
65
|
-
expect(client.
|
65
|
+
expect(client.units).to eql 'imperial'
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
@@ -23,13 +23,28 @@ describe Gistance::Request do
|
|
23
23
|
|
24
24
|
assert_requested :get, 'https://maps.googleapis.com/maps/api/distancematrix/json?'\
|
25
25
|
'language=en&'\
|
26
|
-
'
|
26
|
+
'units=metric&'\
|
27
27
|
'sensor=false&'\
|
28
28
|
'client=gme-fuubar&'\
|
29
29
|
'channel=test&'\
|
30
|
-
'signature=
|
30
|
+
'signature=JlBk9pESGAhVTtCZbidG8Ss2fbM%3D'
|
31
31
|
|
32
32
|
VCR.turn_on!
|
33
33
|
end
|
34
|
+
|
35
|
+
it 'respects overridden options' do
|
36
|
+
stub_request(:get, /.*maps.*/).to_return(body: { status: 'ok' }.to_json)
|
37
|
+
|
38
|
+
business_client.units = 'imperial'
|
39
|
+
|
40
|
+
business_client.get
|
41
|
+
|
42
|
+
expect(
|
43
|
+
a_request(:get, 'https://maps.googleapis.com/maps/api/distancematrix/json').
|
44
|
+
with(:query => hash_including("units" => "imperial"))
|
45
|
+
).
|
46
|
+
to have_been_made
|
47
|
+
|
48
|
+
end
|
34
49
|
end
|
35
50
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gistance
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aylic Petit
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-09-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -16,28 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.9.1
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.
|
26
|
+
version: 0.9.1
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: faraday_middleware
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.9.
|
33
|
+
version: 0.9.1
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.9.
|
40
|
+
version: 0.9.1
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: hashie
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 1.
|
75
|
+
version: 1.11.0
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 1.
|
82
|
+
version: 1.11.0
|
83
83
|
description: Simple Ruby wrapper for the Google Distance Matrix API.
|
84
84
|
email:
|
85
85
|
- sush@users.noreply.github.com
|
@@ -134,7 +134,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
134
134
|
version: '0'
|
135
135
|
requirements: []
|
136
136
|
rubyforge_project:
|
137
|
-
rubygems_version: 2.
|
137
|
+
rubygems_version: 2.4.8
|
138
138
|
signing_key:
|
139
139
|
specification_version: 4
|
140
140
|
summary: Google Distance Matrix API Ruby wrapper
|