C
Clifford Heath
GeoIP 1.0.0 has been released. This pure Ruby gem searches the various
geographic databases available from http://maxmind.com for an IP address.
(sudo) gem install geoip
GeoIP web locations:
http://geoip.rubyforge.org
http://github.com/cjheath/geoip
Changes:
This version still returns an array of values (as copied from the early
version by Sean Crittendon), but now it augments the results with to_hash
and with accessor methods, for more convenient and reliable access. This
change does not break the previous API, but I thought it a sufficient
sign of maturity (after six years!) that it deserved a 1.0.0 number.
Examples:
require ‘geoip’
c = GeoIP.new(‘GeoIP.dat’).country(‘www.nokia.com’)
=> [“www.nokia.com”, “147.243.3.83”, 69, “FI”, “FIN”, “Finland”, “EU”]
c.country_code3
=> “FIN”
c.to_hash
=> {:country_code3=>"FIN", :country_name=>"Finland", :continent_code=>"EU",
:request=>"www.nokia.com", :country_code=>69, :country_code2=>"FI", :ip=>"147.243.3.83"}
c = GeoIP.new(‘GeoLiteCity.dat’).city(‘github.com’)
=> [“github.com”, “207.97.227.239”, “US”, “USA”, “United States”, “NA”, “CA”,
“San Francisco”, “94110”, 37.7484, -122.4156, 807, 415, “America/Los_Angeles”]=> “America/Los_Angeles”
c = GeoIP.new(‘GeoIPASNum.dat’).asn(“www.fsb.ru”)
=> [“AS8342”, “RTComm.RU Autonomous System”]
Clifford Heath, Data Constellation, http://dataconstellation.com
Agile Information Management and Design.
geographic databases available from http://maxmind.com for an IP address.
(sudo) gem install geoip
GeoIP web locations:
http://geoip.rubyforge.org
http://github.com/cjheath/geoip
Changes:
This version still returns an array of values (as copied from the early
version by Sean Crittendon), but now it augments the results with to_hash
and with accessor methods, for more convenient and reliable access. This
change does not break the previous API, but I thought it a sufficient
sign of maturity (after six years!) that it deserved a 1.0.0 number.
Examples:
require ‘geoip’
c = GeoIP.new(‘GeoIP.dat’).country(‘www.nokia.com’)
=> [“www.nokia.com”, “147.243.3.83”, 69, “FI”, “FIN”, “Finland”, “EU”]
c.country_code3
=> “FIN”
c.to_hash
=> {:country_code3=>"FIN", :country_name=>"Finland", :continent_code=>"EU",
:request=>"www.nokia.com", :country_code=>69, :country_code2=>"FI", :ip=>"147.243.3.83"}
c = GeoIP.new(‘GeoLiteCity.dat’).city(‘github.com’)
=> [“github.com”, “207.97.227.239”, “US”, “USA”, “United States”, “NA”, “CA”,
“San Francisco”, “94110”, 37.7484, -122.4156, 807, 415, “America/Los_Angeles”]=> “America/Los_Angeles”
c = GeoIP.new(‘GeoIPASNum.dat’).asn(“www.fsb.ru”)
=> [“AS8342”, “RTComm.RU Autonomous System”]
Clifford Heath, Data Constellation, http://dataconstellation.com
Agile Information Management and Design.