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/database_fingerprint.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,
lib/trackdown/providers/cloudfront_provider.rb
Defined Under Namespace
Modules: Generators, Providers Classes: Configuration, DatabaseFingerprint, DatabaseUpdater, Error, IpLocator, IpValidator, LocationResult
Constant Summary collapse
- VERSION =
"0.4.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
22 23 24 |
# File 'lib/trackdown.rb', line 22 def self.configuration @configuration ||= Configuration.new end |
Class Method Details
.configure {|configuration| ... } ⇒ Object
26 27 28 |
# File 'lib/trackdown.rb', line 26 def self.configure yield(configuration) end |
.database_exists? ⇒ Boolean
43 44 45 |
# File 'lib/trackdown.rb', line 43 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
49 50 51 52 53 |
# File 'lib/trackdown.rb', line 49 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
34 35 36 |
# File 'lib/trackdown.rb', line 34 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)
39 40 41 |
# File 'lib/trackdown.rb', line 39 def self.update_database DatabaseUpdater.update end |