lib/geocoder/lookups/geocoder_us.rb in geocoder-1.4.9 vs lib/geocoder/lookups/geocoder_us.rb in geocoder-1.5.0
- old
+ new
@@ -6,22 +6,30 @@
def name
"Geocoder.us"
end
- def supported_protocols
- [:http]
- end
+ def supported_protocols
+ [:http]
+ end
- def query_url(query)
+ private # ----------------------------------------------------------------
+
+ def base_query_url(query)
+ base_query_url_with_optional_key(configuration.api_key)
+ end
+
+ def cache_key(query)
+ base_query_url_with_optional_key(nil) + url_query_string(query)
+ end
+
+ def base_query_url_with_optional_key(key = nil)
+ base = "#{protocol}://"
if configuration.api_key
- "#{protocol}://#{configuration.api_key}@geocoder.us/member/service/csv/geocode?" + url_query_string(query)
- else
- "#{protocol}://geocoder.us/service/csv/geocode?" + url_query_string(query)
+ base << "#{configuration.api_key}@"
end
+ base + "geocoder.us/member/service/csv/geocode?"
end
-
- private
def results(query)
return [] unless doc = fetch_data(query)
if doc[0].to_s =~ /^(\d+)\:/
return []