google_distance_matrix 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 889a735e923a64e646fdd8d62f8b95e9cac813de
4
- data.tar.gz: aac05a54e40741a24969c3cd7ebc07e24531a535
3
+ metadata.gz: 1bafa7129b5e8795d2843bf132729e31ac07079e
4
+ data.tar.gz: ee670023245891199fe478f084b58b1e984ae7b4
5
5
  SHA512:
6
- metadata.gz: dae22319ffd3a4c144527985d729c1dfcd87432d830d7c9efa8434d8210285507f7890257a6ace2f26349dbb5f64523abee6599cec44bbd7b476e52b6e60502b
7
- data.tar.gz: f5d5950aa52c3527be20fe315de87a3f0e10a636d9e0c31d563a9f4d367dbeafab61a19426e477864fc5e4213609443c45ba4e96fb434ca2713cd16bc1d34f91
6
+ metadata.gz: b407618b92520edcc3a84199f5ab27e9db91598fb8c6e51b851379e6b4fb82f4d2fabe783eed065f4ba3a51ccc3a81abd4b99759546ae77e82ec49efccf954f8
7
+ data.tar.gz: cffa738e7f599684a5107755d0945924c229dedc320daa14b5cc71f70079409f572fdff199ed04f43a12889ff603df860e9ee04340cf649a058c08fec42d7647
data/.travis.yml CHANGED
@@ -1,9 +1,12 @@
1
+ before_install:
2
+ - gem update bundler
1
3
  rvm:
2
4
  - 2.0.0
3
5
  - 2.1.0
4
6
  - 2.1.2
5
7
  - 2.1.5
6
8
  - 2.2.3
9
+ - 2.3.0
7
10
  - ruby-head
8
11
  matrix:
9
12
  allow_failures:
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## v.0.2.1
2
+ * Made https be default (by almnes)
3
+
1
4
  ## v.0.2.0
2
5
  * Dropped support for Ruby 1.9.X
3
6
  * Added new configuration options: google_api_key,
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [![Build Status](https://travis-ci.org/Skalar/google_distance_matrix.svg?branch=master)](https://travis-ci.org/Skalar/google_distance_matrix)
4
4
 
5
- Ruby client for The Google Distance Matrix API.
5
+ Ruby client for the [Google Distance Matrix API](https://developers.google.com/maps/documentation/distance-matrix/intro).
6
6
 
7
7
  This lib makes Google's distance matrix API easy to work with,
8
8
  allowing you to set up some origins and destinations and
@@ -12,7 +12,7 @@ Once you have the matrix you can fetch all routes from a given
12
12
  origin or to a given destination.
13
13
 
14
14
  The matrix may also be used as a data set for traveling salesman problem,
15
- but to solve it you may look at http://ai4r.org/.
15
+ but to solve it you may look at <http://ai4r.org/>.
16
16
 
17
17
 
18
18
 
@@ -21,72 +21,87 @@ but to solve it you may look at http://ai4r.org/.
21
21
 
22
22
  ### Set up a matrix to work with
23
23
 
24
- matrix = GoogleDistanceMatrix::Matrix.new
24
+ ```ruby
25
+ matrix = GoogleDistanceMatrix::Matrix.new
26
+ ```
25
27
 
26
28
  ### Create some places to be used as origins or destinations for the matrix
27
-
28
- lat_lng = GoogleDistanceMatrix::Place.new lng: 12, lat: 12
29
- address = GoogleDistanceMatrix::Place.new address: "My address, Oslo"
30
- dest_address = GoogleDistanceMatrix::Place.new address: "Home, Oppegaard"
31
-
32
- point_dest = Point.new lat: 1, lng: 2
33
- dest_object = GoogleDistanceMatrix::Place.new point_dest
34
-
29
+ ```ruby
30
+ lat_lng = GoogleDistanceMatrix::Place.new lng: 12, lat: 12
31
+ address = GoogleDistanceMatrix::Place.new address: "My address, Oslo"
32
+ dest_address = GoogleDistanceMatrix::Place.new address: "Home, Oppegaard"
33
+
34
+ # Just an example of an object responding to lat & lng.
35
+ # Point class isn't included in this gem, but feel free to
36
+ # create your own point class or use something like https://github.com/nofxx/georuby
37
+ point_dest = Point.new lat: 1, lng: 2
38
+ dest_object = GoogleDistanceMatrix::Place.new point_dest
39
+ ```
35
40
  ### Add places to matrix's origins and destinations
36
-
37
- matrix.origins << lat_lng << address
38
- matrix.destinations << dest_address << dest_object
39
-
40
- # Added objects will be wrapped in a place automatically, so you may skip manyally creating Places.
41
- another_point = Point.new lat: 1, lng: 3
42
- matrix.origins << another_point
43
-
41
+ ```ruby
42
+ matrix.origins << lat_lng << address
43
+ matrix.destinations << dest_address << dest_object
44
+
45
+ # Added objects will be wrapped in a place automatically, so you may skip manyally creating Places.
46
+ another_point = Point.new lat: 1, lng: 3
47
+ matrix.origins << another_point
48
+ ```
44
49
  ### Do some configuration - see GoogleDistanceMatrix.configure_defaults as well.
45
-
46
- matrix.configure do |config|
47
- config.mode = 'driving'
48
- config.avoid = ['tolls']
49
-
50
- # To build signed URLs to use with a Google Business account. You may also use google_api_key.
51
- config.google_business_api_client_id = "123"
52
- config.google_business_api_private_key = "your-secret-key"
53
- end
54
-
50
+ ```ruby
51
+ matrix.configure do |config|
52
+ config.mode = 'driving'
53
+ config.avoid = ['tolls']
54
+
55
+ # To build signed URLs to use with a Google Business account.
56
+ config.google_business_api_client_id = "123"
57
+ config.google_business_api_private_key = "your-secret-key"
58
+
59
+ # If you have an API key, you can specify that as well.
60
+ config.google_api_key = "YOUR_API_KEY"
61
+ end
62
+ ```
55
63
  ### Get the data for the matrix
56
64
 
57
- # Returns the data, loaded from Google, for this matrix.
58
- # It is a multi dimensional array. Rows are ordered according to the values in the origins.
59
- # Each row corresponds to an origin, and each element within that row corresponds to
60
- # a pairing of the origin with a destination.
61
- matrix.data
65
+ `matrix.data` returns the data, loaded from Google, for this matrix.
66
+
67
+ It is a multi dimensional array. Rows are ordered according to the values in the origins.
68
+ Each row corresponds to an origin, and each element within that row corresponds to a pairing of the origin with a destination.
62
69
 
63
- ### Query the matrix
64
70
 
65
- # Returns an array of Google::DistanceMatrix::Route, all having given origin or destination.
66
- matrix.routes_for dest_address
71
+ ### Query the matrix
67
72
 
68
- # Returns Google::DistanceMatrix::Route with given origin and destination
69
- matrix.route_for origin: lat_lng, destination: dest_address
73
+ Returns an array of Google::DistanceMatrix::Route, all having given origin or destination.
70
74
 
71
- matrix.shortest_route_by_distance_to(dest_address) # returns Google::DistanceMatrix::Route with one origin and a destination, together with route data
72
- matrix.shortest_route_by_duration_to(dest_address) # returns Google::DistanceMatrix::Route with one origin and a destination, together with route data
75
+ ```ruby
76
+ matrix.routes_for dest_address
77
+ ```
73
78
 
74
- # In cases you built the place with an object (not hash with attributes) you may provide that object
75
- # as well asking for routes. This is true for route_for and shortest_route_by_* as well.
76
- matrix.routes_for point_dest # Returns routes for dest_object
79
+ Returns Google::DistanceMatrix::Route with given origin and destination
77
80
 
78
- You may call query methods with a bang, in which case it will fail with an error if noe all routes in your result set for the called method is ok.
81
+ ```ruby
82
+ matrix.route_for origin: lat_lng, destination: dest_address
83
+ # Google::DistanceMatrix::Route with one origin and a destination, together with route data
84
+ matrix.shortest_route_by_distance_to(dest_address)
85
+ # Google::DistanceMatrix::Route with one origin and a destination, together with route data
86
+ matrix.shortest_route_by_duration_to(dest_address)
87
+ ```
79
88
 
89
+ In cases where you built the place with an object (not hash with attributes) you may provide that object as well asking for routes. This is true for `route_for` and `shortest_route_by_*` as well.
80
90
 
91
+ ```ruby
92
+ matrix.routes_for point_dest # Returns routes for dest_object
93
+ ```
81
94
 
95
+ You may call query methods with a bang, in which case it will fail with an error if not all of the routes in your result set for the called method are ok.
82
96
 
83
97
 
84
98
  ## Installation
85
99
 
86
100
  Add this line to your application's Gemfile:
87
101
 
88
- gem 'google_distance_matrix'
89
-
102
+ ```ruby
103
+ gem 'google_distance_matrix'
104
+ ```
90
105
  And then execute:
91
106
 
92
107
  $ bundle
@@ -96,26 +111,25 @@ Or install it yourself as:
96
111
  $ gem install google_distance_matrix
97
112
 
98
113
 
99
-
100
-
101
114
  ## Configuration
102
115
 
103
- Configuration is done directly on a matrix or via GoogleDistanceMatrix.configure_defaults.
104
- Apart from configuration on requests it is also possible to provide your own logger class and
105
- set a cache.
116
+ Configuration is done directly on a matrix or via `GoogleDistanceMatrix.configure_defaults`.
117
+ Apart from configuration on requests it is also possible to provide your own logger class and
118
+ set a cache.
106
119
 
107
120
  ### Request cache
108
121
 
109
- Given Google's limit to the service you may have the need to cache requests. This is done by simply
110
- using URL as cache keys. Cache we'll accept should provide a default ActiveSupport::Cache::Store interface.
111
-
112
- GoogleDistanceMatrix.configure_defaults do |config|
113
- config.cache = ActiveSupport::Cache.lookup_store :your_store, {
114
- expires_in: 12.hours
115
- # ..or other options you like for your store
116
- }
117
- end
118
-
122
+ Given Google's limit to the service you may have the need to cache requests. This is done by simply
123
+ using URL as cache keys. Cache we'll accept should provide a default ActiveSupport::Cache::Store interface.
124
+
125
+ ```ruby
126
+ GoogleDistanceMatrix.configure_defaults do |config|
127
+ config.cache = ActiveSupport::Cache.lookup_store :your_store, {
128
+ expires_in: 12.hours
129
+ # ..or other options you like for your store
130
+ }
131
+ end
132
+ ```
119
133
 
120
134
 
121
135
  ## Contributing
@@ -36,7 +36,7 @@ module GoogleDistanceMatrix
36
36
 
37
37
  def initialize
38
38
  self.sensor = false
39
- self.protocol = "http"
39
+ self.protocol = "https"
40
40
  self.lat_lng_scale = 5
41
41
 
42
42
  API_DEFAULTS.each_pair do |attr_name, value|
@@ -1,3 +1,3 @@
1
1
  module GoogleDistanceMatrix
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
@@ -77,7 +77,7 @@ describe GoogleDistanceMatrix::Configuration do
77
77
  it { expect(subject.avoid).to be_nil }
78
78
  it { expect(subject.units).to eq "metric" }
79
79
  it { expect(subject.lat_lng_scale).to eq 5 }
80
- it { expect(subject.protocol).to eq 'http' }
80
+ it { expect(subject.protocol).to eq 'https' }
81
81
  it { expect(subject.language).to be_nil }
82
82
 
83
83
  it { expect(subject.departure_time).to be_nil }
@@ -53,12 +53,12 @@ describe GoogleDistanceMatrix::UrlBuilder do
53
53
  end
54
54
 
55
55
  it "starts with the base URL" do
56
- expect(subject.url).to start_with "http://" + described_class::BASE_URL
56
+ expect(subject.url).to start_with "https://" + described_class::BASE_URL
57
57
  end
58
58
 
59
59
  it "has a configurable protocol" do
60
- matrix.configure { |c| c.protocol = "https" }
61
- expect(subject.url).to start_with "https://"
60
+ matrix.configure { |c| c.protocol = "http" }
61
+ expect(subject.url).to start_with "http://"
62
62
  end
63
63
 
64
64
  it "includes origins" do
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.2.0
4
+ version: 0.2.1
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: 2015-10-13 00:00:00.000000000 Z
11
+ date: 2016-04-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport