google_maps_api-distance_matrix 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +0 -1
- data/google_maps_api-distance_matrix.gemspec +2 -2
- data/lib/google_maps_api/distance_matrix/element.rb +10 -6
- data/lib/google_maps_api/distance_matrix/request.rb +1 -0
- data/lib/google_maps_api/distance_matrix/version.rb +1 -1
- data/spec/google_maps_api/distance_matrix/element_spec.rb +9 -0
- data/spec/google_maps_api/distance_matrix/response_mock.json +1 -9
- metadata +8 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 459789156b49eb9dbb78089412679ea631fa42e7
|
4
|
+
data.tar.gz: e07ae87b679cf02a170e2f574c67dd0de17ea36a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef94a05beaaa4ae899f18c7fb78c9338ed9cf852351cf7aa01a4e6f9fb66a87ca5c078ff4935643503e5b947036eab0adb5b72b00e7673896e875cfdddf90f24
|
7
|
+
data.tar.gz: 2c6c7b61902279fb15187881372ddfbe33bf0a704948a6cd5b191b2726c3b7ea56ac3fc0ca5fdcb8aec090e213764ef39efb23b0b57e6d1a05723568829b6a21
|
data/.rspec
CHANGED
@@ -7,7 +7,7 @@ Gem::Specification.new do |spec|
|
|
7
7
|
spec.name = "google_maps_api-distance_matrix"
|
8
8
|
spec.version = GoogleMapsAPI::DistanceMatrix::VERSION
|
9
9
|
spec.authors = ["Felipe Zavan"]
|
10
|
-
spec.email = ["zavan
|
10
|
+
spec.email = ["felipe@zavan.me"]
|
11
11
|
spec.summary = %q{Wrapper around the Google Maps Distance Matrix API.}
|
12
12
|
spec.homepage = "https://github.com/zavan/google_maps_api-distance_matrix"
|
13
13
|
spec.license = "MIT"
|
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
|
|
19
19
|
|
20
20
|
spec.add_development_dependency "bundler", "~> 1.6"
|
21
21
|
spec.add_development_dependency "rake"
|
22
|
-
spec.add_development_dependency "rspec", "
|
22
|
+
spec.add_development_dependency "rspec", "~> 3.4.0"
|
23
23
|
|
24
24
|
spec.add_dependency "google_maps_api-core", "~> 0.2"
|
25
25
|
end
|
@@ -1,17 +1,21 @@
|
|
1
1
|
class GoogleMapsAPI::DistanceMatrix::Element
|
2
2
|
attr_reader :status, :duration, :distance
|
3
3
|
|
4
|
-
def initialize(status, duration, distance)
|
4
|
+
def initialize(status, duration = nil, distance = nil)
|
5
5
|
@status = status
|
6
6
|
@duration = duration
|
7
7
|
@distance = distance
|
8
8
|
end
|
9
9
|
|
10
10
|
def self.from_hash(hash)
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
11
|
+
if hash["status"] == "OK"
|
12
|
+
new(
|
13
|
+
hash["status"],
|
14
|
+
GoogleMapsAPI::Core::Duration.from_hash(hash["duration"]),
|
15
|
+
GoogleMapsAPI::Core::Distance.from_hash(hash["distance"])
|
16
|
+
)
|
17
|
+
else
|
18
|
+
new(hash["status"])
|
19
|
+
end
|
16
20
|
end
|
17
21
|
end
|
@@ -10,5 +10,14 @@ describe GoogleMapsAPI::DistanceMatrix::Element do
|
|
10
10
|
it "returns a new element" do
|
11
11
|
expect(subject.from_hash(parsed_json["rows"].first["elements"].first)).to be_a(subject)
|
12
12
|
end
|
13
|
+
|
14
|
+
it "handles 'ZERO_RESULTS' status" do
|
15
|
+
element = subject.from_hash(parsed_json["rows"].first["elements"][1])
|
16
|
+
|
17
|
+
expect(element).to be_a(subject)
|
18
|
+
expect(element.status).to eq("ZERO_RESULTS")
|
19
|
+
expect(element.distance).to be_nil
|
20
|
+
expect(element.duration).to be_nil
|
21
|
+
end
|
13
22
|
end
|
14
23
|
end
|
@@ -14,15 +14,7 @@
|
|
14
14
|
"text": "1 735 km"
|
15
15
|
}
|
16
16
|
}, {
|
17
|
-
"status": "
|
18
|
-
"duration": {
|
19
|
-
"value": 24487,
|
20
|
-
"text": "6 heures 48 minutes"
|
21
|
-
},
|
22
|
-
"distance": {
|
23
|
-
"value": 129324,
|
24
|
-
"text": "129 km"
|
25
|
-
}
|
17
|
+
"status" : "ZERO_RESULTS"
|
26
18
|
} ]
|
27
19
|
}, {
|
28
20
|
"elements": [ {
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: google_maps_api-distance_matrix
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Felipe Zavan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-03-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -42,22 +42,16 @@ dependencies:
|
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: 3.0.0.beta2
|
48
|
-
- - "<"
|
45
|
+
- - "~>"
|
49
46
|
- !ruby/object:Gem::Version
|
50
|
-
version:
|
47
|
+
version: 3.4.0
|
51
48
|
type: :development
|
52
49
|
prerelease: false
|
53
50
|
version_requirements: !ruby/object:Gem::Requirement
|
54
51
|
requirements:
|
55
|
-
- - "
|
56
|
-
- !ruby/object:Gem::Version
|
57
|
-
version: 3.0.0.beta2
|
58
|
-
- - "<"
|
52
|
+
- - "~>"
|
59
53
|
- !ruby/object:Gem::Version
|
60
|
-
version:
|
54
|
+
version: 3.4.0
|
61
55
|
- !ruby/object:Gem::Dependency
|
62
56
|
name: google_maps_api-core
|
63
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -74,7 +68,7 @@ dependencies:
|
|
74
68
|
version: '0.2'
|
75
69
|
description:
|
76
70
|
email:
|
77
|
-
- zavan
|
71
|
+
- felipe@zavan.me
|
78
72
|
executables: []
|
79
73
|
extensions: []
|
80
74
|
extra_rdoc_files: []
|
@@ -122,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
122
116
|
version: '0'
|
123
117
|
requirements: []
|
124
118
|
rubyforge_project:
|
125
|
-
rubygems_version: 2.
|
119
|
+
rubygems_version: 2.5.1
|
126
120
|
signing_key:
|
127
121
|
specification_version: 4
|
128
122
|
summary: Wrapper around the Google Maps Distance Matrix API.
|