diff --git a/Gemfile b/Gemfile index 92d5cdde41258c4c19d46621508c80cf37745ef7..b9c7deb261e5d69bd680b57b0c7be3b049a89319 100644 --- a/Gemfile +++ b/Gemfile @@ -14,6 +14,7 @@ group :development, :test do platforms :jruby do gem 'jruby-openssl' + gem 'jgeoip' end platforms :rbx do diff --git a/lib/geocoder/lookups/maxmind_local.rb b/lib/geocoder/lookups/maxmind_local.rb index 1045b748f88c04816888965e5e7583eedd7a0ea0..465c3614e5e11aa1b8e1245689fc72bd1b2be73e 100644 --- a/lib/geocoder/lookups/maxmind_local.rb +++ b/lib/geocoder/lookups/maxmind_local.rb @@ -6,11 +6,10 @@ module Geocoder::Lookup def initialize begin - require 'geoip' + require (RUBY_PLATFORM == 'java' ? 'jgeoip' : 'geoip') rescue LoadError => e raise 'Could not load geoip dependency. To use MaxMind Local lookup you must add geoip gem to your Gemfile or have it installed in your system.' end - super end @@ -32,9 +31,7 @@ module Geocoder::Lookup "Geocoder.configure(:maxmind_local => {:database => ...}), " ) end - - result = GeoIP.new(configuration[:database]).city(query.to_s) - + result = (RUBY_PLATFORM == "java" ? JGeoIP.new(configuration[:database]).city(query.to_s) : GeoIP.new(configuration[:database]).city(query.to_s)) result.nil? ? [] : [result.to_hash] end end