google_directions 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -3,7 +3,7 @@ require 'rubygems'
3
3
  require 'rake'
4
4
  require 'echoe'
5
5
 
6
- Echoe.new('google_directions', '0.1.3') do |p|
6
+ Echoe.new('google_directions', '0.1.4') do |p|
7
7
  p.description = "Ruby-wrapper for Google Directions API. Can return the drive time and driving distance between to places"
8
8
  p.url = "http://github.com/joshcrews/Google-Directions-Ruby"
9
9
  p.author = "Josh Crews"
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{google_directions}
5
- s.version = "0.1.3"
5
+ s.version = "0.1.4"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Josh Crews"]
9
- s.date = %q{2010-07-20}
9
+ s.date = %q{2010-07-21}
10
10
  s.description = %q{Ruby-wrapper for Google Directions API. Can return the drive time and driving distance between to places}
11
11
  s.email = %q{josh@joshcrews.com}
12
12
  s.extra_rdoc_files = ["README.textile", "lib/google_directions.rb"]
@@ -10,7 +10,6 @@ class GoogleDirections
10
10
  @location_2 = location_2
11
11
  options = "origin=#{transcribe(@location_1)}&destination=#{transcribe(@location_2)}"
12
12
  @xml_call = @base_url + options
13
- @xml = get_url(@xml_call)
14
13
  @status = find_status
15
14
  end
16
15
 
@@ -18,13 +17,17 @@ class GoogleDirections
18
17
  #http://maps.google.com/maps/api/directions/xml?origin=St.+Louis,+MO&destination=Nashville,+TN&sensor=false&key=ABQIAAAAINgf4OmAIbIdWblvypOUhxSQ8yY-fgrep0oj4uKpavE300Q6ExQlxB7SCyrAg2evsxwAsak4D0Liiv
19
18
 
20
19
  def find_status
21
- doc = Nokogiri::XML(@xml)
20
+ doc = Nokogiri::XML(xml)
22
21
  doc.css("status").text
23
22
  end
24
23
 
25
- def xml
26
- @xml
27
- end
24
+ def xml
25
+ unless @xml.nil?
26
+ @xml
27
+ else
28
+ @xml ||= get_url(@xml_call)
29
+ end
30
+ end
28
31
 
29
32
  def xml_call
30
33
  @xml_call
@@ -34,7 +37,7 @@ class GoogleDirections
34
37
  if @status != "OK"
35
38
  drive_time = 0
36
39
  else
37
- doc = Nokogiri::XML(@xml)
40
+ doc = Nokogiri::XML(xml)
38
41
  drive_time = doc.css("duration value").last.text
39
42
  convert_to_minutes(drive_time)
40
43
  end
@@ -44,7 +47,7 @@ class GoogleDirections
44
47
  if @status != "OK"
45
48
  distance_in_miles = 0
46
49
  else
47
- doc = Nokogiri::XML(@xml)
50
+ doc = Nokogiri::XML(xml)
48
51
  meters = doc.css("distance value").last.text
49
52
  distance_in_miles = (meters.to_f / 1610.22).round
50
53
  distance_in_miles
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google_directions
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 3
10
- version: 0.1.3
9
+ - 4
10
+ version: 0.1.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Josh Crews
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-07-20 00:00:00 -05:00
18
+ date: 2010-07-21 00:00:00 -05:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency