Module: IpFilter
- Extended by:
- IpFilter
- Included in:
- IpFilter
- Defined in:
- lib/ip_filter.rb,
lib/ip_filter/cache.rb,
lib/ip_filter/railtie.rb,
lib/ip_filter/request.rb,
lib/ip_filter/version.rb,
lib/ip_filter/cache/redis.rb,
lib/ip_filter/lookups/base.rb,
lib/ip_filter/providers/s3.rb,
lib/ip_filter/results/base.rb,
lib/ip_filter/configuration.rb,
lib/ip_filter/lookups/geoip.rb,
lib/ip_filter/results/geoip.rb,
lib/ip_filter/cache/dallistore.rb,
lib/ip_filter/providers/max_mind.rb,
lib/ip_filter/controller/geo_ip_lookup.rb
Defined Under Namespace
Modules: Controller, Lookup, Providers, Request, Result Classes: Cache, Configuration, Railtie
Constant Summary collapse
- VERSION =
'0.8.0'
Class Attribute Summary collapse
-
.configuration ⇒ Object
Returns the value of attribute configuration.
Instance Attribute Summary collapse
-
#lookups ⇒ Object
readonly
Returns the value of attribute lookups.
-
#refresh_inprogress ⇒ Object
readonly
Returns the value of attribute refresh_inprogress.
-
#updated_at ⇒ Object
Returns the value of attribute updated_at.
Class Method Summary collapse
Instance Method Summary collapse
-
#cache ⇒ Object
The working Cache object, or
nilif none configured. - #database_files ⇒ Object
- #maxmind ⇒ Object
- #reference_file ⇒ Object
- #s3 ⇒ Object
-
#search(query) ⇒ Object
Search for information about an address.
Class Attribute Details
.configuration ⇒ Object
Returns the value of attribute configuration.
15 16 17 |
# File 'lib/ip_filter.rb', line 15 def configuration @configuration end |
Instance Attribute Details
#lookups ⇒ Object (readonly)
Returns the value of attribute lookups.
11 12 13 |
# File 'lib/ip_filter.rb', line 11 def lookups @lookups end |
#refresh_inprogress ⇒ Object (readonly)
Returns the value of attribute refresh_inprogress.
11 12 13 |
# File 'lib/ip_filter.rb', line 11 def refresh_inprogress @refresh_inprogress end |
#updated_at ⇒ Object
Returns the value of attribute updated_at.
10 11 12 |
# File 'lib/ip_filter.rb', line 10 def updated_at @updated_at end |
Class Method Details
.configure {|configuration| ... } ⇒ Object
18 19 20 21 |
# File 'lib/ip_filter.rb', line 18 def self.configure self.configuration ||= IpFilter::Configuration.new yield(configuration) end |
Instance Method Details
#cache ⇒ Object
The working Cache object, or nil if none configured.
40 41 42 |
# File 'lib/ip_filter.rb', line 40 def cache @cache ||= configuration.cache end |
#database_files ⇒ Object
61 62 63 |
# File 'lib/ip_filter.rb', line 61 def database_files Dir[configuration.data_folder + '/*.dat'] end |
#maxmind ⇒ Object
53 54 55 |
# File 'lib/ip_filter.rb', line 53 def maxmind @maxmind ||= IpFilter::Providers::MaxMind.new end |
#reference_file ⇒ Object
57 58 59 |
# File 'lib/ip_filter.rb', line 57 def reference_file configuration.geo_ip_dat end |
#s3 ⇒ Object
44 45 46 47 48 49 50 51 |
# File 'lib/ip_filter.rb', line 44 def s3 return @s3 unless @s3.nil? if !configuration.s3_access_key_id.nil? && !configuration.s3_secret_access_key.nil? return @s3 ||= IpFilter::S3.new end @s3 end |
#search(query) ⇒ Object
Search for information about an address.
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/ip_filter.rb', line 26 def search(query) if !ip_address?(query) && query.blank? raise ArgumentError, 'invalid address' end begin get_lookup.search(query) rescue sleep(0.300) # wait to reload the file get_lookup.search(query) end end |