google_directions 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.textile CHANGED
@@ -20,9 +20,13 @@ xml_call = directions.xml_call
20
20
 
21
21
  h3. Error situations
22
22
 
23
+ status: NOT_FOUND
24
+
23
25
  If Google can't recognize your places, the distance_in_miles and drive_time_in_minutes will each return 0. You can call <pre>directions.status</pre> and it should return "NOT_FOUND" (directions.status will also return any other Google API call statuses)
24
26
 
25
- TODO: handle QUERY_OVER_LIMIT
27
+ status: OVER_QUERY_LIMIT
28
+
29
+ If Google thinks you've hit their API too many times in day, or too rapidly, for your given IP address and API key; they might return OVER_QUERY_LIMIT. In this case distance_in_miles and drive_time_in_minutes will each return 0. You can call <pre>directions.status</pre> and it should return "OVER_QUERY_LIMIT"
26
30
 
27
31
  h2. Installation
28
32
 
@@ -58,3 +62,13 @@ http://code.google.com/apis/maps/signup.html
58
62
 
59
63
  Include it as the constant GOOGLE_MAPS_API_KEY in an app configuration file (environment.rb, config/initializers/api_keys.rb)
60
64
 
65
+ h3. Need turn-by-turn directions?
66
+
67
+ Not yet included in this gem, but you can do it with nokogiri to parse the XML that comes back when you do
68
+ <pre>GoogleDirections.new(origin, destination).xml</pre>
69
+ And then nokogiri can cycle through each <step> and you can pick out what you need.
70
+
71
+ h2. License
72
+
73
+ Anyone can use this code in any way.
74
+
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.1') do |p|
6
+ Echoe.new('google_directions', '0.1.2') 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.1"
5
+ s.version = "0.1.2"
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-14}
9
+ s.date = %q{2010-07-15}
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"]
@@ -31,7 +31,7 @@ class GoogleDirections
31
31
  end
32
32
 
33
33
  def drive_time_in_minutes
34
- if @status == "NOT_FOUND"
34
+ if @status == "NOT_FOUND" or @status == "OVER_QUERY_LIMIT"
35
35
  drive_time = 0
36
36
  else
37
37
  doc = Nokogiri::XML(@xml)
@@ -41,7 +41,7 @@ class GoogleDirections
41
41
  end
42
42
 
43
43
  def distance_in_miles
44
- if @status == "NOT_FOUND"
44
+ if @status == "NOT_FOUND" or @status == "OVER_QUERY_LIMIT"
45
45
  distance_in_miles = 0
46
46
  else
47
47
  doc = Nokogiri::XML(@xml)
data/test/test_helper.rb CHANGED
@@ -6,5 +6,5 @@ require 'ruby-debug'
6
6
  $:.unshift File.expand_path('../lib', __FILE__)
7
7
  require 'google_directions'
8
8
 
9
- GOOGLE_MAPS_API_KEY = "ABQIAAAAj_VbPHmedky6mQd2p37p9xQbL-Ke6g7EfeqhfwcS7ZnhWLsBVxQA3yWKTKM9MVa31hYIhxsKffu7Pw"
9
+ GOOGLE_MAPS_API_KEY = "afakeapithatworksanyway"
10
10
 
@@ -10,7 +10,7 @@ class GoogleDirectionsTest < Test::Unit::TestCase
10
10
  directions = GoogleDirections.new("121 Gordonsville Highway, 37030", "499 Gordonsville Highway, 38563")
11
11
  assert_equal(4, directions.distance_in_miles)
12
12
  assert_equal(6, directions.drive_time_in_minutes)
13
- assert_equal("http://maps.google.com/maps/api/directions/xml?key=ABQIAAAAj_VbPHmedky6mQd2p37p9xQbL-Ke6g7EfeqhfwcS7ZnhWLsBVxQA3yWKTKM9MVa31hYIhxsKffu7Pw&sensor=false&origin=121+Gordonsville+Highway,+37030&destination=499+Gordonsville+Highway,+38563", directions.xml_call)
13
+ assert_equal("http://maps.google.com/maps/api/directions/xml?key=afakeapithatworksanyway&sensor=false&origin=121+Gordonsville+Highway,+37030&destination=499+Gordonsville+Highway,+38563", directions.xml_call)
14
14
  assert_not_nil(directions.xml =~ /36\.1773300/)
15
15
  end
16
16
 
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: 25
4
+ hash: 31
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 1
10
- version: 0.1.1
9
+ - 2
10
+ version: 0.1.2
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-14 00:00:00 -05:00
18
+ date: 2010-07-15 00:00:00 -05:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency