December 9

Installing geoip-ruby on Leopard

Using GeoIP libraries in Ruby is easy….

curl -O http://geolite.maxmind.com/download/geoip/api/c/GeoIP-1.4.5.tar.gz
tar xvzf GeoIP-1.4.5.tar.gz
cd GeoIP-1.4.5/
./configure --prefix=/usr/local
make
sudo make install
sudo gem i geoip

curl -O http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
gunzip GeoLiteCity.dat.gz

Then you can just do something like this in your application:

require 'rubygems'
require 'geoip'

g = GeoIP.new(PATH_TO + "/GeoLiteCity.dat")
g.city("google.com")
=> ["google.com", "209.85.171.100", "US", "USA", "United States", "NA", "CA", "Mountain View", "94043", 37.4192, -122.0574, 807, 650]

Easy