Sha256: bc07ba5a9d42dc75cb451c5fde93ba6c3129a0a7c039fb2da10495d8a1a345e3

Contents?: true

Size: 1.87 KB

Versions: 1

Compression:

Stored size: 1.87 KB

Contents

= spotlight

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 (url=http://github.com/jnunemaker/httparty/tree/master)
  [version used=0.3.1]

== TESTING environment only

- fakeweb [version used=1.2.0]

= example

== from the command line

 # spotlight 209.85.171.100

== from a ruby script

 require 'rubygems'
 require 'spotlight'
 
 spotlight = Spotlight.new("209.85.171.100")
 
 puts spotlight.location.coordinates

== from a rails application

=== in config/environment
 
 require 'spotlight'
 
=== in your controller
 
 @spotlight = Spotlight.new("209.85.171.100")
 
=== in your view

 @spotlight.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 'spotlight'
 
=== in your controller
 
 ip_address = "209.85.171.100"
 @spotlight = Rails.cache.fetch(Spotlight.key(ip_address), :expires_in => 1.weeks) do
   Spotlight.new(ip_address)
 end
 
=== in your view

 @spotlight.location.coordinates

= credits

Other then the code written by me (url=http://github.com/attack) and the code
generated by 'jeweler' (url=http://github.com/jnunemaker) for making  and 
maintaining gems, there is strong influence from jnunemaker
(url=http://github.com/jnunemaker) and the gem google-weather.

== Copyright

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
attack-spotlight-0.1.0 README.rdoc