From 8af00bdb234e08ec894800040a89b2a190cd478f Mon Sep 17 00:00:00 2001
From: Alex Reisner <alex@alexreisner.com>
Date: Mon, 1 Oct 2012 10:35:56 -0400
Subject: [PATCH] Update Yahoo lookup to reflect API changes.

"Results" key is now "Result" and is not an array when only one result.
---
 lib/geocoder/lookups/yahoo.rb                  | 2 +-
 test/fixtures/yahoo_garbage.json               | 2 +-
 test/fixtures/yahoo_madison_square_garden.json | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/geocoder/lookups/yahoo.rb b/lib/geocoder/lookups/yahoo.rb
index 9282f2e9..dcd7a279 100644
--- a/lib/geocoder/lookups/yahoo.rb
+++ b/lib/geocoder/lookups/yahoo.rb
@@ -13,7 +13,7 @@ module Geocoder::Lookup
     def results(query)
       return [] unless doc = fetch_data(query)
       if doc = doc['ResultSet'] and doc['Error'] == 0
-        return doc['Found'] > 0 ? doc['Results'] : []
+        return doc['Found'] > 0 ? Array(doc['Result']) : []
       else
         warn "Yahoo Geocoding API error: #{doc['Error']} (#{doc['ErrorMessage']})."
         return []
diff --git a/test/fixtures/yahoo_garbage.json b/test/fixtures/yahoo_garbage.json
index 8e8970fd..11e551c9 100644
--- a/test/fixtures/yahoo_garbage.json
+++ b/test/fixtures/yahoo_garbage.json
@@ -6,7 +6,7 @@
     "Locale":"us_US",
     "Quality":87,
     "Found":1,
-    "Results":[{
+    "Result":[{
       "quality":9,
       "latitude":"55.008390",
       "longitude":"-5.822485",
diff --git a/test/fixtures/yahoo_madison_square_garden.json b/test/fixtures/yahoo_madison_square_garden.json
index 6e54b8e7..4befd7cf 100644
--- a/test/fixtures/yahoo_madison_square_garden.json
+++ b/test/fixtures/yahoo_madison_square_garden.json
@@ -6,7 +6,7 @@
     "Locale":"us_US",
     "Quality":90,
     "Found":1,
-    "Results":[{
+    "Result":[{
       "quality":90,
       "latitude":"40.750381",
       "longitude":"-73.993988",
-- 
GitLab