From be6137599110a563ece565bd549725e6b91058bd Mon Sep 17 00:00:00 2001
From: andrea longhi <andrea@spaghetticode.it>
Date: Thu, 6 Dec 2012 20:32:43 +0100
Subject: [PATCH] add route info for google result

---
 lib/geocoder/results/google.rb | 6 ++++++
 test/services_test.rb          | 6 ++++++
 2 files changed, 12 insertions(+)

diff --git a/lib/geocoder/results/google.rb b/lib/geocoder/results/google.rb
index 73e2289d..e293c0ba 100644
--- a/lib/geocoder/results/google.rb
+++ b/lib/geocoder/results/google.rb
@@ -53,6 +53,12 @@ module Geocoder::Result
       end
     end
 
+    def route
+      if route = address_components_of_type(:route).first
+        route['long_name']
+      end
+    end
+
     def types
       @data['types']
     end
diff --git a/test/services_test.rb b/test/services_test.rb
index 540f71c3..0000b57b 100644
--- a/test/services_test.rb
+++ b/test/services_test.rb
@@ -25,6 +25,12 @@ class ServicesTest < Test::Unit::TestCase
       result.address_components_of_type(:sublocality).first['long_name']
   end
 
+  def test_google_result_components_contains_route
+    result = Geocoder.search("Madison Square Garden, New York, NY").first
+    assert_equal "Penn Plaza",
+      result.address_components_of_type(:route).first['long_name']
+  end
+
   def test_google_returns_city_when_no_locality_in_result
     result = Geocoder.search("no locality").first
     assert_equal "Haram", result.city
-- 
GitLab