diff --git a/lib/geocoder/configuration.rb b/lib/geocoder/configuration.rb index 5c83adf8c6c6c27b02457617166acdfff279fe2a..54fceacf4493fe1b802df34ee4005f1e6b071a37 100644 --- a/lib/geocoder/configuration.rb +++ b/lib/geocoder/configuration.rb @@ -22,14 +22,9 @@ module Geocoder [:https_proxy, nil], # API key for geocoding service + # for Google Premier use a 3-element array: [key, client, channel] [:api_key, nil], - # API client for geocoding service - [:api_client, nil], - - # API channel for geocoding service - [:api_channel, nil], - # cache object (must respond to #[], #[]=, and #keys) [:cache, nil], diff --git a/lib/geocoder/lookups/google_premier.rb b/lib/geocoder/lookups/google_premier.rb index 31a033e700c0695f1d8e33a2e811198716078159..6befdddf585167868fcdbb58a042f0ea8175ea6d 100644 --- a/lib/geocoder/lookups/google_premier.rb +++ b/lib/geocoder/lookups/google_premier.rb @@ -13,15 +13,15 @@ module Geocoder::Lookup (reverse ? :latlng : :address) => query, :sensor => 'false', :language => Geocoder::Configuration.language, - :client => Geocoder::Configuration.api_client, - :channel => Geocoder::Configuration.api_channel + :client => Geocoder::Configuration.api_key[1], + :channel => Geocoder::Configuration.api_key[2] }.reject{ |key, value| value.nil? } path = "/maps/api/geocode/json?#{hash_to_query(params)}" "#{protocol}://maps.googleapis.com#{path}&signature=#{sign(path)}" end def sign(string) - raw_private_key = url_safe_base64_decode(Geocoder::Configuration.api_key) + raw_private_key = url_safe_base64_decode(Geocoder::Configuration.api_key[0]) digest = OpenSSL::Digest::Digest.new('sha1') raw_signature = OpenSSL::HMAC.digest(digest, raw_private_key, string) url_safe_base64_encode(raw_signature) diff --git a/test/services_test.rb b/test/services_test.rb index d1a8218f78496b226e6802914d1c609ccefce637..da81f7c9b9965408ccef30de2f9ce3cd799eca05 100644 --- a/test/services_test.rb +++ b/test/services_test.rb @@ -43,9 +43,7 @@ class ServicesTest < Test::Unit::TestCase end def test_google_premier_query_url - Geocoder::Configuration.api_key = "deadbeef" - Geocoder::Configuration.api_client = "gme-test" - Geocoder::Configuration.api_channel = "test-dev" + Geocoder::Configuration.api_key = ["deadbeef", "gme-test", "test-dev"] assert_equal "http://maps.googleapis.com/maps/api/geocode/json?address=Madison+Square+Garden%2C+New+York%2C+NY&channel=test-dev&client=gme-test&language=en&sensor=false&signature=doJvJqX7YJzgV9rJ0DnVkTGZqTg=", Geocoder::Lookup::GooglePremier.new.send(:query_url, "Madison Square Garden, New York, NY", false) end