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

List street and ip lookups separately.

parent 2ab17e6d
No related branches found
No related tags found
No related merge requests found
...@@ -76,7 +76,21 @@ module Geocoder ...@@ -76,7 +76,21 @@ module Geocoder
# Array of valid Lookup names. # Array of valid Lookup names.
# #
def valid_lookups def valid_lookups
[:google, :yahoo, :geocoder_ca, :yandex, :freegeoip] street_lookups + ip_lookups
end
##
# All street address lookups, default first.
#
def street_lookups
[:google, :yahoo, :geocoder_ca, :yandex]
end
##
# All IP address lookups, default first.
#
def ip_lookups
[:freegeoip]
end end
def version def version
...@@ -97,9 +111,9 @@ module Geocoder ...@@ -97,9 +111,9 @@ module Geocoder
# #
def lookup(ip = false) def lookup(ip = false)
if ip if ip
get_lookup :freegeoip get_lookup(ip_lookups.first)
else else
get_lookup Configuration.lookup || :google get_lookup(Configuration.lookup || street_lookups.first)
end end
end end
......
...@@ -22,13 +22,12 @@ module Geocoder ...@@ -22,13 +22,12 @@ module Geocoder
Geocoder::Configuration.language = language Geocoder::Configuration.language = language
end end
lookups = Geocoder.valid_lookups - [:freegeoip] opts.on("-s <service>", Geocoder.street_lookups, "--service <service>",
opts.on("-s <service>", lookups, "--service <service>", "Geocoding service: #{Geocoder.street_lookups * ', '}") do |service|
"Geocoding service: #{lookups.join(', ')}") do |service|
Geocoder::Configuration.lookup = service.to_sym Geocoder::Configuration.lookup = service.to_sym
end end
opts.on("-t <seconds>", lookups, "--timeout <seconds>", opts.on("-t <seconds>", "--timeout <seconds>",
"Maximum number of seconds to wait for API response") do |timeout| "Maximum number of seconds to wait for API response") do |timeout|
Geocoder::Configuration.timeout = timeout.to_i Geocoder::Configuration.timeout = timeout.to_i
end end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment