Sha256: 10a785a25657bcc01e656de755488126d45fdd544199258a80ee147a996589ff

Contents?: true

Size: 1.82 KB

Versions: 5

Compression:

Stored size: 1.82 KB

Contents

= 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

- [HTTParty](http://github.com/jnunemaker/httparty/tree/master)
  [version used=0.3.1]
- fakeweb [version used=1.2.0] [NOTE: only needed to run tests]

= 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](http://github.com/attack) and the code
created by ['jeweler'](http://github.com/technicalpickles/jeweler/tree/master)
for making and maintaining gems, there is strong influence from
[jnunemaker](http://github.com/jnunemaker) and the gem google-weather.

== Copyright

Copyright (c) 2009 Mark G. See LICENSE for details.

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
attack-focus-0.1.0 README.rdoc
attack-focus-0.2.0 README.rdoc
focus-0.1.0 README.rdoc
focus-0.2.0 README.rdoc
focus-0.2.1 README.rdoc