google_distance_matrix 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/.travis.yml +1 -0
- data/CHANGELOG.md +9 -0
- data/README.md +1 -1
- data/google_distance_matrix.gemspec +3 -3
- data/lib/google_distance_matrix/configuration.rb +12 -7
- data/lib/google_distance_matrix/version.rb +1 -1
- data/spec/lib/google_distance_matrix/configuration_spec.rb +4 -23
- data/spec/lib/google_distance_matrix/matrix_spec.rb +4 -4
- data/spec/lib/google_distance_matrix/url_builder_spec.rb +2 -6
- 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: 90be905a03cf4356641158bddfc9d73e8dbcd30a
|
4
|
+
data.tar.gz: aa34d8e0ef5d84c3041105c6e07e5a05e8fbf30a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 99df75867c1dee0fc7c2fea2d9d1811cb236d2a9acbfbddce2e4ad0bff73a62a28ae9fadfcc8eec8b18b0cdf3739cf0047f0876178d0ddcc211020c4e822fa66
|
7
|
+
data.tar.gz: a27b71536a839707da8e62bb1d58e76c0cb8f255698f62e084938c002adb7eda0d81a5bee3dec8af74fc9903ace9e674640cc6ca23735d03bae60c9346363c54
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.3.1
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
## v.0.3.0 (unreleased)
|
2
|
+
This release includes one breaking change, the removal of sensor parameter.
|
3
|
+
This parameter is no longer used - see:
|
4
|
+
https://developers.google.com/maps/documentation/distance-matrix/intro#Sensor
|
5
|
+
|
6
|
+
* Remove sensor attribute. (by rpocklin)
|
7
|
+
* Added "transit_routing_preference" and "traffic_model" attributes to request. (by rpocklin)
|
8
|
+
* Added "ferries", "indoor" as valid avoid value. (by rpocklin)
|
9
|
+
|
1
10
|
## v.0.2.1
|
2
11
|
* Made https be default (by almnes)
|
3
12
|
|
data/README.md
CHANGED
@@ -50,7 +50,7 @@ matrix.origins << another_point
|
|
50
50
|
```ruby
|
51
51
|
matrix.configure do |config|
|
52
52
|
config.mode = 'driving'
|
53
|
-
config.avoid =
|
53
|
+
config.avoid = 'tolls'
|
54
54
|
|
55
55
|
# To build signed URLs to use with a Google Business account.
|
56
56
|
config.google_business_api_client_id = "123"
|
@@ -23,8 +23,8 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.add_dependency "google_business_api_url_signer", "~> 0.1.3"
|
24
24
|
|
25
25
|
spec.add_development_dependency "bundler"
|
26
|
-
spec.add_development_dependency "rspec", "~> 3.
|
27
|
-
spec.add_development_dependency "shoulda-matchers", "~> 3.
|
28
|
-
spec.add_development_dependency "webmock", "~>
|
26
|
+
spec.add_development_dependency "rspec", "~> 3.4.0"
|
27
|
+
spec.add_development_dependency "shoulda-matchers", "~> 3.1.1"
|
28
|
+
spec.add_development_dependency "webmock", "~> 2.0.2"
|
29
29
|
spec.add_development_dependency "rake"
|
30
30
|
end
|
@@ -3,17 +3,23 @@ module GoogleDistanceMatrix
|
|
3
3
|
#
|
4
4
|
# Holds configuration used when building API URL.
|
5
5
|
#
|
6
|
-
# See https://developers.google.com/maps/documentation/
|
6
|
+
# See https://developers.google.com/maps/documentation/distance-matrix/intro
|
7
7
|
# for documentation on each configuration.
|
8
8
|
#
|
9
9
|
class Configuration
|
10
10
|
include ActiveModel::Validations
|
11
11
|
|
12
|
-
ATTRIBUTES = %w[
|
12
|
+
ATTRIBUTES = %w[
|
13
|
+
mode avoid units language
|
14
|
+
departure_time arrival_time
|
15
|
+
transit_mode transit_routing_preference
|
16
|
+
traffic_model
|
17
|
+
]
|
13
18
|
|
14
19
|
API_DEFAULTS = {
|
15
20
|
mode: "driving",
|
16
|
-
units: "metric"
|
21
|
+
units: "metric",
|
22
|
+
traffic_model: "best_guess"
|
17
23
|
}.with_indifferent_access
|
18
24
|
|
19
25
|
attr_accessor *ATTRIBUTES, :protocol, :logger, :lat_lng_scale
|
@@ -21,21 +27,20 @@ module GoogleDistanceMatrix
|
|
21
27
|
attr_accessor :cache
|
22
28
|
|
23
29
|
|
24
|
-
validates :sensor, inclusion: {in: [true, false]}
|
25
30
|
validates :mode, inclusion: {in: ["driving", "walking", "bicycling", "transit"]}, allow_blank: true
|
26
|
-
validates :avoid, inclusion: {in: ["tolls", "highways"]}, allow_blank: true
|
31
|
+
validates :avoid, inclusion: {in: ["tolls", "highways", "ferries", "indoor"]}, allow_blank: true
|
27
32
|
validates :units, inclusion: {in: ["metric", "imperial"]}, allow_blank: true
|
28
33
|
|
29
34
|
validates :departure_time, numericality: true, allow_blank: true
|
30
35
|
validates :arrival_time, numericality: true, allow_blank: true
|
31
36
|
|
32
37
|
validates :transit_mode, inclusion: {in: %w[bus subway train tram rail]}, allow_blank: true
|
38
|
+
validates :transit_routing_preference, inclusion: {in: %w[less_walking fewer_transfers]}, allow_blank: true
|
39
|
+
validates :traffic_model, inclusion: {in: %w[best_guess pessimistic optimistic]}, allow_blank: true
|
33
40
|
|
34
41
|
validates :protocol, inclusion: {in: ["http", "https"]}, allow_blank: true
|
35
42
|
|
36
|
-
|
37
43
|
def initialize
|
38
|
-
self.sensor = false
|
39
44
|
self.protocol = "https"
|
40
45
|
self.lat_lng_scale = 5
|
41
46
|
|
@@ -6,26 +6,6 @@ describe GoogleDistanceMatrix::Configuration do
|
|
6
6
|
subject { described_class.new }
|
7
7
|
|
8
8
|
describe "Validations" do
|
9
|
-
describe "sensor" do
|
10
|
-
it "is valid with true" do
|
11
|
-
subject.sensor = true
|
12
|
-
subject.valid?
|
13
|
-
expect(subject.errors[:sensor].length).to eq 0
|
14
|
-
end
|
15
|
-
|
16
|
-
it "is valid with false" do
|
17
|
-
subject.sensor = false
|
18
|
-
subject.valid?
|
19
|
-
expect(subject.errors[:sensor].length).to eq 0
|
20
|
-
end
|
21
|
-
|
22
|
-
it "is invalid with 'foo'" do
|
23
|
-
subject.sensor = 'foo'
|
24
|
-
subject.valid?
|
25
|
-
expect(subject.errors[:sensor].length).to eq 1
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
9
|
describe 'departure_time' do
|
30
10
|
it 'is valid with a timestamp' do
|
31
11
|
subject.departure_time = Time.now.to_i
|
@@ -55,10 +35,9 @@ describe GoogleDistanceMatrix::Configuration do
|
|
55
35
|
end
|
56
36
|
|
57
37
|
it { should validate_inclusion_of(:mode).in_array(["driving", "walking", "bicycling", "transit"]) }
|
58
|
-
|
59
38
|
it { should allow_value(nil).for(:mode) }
|
60
39
|
|
61
|
-
it { should validate_inclusion_of(:avoid).in_array(["tolls", "highways"]) }
|
40
|
+
it { should validate_inclusion_of(:avoid).in_array(["tolls", "highways", "ferries", "indoor"]) }
|
62
41
|
it { should allow_value(nil).for(:avoid) }
|
63
42
|
|
64
43
|
it { should validate_inclusion_of(:units).in_array(["metric", "imperial"]) }
|
@@ -68,11 +47,12 @@ describe GoogleDistanceMatrix::Configuration do
|
|
68
47
|
it { should validate_inclusion_of(:protocol).in_array(["http", "https"]) }
|
69
48
|
|
70
49
|
it { should validate_inclusion_of(:transit_mode).in_array(["bus", "subway", "train", "tram", "rail"])}
|
50
|
+
it { should validate_inclusion_of(:transit_routing_preference).in_array(["less_walking", "fewer_transfers"])}
|
51
|
+
it { should validate_inclusion_of(:traffic_model).in_array(["best_guess", "pessimistic", "optimistic"])}
|
71
52
|
end
|
72
53
|
|
73
54
|
|
74
55
|
describe "defaults" do
|
75
|
-
it { expect(subject.sensor).to eq false }
|
76
56
|
it { expect(subject.mode).to eq "driving" }
|
77
57
|
it { expect(subject.avoid).to be_nil }
|
78
58
|
it { expect(subject.units).to eq "metric" }
|
@@ -83,6 +63,7 @@ describe GoogleDistanceMatrix::Configuration do
|
|
83
63
|
it { expect(subject.departure_time).to be_nil }
|
84
64
|
it { expect(subject.arrival_time).to be_nil }
|
85
65
|
it { expect(subject.transit_mode).to be_nil }
|
66
|
+
it { expect(subject.traffic_model).to eq 'best_guess' }
|
86
67
|
|
87
68
|
it { expect(subject.google_business_api_client_id).to be_nil }
|
88
69
|
it { expect(subject.google_business_api_private_key).to be_nil }
|
@@ -44,14 +44,14 @@ describe GoogleDistanceMatrix::Matrix do
|
|
44
44
|
|
45
45
|
it "has it's own configuration" do
|
46
46
|
expect {
|
47
|
-
subject.configure { |c| c.
|
48
|
-
}.to_not change(GoogleDistanceMatrix.default_configuration, :
|
47
|
+
subject.configure { |c| c.mode = !GoogleDistanceMatrix.default_configuration.mode }
|
48
|
+
}.to_not change(GoogleDistanceMatrix.default_configuration, :mode)
|
49
49
|
end
|
50
50
|
|
51
51
|
it "has a configurable configuration :-)" do
|
52
52
|
expect {
|
53
|
-
subject.configure { |c| c.
|
54
|
-
}.to change(subject.configuration, :
|
53
|
+
subject.configure { |c| c.mode = !GoogleDistanceMatrix.default_configuration.mode }
|
54
|
+
}.to change(subject.configuration, :mode).to !GoogleDistanceMatrix.default_configuration.mode
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
@@ -35,7 +35,7 @@ describe GoogleDistanceMatrix::UrlBuilder do
|
|
35
35
|
|
36
36
|
it "fails if matrix's configuration is invalid" do
|
37
37
|
expect {
|
38
|
-
matrix.configure { |c| c.
|
38
|
+
matrix.configure { |c| c.mode = 'foobar' }
|
39
39
|
described_class.new matrix
|
40
40
|
}.to raise_error GoogleDistanceMatrix::InvalidMatrix
|
41
41
|
end
|
@@ -80,10 +80,6 @@ describe GoogleDistanceMatrix::UrlBuilder do
|
|
80
80
|
end
|
81
81
|
|
82
82
|
describe "configuration" do
|
83
|
-
it "includes sensor" do
|
84
|
-
expect(subject.url).to include "sensor=#{matrix.configuration.sensor}"
|
85
|
-
end
|
86
|
-
|
87
83
|
context 'with google api key set' do
|
88
84
|
before do
|
89
85
|
matrix.configure do |config|
|
@@ -109,7 +105,7 @@ describe GoogleDistanceMatrix::UrlBuilder do
|
|
109
105
|
end
|
110
106
|
|
111
107
|
it "has signature" do
|
112
|
-
expect(subject.url).to include "signature=
|
108
|
+
expect(subject.url).to include "signature=DIUgkQ_BaVBJU6hwhzH3GLeMdeo="
|
113
109
|
end
|
114
110
|
end
|
115
111
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: google_distance_matrix
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thorbjørn Hermansen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-05-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -72,42 +72,42 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 3.
|
75
|
+
version: 3.4.0
|
76
76
|
type: :development
|
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: 3.
|
82
|
+
version: 3.4.0
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: shoulda-matchers
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: 3.
|
89
|
+
version: 3.1.1
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: 3.
|
96
|
+
version: 3.1.1
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: webmock
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
103
|
+
version: 2.0.2
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version:
|
110
|
+
version: 2.0.2
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: rake
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -186,7 +186,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
186
186
|
version: '0'
|
187
187
|
requirements: []
|
188
188
|
rubyforge_project:
|
189
|
-
rubygems_version: 2.
|
189
|
+
rubygems_version: 2.5.1
|
190
190
|
signing_key:
|
191
191
|
specification_version: 4
|
192
192
|
summary: Ruby client for The Google Distance Matrix API
|