geoip-rails 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +2 -0
- data/app/models/geoip/location.rb +4 -0
- data/lib/geoip-rails/version.rb +1 -1
- metadata +4 -4
data/README.markdown
CHANGED
@@ -1,9 +1,13 @@
|
|
1
1
|
module Geoip
|
2
2
|
class Location < Geoip::Base
|
3
3
|
|
4
|
+
IPADDR_REGEX = /^([1-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])){3}$/
|
5
|
+
|
4
6
|
has_many :blocks
|
5
7
|
|
6
8
|
def self.find_by_ip(ip, &block)
|
9
|
+
return nil unless IPADDR_REGEX.match(ip)
|
10
|
+
|
7
11
|
location = self.joins(:blocks).where('MBRCONTAINS(ip_poly, POINTFROMWKB(POINT(INET_ATON(?), 0)))', ip).first
|
8
12
|
|
9
13
|
if location and block_given?
|
data/lib/geoip-rails/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: geoip-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 31
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 2
|
10
|
+
version: 0.1.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Priit Haamer
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-11-11 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|