Giter Site home page Giter Site logo

ip2location / ip2location-ruby Goto Github PK

View Code? Open in Web Editor NEW
24.0 5.0 6.0 6.95 MB

This is IP2Location Ruby library that enables the user to find the country, region, district, city, coordinates, zip code, time zone, ISP, domain name, connection type, area code, weather, MCC, MNC, mobile brand name, elevation, usage type, address type, IAB category and ASN that any IP address or hostname originates from.

Home Page: http://www.ip2location.com

License: MIT License

Ruby 100.00%
ip2location ip2location-ruby geolocation ip-geolocation ip-lookup ip-database geolocation-database ip-address

ip2location-ruby's Introduction

Latest Stable Version Total Downloads

IP2Location Ruby Library

This is IP2Location Ruby library that enables the user to find the country, region or state, district, city, latitude and longitude, ZIP/Postal code, time zone, Internet Service Provider (ISP) or company name, domain name, net speed, area code, weather station code, weather station name, mobile country code (MCC), mobile network code (MNC) and carrier brand, elevation, usage type, address type, IAB category and ASN from IP address using IP2Location database. The library reads the geo location information from IP2Location BIN data file or web service.

Supported IPv4 and IPv6 address.

For more details, please visit: https://www.ip2location.com/developers/ruby

Developer Documentation

To learn more about installation, usage, and code examples, please visit the developer documentation at https://ip2location-ruby.readthedocs.io/en/latest/index.html.

Dependencies

This library requires IP2Location BIN data file to function. You may download the BIN data file at

You can also sign up for IP2Location Web Service to lookup by IP2Location API.

IPv4 BIN vs IPv6 BIN

  • Use the IPv4 BIN file if you just need to query IPv4 addresses.
  • Use the IPv6 BIN file if you need to query BOTH IPv4 and IPv6 addresses.

Support

Email: [email protected]
URL: https://www.ip2location.com

ip2location-ruby's People

Contributors

alexreisner avatar ip2location avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

ip2location-ruby's Issues

File path

It's not obvious that the data should be placed in the rb folder, please mention this in the README.
without knowing it, you also run into an incomprehensible error

i2l = Ip2location.new.open("IP-COUNTRY-SAMPLE.BIN")
=> Ip2location.new.open() error in opening IP-COUNTRY-SAMPLE.BIN.

the full path should be displayed for clarity of the error
Errno::ENOENT: No such file or directory @ rb_sysopen - /your/path/rb/IP-COUNTRY-SAMPLE.BIN

or just leave clean input path

self.file = File.open(File.expand_path url)

self.file = File.open(File.expand_path url, 'rb')

NoMethodError: undefined method `tell' for nil

Hello, after update rails(Rails 7.1.3.2) and ruby 3.3.0
when I write command Ip2location.new.open(Rails.root.join("db/IP2LOCATION-LITE-DB1.BIN")).get_all('8.8.8.8')
get_country_short and e.t.c
return next error
NoMethodError: undefined method tell' for nil from /home/niktexnik/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/ip2location_ruby-8.0.3/lib/ip2location_ruby/i2l_string_data.rb:8:in read_and_return_value'

Ip2location.new.open('IP2LOCATION-LITE-DB1.BIN') expand_path weirdness

On line 14 of lib/ip2location_ruby.rb 'rb' is inserted into the path of the given "url".

 def open(url)
    self.file = File.open(File.expand_path url, 'rb')
    i2l = Ip2locationConfig.read(file)

This forces the database to be in the rb subdirectory of the directory in which the database file exists if I use a relative pathname,

File.expand_path('IP2LOCATION-LITE-DB1.BIN', 'rb')
=> "/home/tmp/foo/ip2location/rb/IP2LOCATION-LITE-DB1.BIN"

Is there some reason this is being done? Because it means I have to store the database file in a subdirectory called 'rb' even if I attempt to open "./IP2LOCATION-LITE-DB1.BIN"

irb(main):028:0> Dir.chdir("/home/tmp/foo/ip2location") {
irb(main):029:1* File.expand_path './IP2LOCATION-LITE-DB1.BIN', 'rb'
irb(main):030:1> }
=> "/home/tmp/foo/ip2location/rb/IP2LOCATION-LITE-DB1.BIN"

The dir_string 'rb' is only inserted into the path for certain relative file paths, if I use a full filespec to point to the file expand_path does not insert the 'rb' directory into the output,

irb(main):013:0> File.expand_path('/home/tmp/foo/ip2location/IP2LOCATION-LITE-DB1.BIN', 'rb')
=> "/home/tmp/foo/ip2location/IP2LOCATION-LITE-DB1.BIN"

This is on,

$ ruby --version
ruby 2.4.2p198 (2017-09-14 revision 59899) [x86_64-linux]

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.