google_maps_api-distance_matrix 0.2.1 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b11c66dd2bab535f70004cfbbd22b5dc5380f0fc
4
- data.tar.gz: 1df40cb57af2326de439298222b00ab8775432f9
3
+ metadata.gz: 459789156b49eb9dbb78089412679ea631fa42e7
4
+ data.tar.gz: e07ae87b679cf02a170e2f574c67dd0de17ea36a
5
5
  SHA512:
6
- metadata.gz: a8a24cb2d932c9a49171ed23f06454d880c31bc37a4e88bdc9e9f8435cca4ca762fa91d95047729c1e99cb42f48b39eeae8be8d9d08a1a5189e876147e18c424
7
- data.tar.gz: 208c417d9488d7a27decdc6aa33ba77f6eb40775aeb36a1cc247155505b0143fd1795fc09b670e91659aad0415e632a92507f47de3ea5fdbfc1696429dd49e79
6
+ metadata.gz: ef94a05beaaa4ae899f18c7fb78c9338ed9cf852351cf7aa01a4e6f9fb66a87ca5c078ff4935643503e5b947036eab0adb5b72b00e7673896e875cfdddf90f24
7
+ data.tar.gz: 2c6c7b61902279fb15187881372ddfbe33bf0a704948a6cd5b191b2726c3b7ea56ac3fc0ca5fdcb8aec090e213764ef39efb23b0b57e6d1a05723568829b6a21
data/.rspec CHANGED
@@ -1,3 +1,2 @@
1
1
  --color
2
- --warnings
3
2
  --require spec_helper
@@ -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@outlook.com"]
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", ">= 3.0.0.beta2", "< 4"
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
- self.new(
12
- hash["status"],
13
- GoogleMapsAPI::Core::Duration.from_hash(hash["duration"]),
14
- GoogleMapsAPI::Core::Distance.from_hash(hash["distance"])
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
@@ -1,4 +1,5 @@
1
1
  require "net/http"
2
+ require "date"
2
3
 
3
4
  class GoogleMapsAPI::DistanceMatrix::Request
4
5
  BASE_PATH = "/maps/api/distancematrix/json"
@@ -1,5 +1,5 @@
1
1
  module GoogleMapsAPI
2
2
  module DistanceMatrix
3
- VERSION = "0.2.1"
3
+ VERSION = "0.2.2"
4
4
  end
5
5
  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": "OK",
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.1
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: 2014-09-16 00:00:00.000000000 Z
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: '4'
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: '4'
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@outlook.com
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.2.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.