what maxmind geoip ruby wrapper is up2date and usable? ( for the commercial library )
-
09-12-2019 - |
Question
Im trying to get below github repo in my app
https://github.com/mtodd/geoip
Ive tried adding it like
gem "geoip", :git => "git://github.com/mtodd/geoip.git"
Error =
Could not find gem 'geoip (>= 0) ruby' in git://github.com/mtodd/geoip.git (at master).
Source does not contain any versions of 'geoip (>= 0) ruby'
Is there are ruby gem wrapper for GeoIP that is compatible with the LATEST GEOIP? Ive searched very long for one, the one above seems to be sort off compatible with 1.4.7 and higher but I can't get it installed, any other suggestion? Thx !
Solution
I have this in my Gemfile:
gem "geoip-c", '~> 0.7.1', :git => "git://github.com/mtodd/geoip.git"
As far as I know, it's totally compatible.
OTHER TIPS
I know this was posted a few years ago, but I recently had trouble finding a good up-to-date gem for this. What I found was Geoip2 by YotpoLtd.
In my Gemfile
gem 'geoip2'
Setting/Configuring
Geoip2.configure do |conf|
# Mandatory
conf.license_key = 'Your MaxMind License Key'
conf.user_id = 'Your MaxMind User Id'
# Optional
conf.host = 'geoip.maxmind.com' # Or any host that you would like to work with
conf.base_path = '/geoip/v2.0' # Or any other version of this API
conf.parallel_requests = 5 # Or any other amount of parallel requests that you would like to use
end
Using
data = Geoip2.omni('0.0.0.0') #this call is synchronous
*note: I believe you can replace 'omni' with the name of the product tier: city, country, etc
Errors If there is an error, the returned hash will have an error object, so simply check for its existence
if data.error
# error handling
else #still might want to check for data's existence ( if data )
#access object as you will
data.city.names.en
data.postal.code
end
For more information about the returned hash, see the MaxMind Web Services Documentation