0.0
No commit activity in last 3 years
No release in over 3 years
TODO
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies
 Project Readme

focus¶ ↑

A simple interface to the www.hostip.info API.

HostIP.info¶ ↑

hostip.info is a “Community Geotarget IP Project” and provides a simple API to transform an “IP Address” into a location (including Country, City, and coordinates).

No API key or sign-up is required to use the service.

hostip.info does request that if a lot of databases lookups are being done that you download the entire database from them instead.

dependencies¶ ↑

example¶ ↑

from the command line¶ ↑

# focus 209.85.171.100

from a ruby script¶ ↑

require 'rubygems'
require 'focus'

focus = Focus.new("209.85.171.100")

puts focus.location.coordinates

from a rails application¶ ↑

in config/environment¶ ↑

require 'focus'

in your controller¶ ↑

@focus = Focus.new("209.85.171.100")

in your view¶ ↑

@focus.location.coordinates

from a rails application with caching¶ ↑

Using caching is highly advised if possible. The ip_address to location conversion doesn’t normally change over time (if ever) so why continuously query it?

Assumption: caching is already enabled and working.

in config/environment¶ ↑

require 'focus'

in your controller¶ ↑

ip_address = "209.85.171.100"
@focus = Rails.cache.fetch(Spotlight.key(ip_address), :expires_in => 1.weeks) do
  Focus.new(ip_address)
end

in your view¶ ↑

@focus.location.coordinates

credits¶ ↑

Other then the code written by [me](github.com/attack) and the code created by [‘jeweler’](github.com/technicalpickles/jeweler/tree/master) for making and maintaining gems, there is strong influence from [jnunemaker](github.com/jnunemaker) and the gem google-weather.

Copyright © 2009 Mark G. See LICENSE for details.