Skip to content

Commit

Permalink
Merge pull request #1471 from ankane/maxmind_local_country
Browse files Browse the repository at this point in the history
Adds support for country file lookup to MaxMind Local
  • Loading branch information
alexreisner authored Dec 1, 2020
2 parents c804871 + 1bac82c commit 920ab3b
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/geocoder/lookups/maxmind_local.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,13 @@ def required_api_key_parts
def results(query)
if configuration[:file]
geoip_class = RUBY_PLATFORM == "java" ? JGeoIP : GeoIP
result = geoip_class.new(configuration[:file]).city(query.to_s)
geoip_instance = geoip_class.new(configuration[:file])
result =
if configuration[:package] == :country
geoip_instance.country(query.to_s)
else
geoip_instance.city(query.to_s)
end
result.nil? ? [] : [encode_hash(result.to_hash)]
elsif configuration[:package] == :city
addr = IPAddr.new(query.text).to_i
Expand Down

0 comments on commit 920ab3b

Please sign in to comment.