distance_finder 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -0
- data/distance_finder.gemspec +2 -0
- data/lib/distance_finder/calculator.rb +7 -2
- data/lib/distance_finder/interface.rb +1 -1
- data/lib/distance_finder/version.rb +1 -1
- data/lib/distance_finder.rb +1 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 87ff87fa819023f3a7df1755f6ea105407153493
|
4
|
+
data.tar.gz: 58405c0061e23763bf2c413ecb1c3a49fb9217c5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0b8303f7579e002366f355e59b052f3302ab3450e5aa7efa2ffff08d785b7aa17b26a4e2168ddbc6f2aaaebf8bee503eb840b58dfb71af4087a19f80403b7db4
|
7
|
+
data.tar.gz: 764b47fe6f8c5f4eaa3f6bc3da8bf689e83992ae6fefd7335882f01e516ec948b64d7c0e6e08bbc685eae26a1989d5f87c2e8a35898a22dc6b1e8126f784825a
|
data/.travis.yml
CHANGED
data/distance_finder.gemspec
CHANGED
@@ -21,6 +21,8 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
22
|
spec.require_paths = ["lib"]
|
23
23
|
|
24
|
+
spec.add_dependency 'activesupport'
|
25
|
+
|
24
26
|
spec.add_development_dependency "bundler", "~> 1.13"
|
25
27
|
spec.add_development_dependency "rake", "~> 10.0"
|
26
28
|
spec.add_development_dependency "minitest", "~> 5.0"
|
@@ -4,8 +4,8 @@ module DistanceFinder
|
|
4
4
|
attr_reader :distance, :duration, :start_address, :end_address, :display_full_response
|
5
5
|
|
6
6
|
def initialize(origin, destination)
|
7
|
-
@origin = origin
|
8
|
-
@destination = destination
|
7
|
+
@origin = strip_input(origin)
|
8
|
+
@destination = strip_input(destination)
|
9
9
|
@google_object = parse_response
|
10
10
|
end
|
11
11
|
|
@@ -40,6 +40,7 @@ module DistanceFinder
|
|
40
40
|
puts JSON.pretty_generate(@google_object)
|
41
41
|
end
|
42
42
|
|
43
|
+
|
43
44
|
def parse_response
|
44
45
|
if get_response.kind_of? Net::HTTPSuccess
|
45
46
|
JSON.parse(get_response.body)
|
@@ -64,5 +65,9 @@ module DistanceFinder
|
|
64
65
|
"https://maps.googleapis.com/maps/api/directions/json?origin=#{@origin}&destination=#{@destination}"
|
65
66
|
end
|
66
67
|
|
68
|
+
def strip_input(string)
|
69
|
+
ActiveSupport::Inflector.transliterate(string).strip()
|
70
|
+
end
|
71
|
+
|
67
72
|
end
|
68
73
|
end
|
@@ -42,7 +42,7 @@ module DistanceFinder
|
|
42
42
|
if route.status == "OK"
|
43
43
|
puts format_result("⊗ Origin:", route.start_address)
|
44
44
|
puts format_result("⊗ Destination:", route.end_address)
|
45
|
-
puts format_result("⇄ Distance:", route.distance.round(1).to_s + "miles")
|
45
|
+
puts format_result("⇄ Distance:", route.distance.round(1).to_s + " miles")
|
46
46
|
puts format_result("🕑 Travel time:", route.duration)
|
47
47
|
else
|
48
48
|
puts format_result("Sorry, unable to find the route.")
|
data/lib/distance_finder.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: distance_finder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Slawomir Cieslak
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-02-
|
11
|
+
date: 2017-02-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activesupport
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: bundler
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|