diff --git a/README.md b/README.md index b41c95ff8e5debce9e2a220d1472599aea865b34..cc0e33b8f8b2825ca75d88af4ba3476ca3f9e43c 100644 --- a/README.md +++ b/README.md @@ -434,19 +434,6 @@ The [Google Places Details API](https://developers.google.com/places/documentati * **Terms of Service**: https://developers.google.com/places/policies * **Limitations**: "If your application displays Places API data on a page or view that does not also display a Google Map, you must show a "Powered by Google" logo with that data." -#### Yahoo BOSS (`:yahoo`) -**Warning - [this API will be discontinued on March 31.](https://developer.yahoo.com/boss/placefinder/)** - -* **API key**: requires OAuth consumer key and secret (set `Geocoder.configure(:api_key => [key, secret])`) -* **Key signup**: http://developer.yahoo.com/boss/geo/ -* **Quota**: unlimited, but subject to usage fees -* **Region**: world -* **SSL support**: no -* **Languages**: en, fr, de, it, es, pt, nl, zh, ja, ko -* **Documentation**: http://developer.yahoo.com/boss/geo/docs/index.html -* **Terms of Service**: http://info.yahoo.com/legal/us/yahoo/boss/tou/?pir=ucJPcJ1ibUn.h.d.lVmlcbcEkoHjwJ_PvxG9SLK9VIbIQAw1XFrnDqY- -* **Limitations**: No mass downloads, no commercial map production based on the data, no storage of data except for caching. - #### Bing (`:bing`) * **API key**: required (set `Geocoder.configure(:lookup => :bing, :api_key => key)`) diff --git a/lib/geocoder/configuration.rb b/lib/geocoder/configuration.rb index 9d224b53dcff6a01b55a480e89e5e4c8ccd5eacd..de897fc08dc4318d582f2119d3c8d0ecac760c7e 100644 --- a/lib/geocoder/configuration.rb +++ b/lib/geocoder/configuration.rb @@ -17,10 +17,6 @@ module Geocoder if !options.nil? Configuration.instance.configure(options) end - - if config.lookup == :yahoo - Geocoder.log(:warn, "Yahoo BOSS Placefinder API will be discontinued March 31, 2016.") - end end ## diff --git a/lib/geocoder/lookup.rb b/lib/geocoder/lookup.rb index c48960851bb4aa71656ea1102857c510cfc30ded..f96470b8c9bf8cddbba5facb040169325a593fc6 100644 --- a/lib/geocoder/lookup.rb +++ b/lib/geocoder/lookup.rb @@ -28,7 +28,6 @@ module Geocoder :google, :google_premier, :google_places_details, - :yahoo, :bing, :geocoder_ca, :geocoder_us, diff --git a/lib/geocoder/lookups/yahoo.rb b/lib/geocoder/lookups/yahoo.rb deleted file mode 100644 index bf9fbec71daddc7e49fd21e8b97174fb56f97143..0000000000000000000000000000000000000000 --- a/lib/geocoder/lookups/yahoo.rb +++ /dev/null @@ -1,89 +0,0 @@ -require 'geocoder/lookups/base' -require "geocoder/results/yahoo" -require 'oauth_util' - -module Geocoder::Lookup - class Yahoo < Base - - def name - "Yahoo BOSS" - end - - def map_link_url(coordinates) - "http://maps.yahoo.com/#lat=#{coordinates[0]}&lon=#{coordinates[1]}" - end - - def required_api_key_parts - ["consumer key", "consumer secret"] - end - - def query_url(query) - parsed_url = URI.parse(raw_url(query)) - o = OauthUtil.new - o.consumer_key = configuration.api_key[0] - o.consumer_secret = configuration.api_key[1] - base_url + o.sign(parsed_url).query_string - end - - private # --------------------------------------------------------------- - - def results(query) - Geocoder.log(:warn, "Yahoo BOSS Placefinder API will be discontinued March 31, 2016.") - return [] unless doc = fetch_data(query) - doc = doc['bossresponse'] - if doc['responsecode'].to_i == 200 - if doc['placefinder']['count'].to_i > 0 - return doc['placefinder']['results'] - else - return [] - end - else - Geocoder.log(:warn, "Yahoo Geocoding API error: #{doc['responsecode']} (#{doc['reason']}).") - return [] - end - end - - ## - # Yahoo returns errors as XML even when JSON format is specified. - # Handle that here, without parsing the XML - # (which would add unnecessary complexity). - # Yahoo auth errors can also be cryptic, so add raw error desc - # to warning message. - # - def parse_raw_data(raw_data) - if raw_data.match(/^<\?xml/) - if raw_data.include?("Rate Limit Exceeded") - raise_error(Geocoder::OverQueryLimitError) || Geocoder.log(:warn, "Over API query limit.") - elsif raw_data =~ /<yahoo:description>(Please provide valid credentials.*)<\/yahoo:description>/i - raise_error(Geocoder::InvalidApiKey) || Geocoder.log(:warn, "Invalid API key. Error response: #{$1}") - end - else - super(raw_data) - end - end - - def query_url_params(query) - lang = (query.language || configuration.language).to_s - lang += '_US' if lang == 'en' - { - :location => query.sanitized_text, - :flags => "JXTSR", - :gflags => "AC#{'R' if query.reverse_geocode?}", - :locale => lang, - :appid => configuration.api_key - }.merge(super) - end - - def cache_key(query) - raw_url(query) - end - - def base_url - "#{protocol}://yboss.yahooapis.com/geo/placefinder?" - end - - def raw_url(query) - base_url + url_query_string(query) - end - end -end diff --git a/lib/geocoder/results/yahoo.rb b/lib/geocoder/results/yahoo.rb deleted file mode 100644 index e5b7b5642e6435d0b6bc4ce6896a734d1e955f1e..0000000000000000000000000000000000000000 --- a/lib/geocoder/results/yahoo.rb +++ /dev/null @@ -1,60 +0,0 @@ -require 'geocoder/results/base' - -module Geocoder::Result - class Yahoo < Base - - def address(format = :full) - (1..4).to_a.map{ |i| @data["line#{i}"] }.reject{ |i| i.nil? or i == "" }.join(", ") - end - - def city - @data['city'] - end - - def state - @data['state'] - end - - def state_code - @data['statecode'] - end - - def country - @data['country'] - end - - def country_code - @data['countrycode'] - end - - def postal_code - @data['postal'] - end - - def address_hash - @data['hash'] - end - - def viewport - boundingbox = @data['boundingbox'] || fail - %w(south west north east).map{ |i| boundingbox[i].to_f } - end - - def self.response_attributes - %w[quality offsetlat offsetlon radius boundingbox name - line1 line2 line3 line4 cross house street xstreet unittype unit - city state statecode country countrycode postal - neighborhood county countycode - level0 level1 level2 level3 level4 level0code level1code level2code - timezone areacode uzip hash woeid woetype] - end - - response_attributes.each do |a| - unless method_defined?(a) - define_method a do - @data[a] - end - end - end - end -end diff --git a/test/fixtures/yahoo_error b/test/fixtures/yahoo_error deleted file mode 100644 index 7dbfdfeabeaa611d00af6ef756118795619703a1..0000000000000000000000000000000000000000 --- a/test/fixtures/yahoo_error +++ /dev/null @@ -1 +0,0 @@ -{"bossresponse":{"responsecode":"6000","reason":"internal error"}} diff --git a/test/fixtures/yahoo_invalid_key b/test/fixtures/yahoo_invalid_key deleted file mode 100644 index c9b7319b05361287a7829d884d051fb397f36e4d..0000000000000000000000000000000000000000 --- a/test/fixtures/yahoo_invalid_key +++ /dev/null @@ -1,2 +0,0 @@ -<?xml version='1.0' encoding='UTF-8'?>\n<yahoo:error xmlns:yahoo='http://yahooapis.com/v1/base.rng'\n xml:lang='en-US'> - <yahoo:description>Please provide valid credentials. OAuth oauth_problem="consumer_key_unknown", realm="yahooapis.com"</yahoo:description>\n</yahoo:error> diff --git a/test/fixtures/yahoo_madison_square_garden b/test/fixtures/yahoo_madison_square_garden deleted file mode 100644 index 24161f60b57f58f99c68ec9e99f648c89ee08097..0000000000000000000000000000000000000000 --- a/test/fixtures/yahoo_madison_square_garden +++ /dev/null @@ -1,52 +0,0 @@ -{ - "bossresponse": { - "responsecode": "200", - "placefinder": { - "start": "0", - "count": "1", - "request": "flags=JXTSR&location=Madison%20Square%20Garden%2C%20NY%2C%20NY&%unsafe%appid=%5B%22dj0yJmk9ZmZ5NXFrNGhNcEthJmQ9WVdrOVFUSlhPV2x1TjJVbWNHbzlORE0wT0RFME9UWXkmcz1jb25zdW1lcnNlY3JldCZ4PTAy%22%2C%20%22b57b1b98eb21f171231f5b441cba505261d6c9bb%22%5D&gflags=AC&locale=en_US", - "results": [ - { - "quality": "90", - "latitude": "40.750381", - "longitude": "-73.993988", - "offsetlat": "40.750381", - "offsetlon": "-73.993988", - "radius": "400", - "boundingbox": { - "north": "40.750832", - "south": "40.749931", - "east": "-73.993393", - "west": "-73.994591" - }, - "name": "Madison Square Garden", - "line1": "Madison Square Garden", - "line2": "New York, NY 10001", - "line3": "", - "line4": "United States", - "cross": "", - "house": "", - "street": "", - "xstreet": "", - "unittype": "", - "unit": "", - "postal": "10001", - "neighborhood": "Garment District|Midtown|Midtown West|Manhattan", - "city": "New York", - "county": "New York County", - "state": "New York", - "country": "United States", - "countrycode": "US", - "statecode": "NY", - "countycode": "", - "timezone": "America/New_York", - "areacode": "212", - "uzip": "10001", - "hash": "", - "woeid": "23617041", - "woetype": "20" - } - ] - } - } -} diff --git a/test/fixtures/yahoo_no_results b/test/fixtures/yahoo_no_results deleted file mode 100644 index 0c65fddc4a9dd4aa3791c7ec19ef75ba977837e8..0000000000000000000000000000000000000000 --- a/test/fixtures/yahoo_no_results +++ /dev/null @@ -1,10 +0,0 @@ -{ - "bossresponse": { - "responsecode": "200", - "placefinder": { - "start": "0", - "count": "0", - "request": "flags=JXTSR&location=asdfasdf28394782sdfj2983&%unsafe%appid=%5B%22dj0yJmk9ZmZ5NXFrNGhNcEthJmQ9WVdrOVFUSlhPV2x1TjJVbWNHbzlORE0wT0RFME9UWXkmcz1jb25zdW1lcnNlY3JldCZ4PTAy%22%2C%20%22b57b1b98eb21f171231f5b441cba505261d6c9bb%22%5D&gflags=AC&locale=en_US" - } - } -} diff --git a/test/fixtures/yahoo_over_limit b/test/fixtures/yahoo_over_limit deleted file mode 100644 index 7dddadf5f0d5e75bae7fd245d34dac41012e23aa..0000000000000000000000000000000000000000 --- a/test/fixtures/yahoo_over_limit +++ /dev/null @@ -1,2 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> <yahoo:error xmlns:yahoo="http://yahooapis.com/v1/base.rng\ <http://yahooapis.com/v1/base.rng%5C>" xml:lang="en-US"> - <yahoo:description>Rate Limit Exceeded</yahoo:description> <yahoo:detail>Key has exceeded its configured rate limit.</yahoo:detail> </yahoo:error> diff --git a/test/unit/lookup_test.rb b/test/unit/lookup_test.rb index 1fba832a3e2103eb42cee90f70e4c78736a6f440..84f5774e109d94fdfa57fb91d6b595b1c141cb38 100644 --- a/test/unit/lookup_test.rb +++ b/test/unit/lookup_test.rb @@ -29,7 +29,7 @@ class LookupTest < GeocoderTestCase url = Geocoder::Lookup.get(l).query_url(Geocoder::Query.new( "test", :params => {:one_in_the_hand => "two in the bush"} )) - # should be "+"s for all lookups except Yahoo + # should be "+"s for all lookups assert_match(/one_in_the_hand=two(%20|\+)in(%20|\+)the(%20|\+)bush/, url, "Lookup #{l} does not appear to support arbitrary params in URL") end @@ -44,7 +44,6 @@ class LookupTest < GeocoderTestCase :mapquest => :key, :maxmind => :l, :nominatim => :"accept-language", - :yahoo => :locale, :yandex => :plng }.each do |l,p| define_method "test_passing_param_to_#{l}_query_overrides_configuration_value" do @@ -61,7 +60,6 @@ class LookupTest < GeocoderTestCase :google => :language, :google_premier => :language, :nominatim => :"accept-language", - :yahoo => :locale, :yandex => :plng }.each do |l,p| define_method "test_passing_language_to_#{l}_query_overrides_configuration_value" do @@ -77,7 +75,7 @@ class LookupTest < GeocoderTestCase def test_raises_exception_on_invalid_key Geocoder.configure(:always_raise => [Geocoder::InvalidApiKey]) #Geocoder::Lookup.all_services_except_test.each do |l| - [:bing, :yahoo, :yandex, :maxmind, :baidu, :baidu_ip].each do |l| + [:bing, :yandex, :maxmind, :baidu, :baidu_ip].each do |l| lookup = Geocoder::Lookup.get(l) assert_raises Geocoder::InvalidApiKey do lookup.send(:results, Geocoder::Query.new("invalid key")) @@ -88,7 +86,7 @@ class LookupTest < GeocoderTestCase def test_returns_empty_array_on_invalid_key silence_warnings do #Geocoder::Lookup.all_services_except_test.each do |l| - [:bing, :yahoo, :yandex, :maxmind, :baidu, :baidu_ip].each do |l| + [:bing, :yandex, :maxmind, :baidu, :baidu_ip].each do |l| Geocoder.configure(:lookup => l) set_api_key!(l) assert_equal [], Geocoder.search("invalid key") diff --git a/test/unit/lookups/yahoo_test.rb b/test/unit/lookups/yahoo_test.rb deleted file mode 100644 index 3289bb4b25e3da0889760d0d06183cf1cafcec33..0000000000000000000000000000000000000000 --- a/test/unit/lookups/yahoo_test.rb +++ /dev/null @@ -1,40 +0,0 @@ -# encoding: utf-8 -require 'test_helper' - -class YahooTest < GeocoderTestCase - - def setup - Geocoder.configure(lookup: :yahoo) - set_api_key!(:yahoo) - end - - def test_no_results - assert_equal [], Geocoder.search("no results") - end - - def test_error - silence_warnings do - assert_equal [], Geocoder.search("error") - end - end - - def test_result_components - result = Geocoder.search("madison square garden").first - assert_equal "10001", result.postal_code - assert_equal "Madison Square Garden, New York, NY 10001, United States", result.address - end - - def test_result_viewport - result = Geocoder.search("Madison Square Garden, New York, NY").first - assert_equal [40.749931, -73.994591, 40.750832, -73.993393], - result.viewport - end - - def test_raises_exception_when_over_query_limit - Geocoder.configure(:always_raise => [Geocoder::OverQueryLimitError]) - l = Geocoder::Lookup.get(:yahoo) - assert_raises Geocoder::OverQueryLimitError do - l.send(:results, Geocoder::Query.new("over limit")) - end - end -end