Skip to content
Snippets Groups Projects
Commit 46d1cb81 authored by Alex Reisner's avatar Alex Reisner
Browse files

Deprecate yahoo_app_id in favor of api_key.

Now that we also support an API key for Google it makes sense for this to
be generic.
parent 76c8b13d
Branches
Tags
No related merge requests found
......@@ -15,11 +15,8 @@ module Geocoder
# use HTTPS for lookup requests? (if supported)
[:use_https, false],
# app id (if using Yahoo geocoding service)
[:yahoo_appid, nil],
# API key (if using Google geocoding service)
[:google_api_key, nil],
# API key for geocoding service
[:api_key, nil],
# cache object (must respond to #[], #[]=, and #keys)
[:cache, nil],
......@@ -35,6 +32,13 @@ module Geocoder
eval("def self.#{o}=(obj); @@#{o} = obj; end")
end
# legacy support
def self.yahoo_app_id=(value)
warn "DEPRECATION WARNING: Geocoder's 'yahoo_app_id' setting has been replaced by 'api_key'. " +
"This method will be removed in Geocoder v1.0."
@@api_key = value
end
##
# Set all values to default.
#
......
......@@ -24,7 +24,7 @@ module Geocoder::Lookup
(reverse ? :latlng : :address) => query,
:sensor => "false",
:language => Geocoder::Configuration.language,
:key => Geocoder::Configuration.google_api_key
:key => Geocoder::Configuration.api_key
}
"#{protocol}://maps.google.com/maps/api/geocode/json?" + hash_to_query(params)
end
......
......@@ -21,7 +21,7 @@ module Geocoder::Lookup
:flags => "JXTSR",
:gflags => "AC#{'R' if reverse}",
:locale => "#{Geocoder::Configuration.language}_US",
:appid => Geocoder::Configuration.yahoo_appid
:appid => Geocoder::Configuration.api_key
}
"http://where.yahooapis.com/geocode?" + hash_to_query(params)
end
......
......@@ -232,11 +232,17 @@ class GeocoderTest < Test::Unit::TestCase
end
def test_google_api_key
Geocoder::Configuration.google_api_key = "MY_KEY"
Geocoder::Configuration.api_key = "MY_KEY"
g = Geocoder::Lookup::Google.new
assert_match "key=MY_KEY", g.send(:query_url, "Madison Square Garden, New York, NY 10001, United States")
end
def test_yahoo_app_id
Geocoder::Configuration.api_key = "MY_KEY"
g = Geocoder::Lookup::Yahoo.new
assert_match "appid=MY_KEY", g.send(:query_url, "Madison Square Garden, New York, NY 10001, United States")
end
private # ------------------------------------------------------------------
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment