Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
## Project Overview

**GeoIP2-ruby** is MaxMind's official Ruby client library for:
- **GeoIP2/GeoLite2 Web Services**: Country, City, and Insights endpoints
- **GeoIP2/GeoLite2 Databases**: Local MMDB file reading for various database types (City, Country, ASN, Anonymous IP, Anonymous Plus, ISP, etc.)
- **GeoIP/GeoLite Web Services**: Country, City Plus, and Insights endpoints
- **GeoIP/GeoLite Databases**: Local MMDB file reading for various database types (City, Country, ASN, Anonymous IP, Anonymous Plus, ISP, etc.)

The library provides both web service clients and database readers that return strongly-typed model objects containing geographic, ISP, anonymizer, and other IP-related data.

Expand Down Expand Up @@ -385,6 +385,6 @@ ruby -Ilib:test test/test_reader.rb
## Additional Resources

- [API Documentation](https://www.rubydoc.info/gems/maxmind-geoip2)
- [GeoIP2 Web Services Docs](https://dev.maxmind.com/geoip/docs/web-services)
- [GeoIP Web Services Docs](https://dev.maxmind.com/geoip/docs/web-services)
- [MaxMind DB Format](https://maxmind.github.io/MaxMind-DB/)
- GitHub Issues: https://github.com/maxmind/GeoIP2-ruby/issues
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# GeoIP2 Ruby API
# GeoIP Ruby API

## Description

This is the Ruby API for the GeoIP2 and GeoLite2
This is the Ruby API for the GeoIP and GeoLite
[webservices](https://dev.maxmind.com/geoip/docs/web-services?lang=en)
and [databases](https://dev.maxmind.com/geoip/docs/databases?lang=en).

Expand All @@ -15,7 +15,7 @@ gem install maxmind-geoip2
## IP Geolocation Usage

IP geolocation is inherently imprecise. Locations are often near the center
of the population. Any location provided by a GeoIP2 database or web
of the population. Any location provided by a GeoIP database or web
service should not be used to identify a particular address or household.

## Database Reader
Expand Down Expand Up @@ -217,7 +217,7 @@ puts record.organization # University of Minnesota
### Usage

To use this API, you must create a new `MaxMind::GeoIP2::Client` object
with your account ID and license key. To use the GeoLite2 web service, you
with your account ID and license key. To use the GeoLite web service, you
may also set the `host` parameter to `geolite.info`. You may then you call
the method corresponding to a specific end point, passing it the IP address
you want to look up.
Expand All @@ -243,18 +243,18 @@ client = MaxMind::GeoIP2::Client.new(
account_id: 42,
license_key: 'license_key',

# To use the GeoLite2 web service instead of the GeoIP2 web service, set
# To use the GeoLite web service instead of the GeoIP web service, set
# the host parameter to "geolite.info":
# host: 'geolite.info',

# To use the Sandbox GeoIP2 web service instead of the production GeoIP2
# To use the Sandbox GeoIP web service instead of the production GeoIP
# web service, set the host parameter to "sandbox.maxmind.com":
# host: 'sandbox.maxmind.com',
)

# Replace "city" with the method corresponding to the web service that
# you are using, e.g., "country", "insights". Please note that Insights
# is only supported by the GeoIP2 web service and not the GeoLite2 web
# is only supported by the GeoIP web service and not the GeoLite web
# service.
record = client.city('128.101.101.101')

Expand Down Expand Up @@ -299,7 +299,7 @@ which can be populated vary between end points. In addition, while an end
point may offer a particular piece of data, MaxMind does not always have
every piece of data for any given IP address.

See the [GeoIP2 web service
See the [GeoIP web service
documentation](https://dev.maxmind.com/geoip/docs/web-services?lang=en) for details on
what data each end point may return.

Expand All @@ -313,7 +313,7 @@ databases with data on geographical features around the world, including
populated places. They offer both free and paid premium data. Each feature
is unique identified by a `geoname_id`, which is an integer.

Many of the records returned by the GeoIP2 web services and databases
Many of the records returned by the GeoIP web services and databases
include a `geoname_id` property. This is the ID of a geographical feature
(city, region, country, etc.) in the GeoNames database.

Expand Down
10 changes: 5 additions & 5 deletions lib/maxmind/geoip2/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
module MaxMind
module GeoIP2
# This class provides a client API for all the
# {https://dev.maxmind.com/geoip/docs/web-services?lang=en GeoIP2 web
# {https://dev.maxmind.com/geoip/docs/web-services?lang=en GeoIP web
# services}. The services are Country, City Plus, and Insights. Each service
# returns a different set of data about an IP address, with Country returning
# the least data and Insights the most.
Expand Down Expand Up @@ -60,7 +60,7 @@ class Client
# rubocop:disable Metrics/CyclomaticComplexity
# rubocop:disable Metrics/PerceivedComplexity

# Create a Client that may be used to query a GeoIP2 web service.
# Create a Client that may be used to query a GeoIP web service.
#
# Once created, the Client is safe to use for lookups from multiple
# threads.
Expand All @@ -73,8 +73,8 @@ class Client
# property from most preferred to least preferred.
#
# @param host [String] the host to use when querying the web service. Set
# this to "geolite.info" to use the GeoLite2 web service instead of the
# GeoIP2 web service. Set this to "sandbox.maxmind.com" to use the
# this to "geolite.info" to use the GeoLite web service instead of the
# GeoIP web service. Set this to "sandbox.maxmind.com" to use the
# Sandbox environment. The sandbox allows you to experiment with the
# API without affecting your production data.
#
Expand Down Expand Up @@ -205,7 +205,7 @@ def country(ip_address = 'me')

# This method calls the Insights web service.
#
# Insights is only supported by the GeoIP2 web service. The GeoLite2 web
# Insights is only supported by the GeoIP web service. The GeoLite web
# service does not support it.
#
# @param ip_address [String] IPv4 or IPv6 address as a string. If no
Expand Down
2 changes: 1 addition & 1 deletion lib/maxmind/geoip2/model/asn.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
module MaxMind
module GeoIP2
module Model
# Model class for the GeoLite2 ASN database.
# Model class for the GeoLite ASN database.
class ASN < Abstract
# The autonomous system number associated with the IP address.
#
Expand Down
4 changes: 2 additions & 2 deletions lib/maxmind/geoip2/model/city.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
module MaxMind
module GeoIP2
module Model
# Model class for the data returned by the GeoIP2 City Plus web service
# and the City database. It is also used for GeoLite2 City lookups.
# Model class for the data returned by the GeoIP City Plus web service
# and the City database. It is also used for GeoLite City lookups.
#
# See https://dev.maxmind.com/geoip/docs/web-services?lang=en for more
# details.
Expand Down
2 changes: 1 addition & 1 deletion lib/maxmind/geoip2/model/connection_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
module MaxMind
module GeoIP2
module Model
# Model class for the GeoIP2 Connection Type database.
# Model class for the GeoIP Connection Type database.
class ConnectionType < Abstract
# The connection type may take the following values: "Dialup",
# "Cable/DSL", "Corporate", "Cellular", and "Satellite". Additional
Expand Down
4 changes: 2 additions & 2 deletions lib/maxmind/geoip2/model/country.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
module MaxMind
module GeoIP2
module Model
# Model class for the data returned by the GeoIP2 Country web service and
# database. It is also used for GeoLite2 Country lookups.
# Model class for the data returned by the GeoIP Country web service and
# database. It is also used for GeoLite Country lookups.
class Country
# Continent data for the IP address.
#
Expand Down
2 changes: 1 addition & 1 deletion lib/maxmind/geoip2/model/domain.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
module MaxMind
module GeoIP2
module Model
# Model class for the GeoIP2 Domain database.
# Model class for the GeoIP Domain database.
class Domain < Abstract
# The second level domain associated with the IP address. This will be
# something like "example.com" or "example.co.uk", not "foo.example.com".
Expand Down
2 changes: 1 addition & 1 deletion lib/maxmind/geoip2/model/enterprise.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
module MaxMind
module GeoIP2
module Model
# Model class for the data returned by GeoIP2 Enterprise database lookups.
# Model class for the data returned by GeoIP Enterprise database lookups.
#
# See https://dev.maxmind.com/geoip/docs/web-services?lang=en for more
# details.
Expand Down
2 changes: 1 addition & 1 deletion lib/maxmind/geoip2/model/insights.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
module MaxMind
module GeoIP2
module Model
# Model class for the data returned by the GeoIP2 Insights web service.
# Model class for the data returned by the GeoIP Insights web service.
#
# See https://dev.maxmind.com/geoip/docs/web-services?lang=en for more
# details.
Expand Down
2 changes: 1 addition & 1 deletion lib/maxmind/geoip2/model/isp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
module MaxMind
module GeoIP2
module Model
# Model class for the GeoIP2 ISP database.
# Model class for the GeoIP ISP database.
class ISP < Abstract
# The autonomous system number associated with the IP address.
#
Expand Down
6 changes: 3 additions & 3 deletions lib/maxmind/geoip2/reader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

module MaxMind
module GeoIP2
# Reader is a reader for the GeoIP2/GeoLite2 database format. IP addresses
# Reader is a reader for the GeoIP/GeoLite database format. IP addresses
# can be looked up using the database specific methods.
#
# == Example
Expand All @@ -31,7 +31,7 @@ class Reader
# rubocop:disable Metrics/CyclomaticComplexity
# rubocop:disable Metrics/PerceivedComplexity

# Create a Reader for looking up IP addresses in a GeoIP2/GeoLite2 database
# Create a Reader for looking up IP addresses in a GeoIP/GeoLite database
# file.
#
# If you're performing multiple lookups, it's most efficient to create one
Expand All @@ -41,7 +41,7 @@ class Reader
# threads. It is safe to use after forking.
#
# @overload initialize(database:, locales: ['en'], mode: MaxMind::DB::MODE_AUTO)
# @param database [String] a path to a GeoIP2/GeoLite2 database file.
# @param database [String] a path to a GeoIP/GeoLite database file.
# @param locales [Array<String>] a list of locale codes to use in the name
# property from most preferred to least preferred.
# @param mode [Symbol] Defines how to open the database. It may be one of
Expand Down
2 changes: 1 addition & 1 deletion lib/maxmind/geoip2/record/city.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module Record
class City < Place
# A value from 0-100 indicating MaxMind's confidence that the city is
# correct. This attribute is only available from the Insights service and
# the GeoIP2 Enterprise database.
# the GeoIP Enterprise database.
#
# @return [Integer, nil]
def confidence
Expand Down
2 changes: 1 addition & 1 deletion lib/maxmind/geoip2/record/country.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module Record
class Country < Place
# A value from 0-100 indicating MaxMind's confidence that the country is
# correct. This attribute is only available from the Insights service and
# the GeoIP2 Enterprise database.
# the GeoIP Enterprise database.
#
# @return [Integer, nil]
def confidence
Expand Down
2 changes: 1 addition & 1 deletion lib/maxmind/geoip2/record/postal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def code

# A value from 0-100 indicating MaxMind's confidence that the postal code
# is correct. This attribute is only available from the Insights service
# and the GeoIP2 Enterprise database.
# and the GeoIP Enterprise database.
#
# @return [Integer, nil]
def confidence
Expand Down
2 changes: 1 addition & 1 deletion lib/maxmind/geoip2/record/subdivision.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module Record
class Subdivision < Place
# This is a value from 0-100 indicating MaxMind's confidence that the
# subdivision is correct. This attribute is only available from the
# Insights service and the GeoIP2 Enterprise database.
# Insights service and the GeoIP Enterprise database.
#
# @return [Integer, nil]
def confidence
Expand Down
2 changes: 1 addition & 1 deletion lib/maxmind/geoip2/record/traits.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def anonymous_vpn?
# {https://en.wikipedia.org/wiki/Anycast anycast network}.
#
# This property is only available from the Country, City Plus, and
# Insights web services and the GeoIP2 Country, City, and Enterprise
# Insights web services and the GeoIP Country, City, and Enterprise
# databases.
#
# @return [Boolean]
Expand Down
4 changes: 2 additions & 2 deletions maxmind-geoip2.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ Gem::Specification.new do |s|
s.authors = ['William Storey']
s.files = Dir['**/*'].difference(Dir['.github/**/*', 'dev-bin/**/*', 'test/**/*', 'CLAUDE.md', 'Gemfile*', 'Rakefile', '*.gemspec', 'README.dev.md'])
s.name = 'maxmind-geoip2'
s.summary = 'A gem for interacting with the GeoIP2 webservices and databases.'
s.summary = 'A gem for interacting with the GeoIP webservices and databases.'
s.version = MaxMind::GeoIP2::VERSION

s.description = 'A gem for interacting with the GeoIP2 webservices and databases. MaxMind provides geolocation data as downloadable databases as well as through a webservice.'
s.description = 'A gem for interacting with the GeoIP webservices and databases. MaxMind provides geolocation data as downloadable databases as well as through a webservice.'
s.email = 'support@maxmind.com'
s.homepage = 'https://github.com/maxmind/GeoIP2-ruby'
s.licenses = ['Apache-2.0', 'MIT']
Expand Down
32 changes: 32 additions & 0 deletions mise.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# @generated - this file is auto-generated by `mise lock` https://mise.jdx.dev/dev-tools/mise-lock.html

[[tools.ruby]]
version = "4.0.5"
backend = "core:ruby"

[tools.ruby."platforms.linux-arm64"]
checksum = "sha256:7d6149079a63f8ae1d326c9fa65c6019ba2dc3155eae7b39159817911c88958e"
url = "https://cache.ruby-lang.org/pub/ruby/4.0/ruby-4.0.5.tar.gz"

[tools.ruby."platforms.linux-arm64-musl"]
checksum = "sha256:7d6149079a63f8ae1d326c9fa65c6019ba2dc3155eae7b39159817911c88958e"
url = "https://cache.ruby-lang.org/pub/ruby/4.0/ruby-4.0.5.tar.gz"

[tools.ruby."platforms.linux-x64"]
checksum = "sha256:7d6149079a63f8ae1d326c9fa65c6019ba2dc3155eae7b39159817911c88958e"
url = "https://cache.ruby-lang.org/pub/ruby/4.0/ruby-4.0.5.tar.gz"

[tools.ruby."platforms.linux-x64-musl"]
checksum = "sha256:7d6149079a63f8ae1d326c9fa65c6019ba2dc3155eae7b39159817911c88958e"
url = "https://cache.ruby-lang.org/pub/ruby/4.0/ruby-4.0.5.tar.gz"

[tools.ruby."platforms.macos-arm64"]
checksum = "sha256:7d6149079a63f8ae1d326c9fa65c6019ba2dc3155eae7b39159817911c88958e"
url = "https://cache.ruby-lang.org/pub/ruby/4.0/ruby-4.0.5.tar.gz"

[tools.ruby."platforms.macos-x64"]
checksum = "sha256:7d6149079a63f8ae1d326c9fa65c6019ba2dc3155eae7b39159817911c88958e"
url = "https://cache.ruby-lang.org/pub/ruby/4.0/ruby-4.0.5.tar.gz"

[tools.ruby."platforms.windows-x64"]
url = "https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-4.0.5-1/rubyinstaller-4.0.5-1-x64.7z"
17 changes: 17 additions & 0 deletions mise.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[settings]
experimental = true
lockfile = true
disable_backends = [
"asdf",
"vfox",
]

[tools]
ruby = "latest"

[hooks]
enter = "mise install --quiet --locked"

[[watch_files]]
patterns = ["mise.toml", "mise.lock"]
run = "mise install --quiet --locked"
2 changes: 1 addition & 1 deletion test/test_model_country.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def test_unknown_trait
end

# This can happen if we're being created from a not fully populated response
# when used by minFraud. It shouldn't ever happen from GeoIP2 though.
# when used by minFraud. It shouldn't ever happen from GeoIP though.
def test_no_traits
model = MaxMind::GeoIP2::Model::Country.new(
{
Expand Down
Loading