lib/geocoder/cli.rb in geocoder-1.1.3 vs lib/geocoder/cli.rb in geocoder-1.1.4

- old
+ new

@@ -30,13 +30,14 @@ opts.on("-p <proxy>", "--proxy <proxy>", "HTTP proxy server to use (user:pass@host:port)") do |proxy| Geocoder::Configuration.http_proxy = proxy end - opts.on("-s <service>", Geocoder.street_lookups, "--service <service>", - "Geocoding service: #{Geocoder.street_lookups * ', '}") do |service| + opts.on("-s <service>", Geocoder::Lookup.all_services_except_test, "--service <service>", + "Geocoding service: #{Geocoder::Lookup.all_services_except_test * ', '}") do |service| Geocoder::Configuration.lookup = service.to_sym + Geocoder::Configuration.ip_lookup = service.to_sym end opts.on("-t <seconds>", "--timeout <seconds>", "Maximum number of seconds to wait for API response") do |timeout| Geocoder::Configuration.timeout = timeout.to_i @@ -76,33 +77,31 @@ out << "You can only specify one of -j and -u.\n" exit 2 end if show_url - lookup = Geocoder.send(:lookup, query) - reverse = lookup.send(:coordinates?, query) - out << lookup.send(:query_url, query, reverse) + "\n" + q = Geocoder::Query.new(query) + out << q.lookup.send(:query_url, q) + "\n" exit 0 end if show_json - lookup = Geocoder.send(:lookup, query) - reverse = lookup.send(:coordinates?, query) - out << lookup.send(:fetch_raw_data, query, reverse) + "\n" + q = Geocoder::Query.new(query) + out << q.lookup.send(:fetch_raw_data, q) + "\n" exit 0 end if (result = Geocoder.search(query).first) - lookup = Geocoder.send(:get_lookup, :google) + google = Geocoder::Lookup.get(:google) lines = [ ["Latitude", result.latitude], ["Longitude", result.longitude], ["Full address", result.address], ["City", result.city], ["State/province", result.state], ["Postal code", result.postal_code], ["Country", result.country], - ["Google map", lookup.map_link_url(result.coordinates)], + ["Google map", google.map_link_url(result.coordinates)], ] lines.each do |line| out << (line[0] + ": ").ljust(18) + line[1].to_s + "\n" end exit 0