Module: Trackdown
- Defined in:
- lib/trackdown.rb,
lib/trackdown/error.rb,
lib/trackdown/version.rb,
lib/trackdown/ip_locator.rb,
lib/trackdown/ip_validator.rb,
lib/trackdown/configuration.rb,
lib/trackdown/location_result.rb,
lib/trackdown/database_updater.rb,
lib/trackdown/providers/auto_provider.rb,
lib/trackdown/providers/base_provider.rb,
lib/trackdown/providers/maxmind_provider.rb,
lib/generators/trackdown/install_generator.rb,
lib/trackdown/providers/cloudflare_provider.rb
Defined Under Namespace
Modules: Generators, Providers Classes: Configuration, DatabaseUpdater, Error, IpLocator, IpValidator, LocationResult
Constant Summary collapse
- VERSION =
"0.2.0"
Class Attribute Summary collapse
Class Method Summary collapse
- .configure {|configuration| ... } ⇒ Object
- .database_exists? ⇒ Boolean
-
.ensure_database_exists! ⇒ Object
Legacy method - kept for backwards compatibility New code should handle provider-specific errors instead.
-
.locate(ip, request: nil) ⇒ LocationResult
Locate an IP address using the configured provider.
-
.update_database ⇒ Object
Update the MaxMind database (only needed when using MaxMind provider).
Class Attribute Details
.configuration ⇒ Object
20 21 22 |
# File 'lib/trackdown.rb', line 20 def self.configuration @configuration ||= Configuration.new end |
Class Method Details
.configure {|configuration| ... } ⇒ Object
24 25 26 |
# File 'lib/trackdown.rb', line 24 def self.configure yield(configuration) end |
.database_exists? ⇒ Boolean
41 42 43 |
# File 'lib/trackdown.rb', line 41 def self.database_exists? File.exist?(configuration.database_path) end |
.ensure_database_exists! ⇒ Object
Legacy method - kept for backwards compatibility New code should handle provider-specific errors instead
47 48 49 50 51 |
# File 'lib/trackdown.rb', line 47 def self.ensure_database_exists! unless database_exists? raise Error, "MaxMind database not found. Please set your MaxMind keys in config/initializers/trackdown.rb as described in the `trackdown` gem README, and then run Trackdown.update_database to download the MaxMind IP geolocation database." end end |
.locate(ip, request: nil) ⇒ LocationResult
Locate an IP address using the configured provider
32 33 34 |
# File 'lib/trackdown.rb', line 32 def self.locate(ip, request: nil) IpLocator.locate(ip, request: request) end |
.update_database ⇒ Object
Update the MaxMind database (only needed when using MaxMind provider)
37 38 39 |
# File 'lib/trackdown.rb', line 37 def self.update_database DatabaseUpdater.update end |