distance_fox 0.1.4 → 0.1.5
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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +5 -3
- data/distance_fox.gemspec +1 -1
- data/lib/distance_fox/calculations.rb +2 -2
- data/lib/distance_fox/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3482b2639db7abb94e287131976731cb735d6a00a9e4ee1a59baedabbc225d5c
|
|
4
|
+
data.tar.gz: 85e0ff5dc5060e139881d4999459eda4f1ad49c50410a6106e8f5020a9b68104
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bc7bae93bca18e0f510cd4bec4d3bf24122c870d2e6236118af132136f0815e997aa495266ba106355ffa09837777be18763f52da2f76f97cf8db2c9301547b3
|
|
7
|
+
data.tar.gz: 3d120db76f035a238e979e455a5dad137659da57643c6ca1e19235d7cca1062cb1ca43abf80a3a5100bce0596eafa726ed53762aa4aaf41e87642de881d8a2cc
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
|
@@ -20,7 +20,9 @@ Or install it yourself as:
|
|
|
20
20
|
|
|
21
21
|
## Configuration
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
Activate "Distance Matrix API" & "Geocoding API" in your Google Developers Console.
|
|
24
|
+
|
|
25
|
+
Set up DistanceFox with your API Key:
|
|
24
26
|
|
|
25
27
|
```ruby
|
|
26
28
|
DistanceFox.configure do |config|
|
|
@@ -37,7 +39,7 @@ end
|
|
|
37
39
|
# * a geocodable address (string)
|
|
38
40
|
#
|
|
39
41
|
# Destinations can be:
|
|
40
|
-
# *
|
|
42
|
+
# * an array of hashes ([{'city' => 'City', 'coordinates' => ['lat','lon']}])
|
|
41
43
|
DistanceFox::Calculations.nearest_driving_distance(origin_coordinates, destinations)
|
|
42
44
|
|
|
43
45
|
# Origin can be:
|
|
@@ -45,7 +47,7 @@ DistanceFox::Calculations.nearest_driving_distance(origin_coordinates, destinati
|
|
|
45
47
|
# * an array of string coordinates (['lat','lon'])
|
|
46
48
|
#
|
|
47
49
|
# Destinations can be:
|
|
48
|
-
# *
|
|
50
|
+
# * an array of hashes ([{'city' => 'City', 'coordinates' => ['lat','lon']}])
|
|
49
51
|
DistanceFox::Calculations.nearest_linear_distance(origin, destinations)
|
|
50
52
|
|
|
51
53
|
# Origin and destination can be:
|
data/distance_fox.gemspec
CHANGED
|
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
|
10
10
|
|
|
11
11
|
spec.summary = 'Calculate the driving distance from a destination to the nearest of multiple locations'
|
|
12
12
|
spec.license = 'MIT'
|
|
13
|
-
spec.required_ruby_version = '>= 2.
|
|
13
|
+
spec.required_ruby_version = '>= 2.5.0'
|
|
14
14
|
|
|
15
15
|
# Specify which files should be added to the gem when it is released.
|
|
16
16
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
@@ -35,7 +35,7 @@ module DistanceFox
|
|
|
35
35
|
# * an array of string coordinates (['lat','lon'])
|
|
36
36
|
#
|
|
37
37
|
# Destinations can be:
|
|
38
|
-
# *
|
|
38
|
+
# * an array of hashes ([{'city' => 'City', 'coordinates' => ['lat','lon']}])
|
|
39
39
|
def self.nearest_linear_distance(origin, destinations)
|
|
40
40
|
origins_with_distance = []
|
|
41
41
|
origin_coordinates = extract_coordinates origin
|
|
@@ -76,7 +76,7 @@ module DistanceFox
|
|
|
76
76
|
# * a geocodable address (string)
|
|
77
77
|
#
|
|
78
78
|
# Destinations can be:
|
|
79
|
-
# *
|
|
79
|
+
# * an array of hashes ([{'city' => 'City', 'coordinates' => ['lat','lon']}])
|
|
80
80
|
def self.nearest_driving_distance(origin, destinations)
|
|
81
81
|
origin = origin.join(',')
|
|
82
82
|
destination = nearest_linear_distance(origin, destinations)['coordinates']['destination'].join(',')
|
data/lib/distance_fox/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: distance_fox
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- danielwollen
|
|
@@ -101,7 +101,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
101
101
|
requirements:
|
|
102
102
|
- - ">="
|
|
103
103
|
- !ruby/object:Gem::Version
|
|
104
|
-
version: 2.
|
|
104
|
+
version: 2.5.0
|
|
105
105
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
106
106
|
requirements:
|
|
107
107
|
- - ">="
|