Skip to content

thoughtpunch/geolocater

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Geolocater

Yet Another IP Geolocation Gem for Fun and Profit!

Installation

gem install geolocater

Usage

Pass any properly formatted IPv4 address string to a new instance of Geolocater like so.

Geolocater.geolocate_ip(IP_ADDRESS_STRING)

and get back a JSON Hash of the results

=> {"city"=>"CITY", "region_code"=>"ST", "region_name"=>"Region Name", "metrocode"=>"999", "zipcode"=>"98765", "longitude"=>"-92.23", "country_name"=>"United States", "country_code"=>"US", "ip"=>"IP_ADDRESS", "latitude"=>"27.54"}

Details

  • This library uses the free (and very good) freegeoip.net REST API.
  • Results are returned in JSON format. For friendlier Ruby object-like results (and better nil handling), pipe the result hash into a new Hashie::Mash like so:

Hashie::Mash.new(Geolocater.ip_lookup(IP_ADDRESS_STRING))

Future Features

  • Add multiple geolocation services in the event the freegeoip service goes down

How You Can Help

  • Suggest additional tests/refactoring
  • Submit a pull request

Thanks!

About

Yet Another Geolocation Library

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published