Skip to content
This repository was archived by the owner on May 16, 2024. It is now read-only.

kolesnikovde/sypex_geo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 3

  •  
  •  
  •  

Languages