Coder Social home page Coder Social logo

ipgeobase_mongoid's Introduction

IPGeoBase

Russia and Ukraine geoip lookup with DB from ipgeobase.ru for Mongoid 3/4

WARNING: 1.0 breaks backward compatibility. For mongoid 2 use ~> 0

Гем для работы с архивом с сайта ipgeobase.ru, содержащим базу местонахождений российских и украинских ip-адресов (с точностью до города) для MongoDB (Mongoid 3/4).

Installation

Add to Gemfile:

gem "rs_ipgeobase_mongoid"

Install required gems:

bundle install

Upload new database

  • Update cities and regions. Downloads file if it’s not present in tmp/cities.txt

    rake ipgeobase:cities
    
  • city id’s are not changed on DB update and can be used as foreign keys

  • Update geo ips. Downloads file if it’s not present in tmp/cidr_optim.txt

    rake ipgeobase:ips
    

Methods

Search for city by IP (Russia and Ukraine only):

После того, как выполнены все предыдущие шаги можно искать город по IP адресу.

Работает только для РФ и Украины. Если город не найден, метод вернет nil.

> geo = Ipgeobase::find_region_by_ip('95.170.177.170')
> pp geo
=> #<Ipgeobase::City _id: 5059d68ee779891c72000201, _type: nil, geo_id: 1428, city: "Красноярск",
    region: "Красноярский край", district: "Сибирский федеральный округ", lat: 56.001251, lon: 92.88559,
    country_id: BSON::ObjectId('5059d68de779891c72000001')>
> geo.city
=> "Красноярск"
> geo.region
=> "Красноярский край"
> geo.district
=> "Сибирский федеральный округ"
> geo.country.name
=> "Россия"
> geo.country.code
=> "RU"

ipgeobase_mongoid's People

Contributors

glebtv avatar vsevolod avatar romanbsd avatar shaggyone avatar

Watchers

James Cloos avatar Rumyantsev Artem avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.