Skip to content

kolesnikovde/sypex_geo

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
lib
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Gem Version Build Status Code Climate Test Coverage

SypexGeo

Sypex Geo IP database adapter for Ruby.

Installation

Add this line to your application's Gemfile:

gem 'sypex_geo'

And then execute:

$ bundle

Usage

require 'sypex_geo'

db = SypexGeo::Database.new('./SxGeoCity.dat')
location = db.query('<IPv4 address>')

location.city
# => {
#   id: 524901,
#   lat: 55.75222,
#   lon: 37.61556,
#   name_ru: 'Москва',
#   name_en: 'Moscow'
# }

location.region
# => {
#   id: 524894,
#   iso: 'RU-MOW',
#   name_ru: 'Москва',
#   name_en: 'Moskva'
# }

location.country
# => {
#   id: 185,
#   iso: 'RU',
#   lat: 60.0,
#   lon: 100.0,
#   name_ru: 'Россия',
#   name_en: 'Russia'
# }

location.country_code
# => 'RU'

Testing

$ wget http://sypexgeo.net/files/SxGeoCountry.zip && unzip SxGeoCountry.zip
$ wget http://sypexgeo.net/files/SxGeoCity_utf8.zip && unzip SxGeoCity_utf8.zip
$ SXGEO_DB=./SxGeo.dat SXGEO_CITY_DB=./SxGeoCity.dat rspec

License

MIT

About

Sypex Geo IP database adapter for Ruby.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages