diff --git a/lib/geocoder/lookups/maxmind_local.rb b/lib/geocoder/lookups/maxmind_local.rb index 1045b748f88c04816888965e5e7583eedd7a0ea0..09aad2278a70d9a890a7f2072022304b74644621 100644 --- a/lib/geocoder/lookups/maxmind_local.rb +++ b/lib/geocoder/lookups/maxmind_local.rb @@ -5,12 +5,19 @@ module Geocoder::Lookup class MaxmindLocal < Base def initialize - begin - require '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.' + if RUBY_PLATFORM == "java" + begin + require 'jgeoip' + 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 + else + begin + require '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 end - super end @@ -32,8 +39,11 @@ module Geocoder::Lookup "Geocoder.configure(:maxmind_local => {:database => ...}), " ) end - - result = GeoIP.new(configuration[:database]).city(query.to_s) + if RUBY_PLATFORM == "java" + result = JGeoIP.new(configuration[:database]).city(query.to_s) + else + result = GeoIP.new(configuration[:database]).city(query.to_s) + end result.nil? ? [] : [result.to_hash] end