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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 33dec0642bc1710b545500e0fc8b91b92e5a7ce3
4
- data.tar.gz: 16161e144683e67c1fc2da5e06d5a16987e8d314
3
+ metadata.gz: 87ff87fa819023f3a7df1755f6ea105407153493
4
+ data.tar.gz: 58405c0061e23763bf2c413ecb1c3a49fb9217c5
5
5
  SHA512:
6
- metadata.gz: 355c36ef1688ecc8719d3f7a614468fd8abcce91ef17f3149e161063759c271c0f5c9e75f4f97498a7e19f0e950bd3dc459e4e302450a6aad1b4ed74100849ff
7
- data.tar.gz: '04979e3530d5e33f10b7575034b8bb06f9ad8b01e46e9b11dac48ee630cf9f2ce92f69a511a38d97e737717ba6ffa455bcc39abf206b15395b9416292e3934df'
6
+ metadata.gz: 0b8303f7579e002366f355e59b052f3302ab3450e5aa7efa2ffff08d785b7aa17b26a4e2168ddbc6f2aaaebf8bee503eb840b58dfb71af4087a19f80403b7db4
7
+ data.tar.gz: 764b47fe6f8c5f4eaa3f6bc3da8bf689e83992ae6fefd7335882f01e516ec948b64d7c0e6e08bbc685eae26a1989d5f87c2e8a35898a22dc6b1e8126f784825a
data/.travis.yml CHANGED
@@ -1,7 +1,10 @@
1
1
  sudo: false
2
2
  language: ruby
3
3
  rvm:
4
+ - 2.2.5
5
+ - 2.2.6
4
6
  - 2.3.3
7
+ - 2.4.0
5
8
  before_install: gem install bundler -v 1.13.7
6
9
  script:
7
10
  - bundle exec rake test
@@ -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.strip().tr(" ", "+")
8
- @destination = destination.strip().tr(" ", "+")
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.")
@@ -1,3 +1,3 @@
1
1
  module DistanceFinder
2
- VERSION = "1.0.2"
2
+ VERSION = "1.0.3"
3
3
  end
@@ -4,6 +4,7 @@ require "distance_finder/interface"
4
4
  require "net/http"
5
5
  require "json"
6
6
  require 'socket'
7
+ require 'active_support/inflector'
7
8
 
8
9
  module DistanceFinder
9
10
 
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.2
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-14 00:00:00.000000000 Z
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