Sha256: 53afe8c33a690e4c38f5ded9d2761a66b548fdc943f20a1c21ae6485724e275c
Contents?: true
Size: 604 Bytes
Versions: 14
Compression:
Stored size: 604 Bytes
Contents
#!/usr/bin/env ruby lib_dir = File.expand_path(File.join(File.dirname(__FILE__),'..','lib')) $LOAD_PATH << lib_dir unless $LOAD_PATH.include?(lib_dir) require 'geoip' data = '/usr/share/GeoIP/GeoIP.dat' data = ARGV.shift if ARGV[0] =~ /\.dat\Z/ geoip = GeoIP.new data req = ([GeoIP::GEOIP_CITY_EDITION_REV1, GeoIP::GEOIP_CITY_EDITION_REV0].include?(geoip.databaseType)) ? :city : :country if ARGV.size > 0 ARGV.each { |a| p geoip.send(req, a) } else while (STDIN.isatty && print('geoip> '); ip = gets) ip.chomp! result = geoip.send(req, ip) p result end STDIN.isatty && puts end
Version data entries
14 entries across 14 versions & 2 rubygems