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
# Array of valid Lookup names.
#
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
def version
......@@ -97,9 +111,9 @@ module Geocoder
#
def lookup(ip = false)
if ip
get_lookup :freegeoip
get_lookup(ip_lookups.first)
else
get_lookup Configuration.lookup || :google
get_lookup(Configuration.lookup || street_lookups.first)
end
end
......
......@@ -22,13 +22,12 @@ module Geocoder
Geocoder::Configuration.language = language
end
lookups = Geocoder.valid_lookups - [:freegeoip]
opts.on("-s <service>", lookups, "--service <service>",
"Geocoding service: #{lookups.join(', ')}") do |service|
opts.on("-s <service>", Geocoder.street_lookups, "--service <service>",
"Geocoding service: #{Geocoder.street_lookups * ', '}") do |service|
Geocoder::Configuration.lookup = service.to_sym
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|
Geocoder::Configuration.timeout = timeout.to_i
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