validates_ip_format_of 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Rakefile CHANGED
@@ -15,10 +15,10 @@ require 'jeweler'
15
15
  Jeweler::Tasks.new do |gem|
16
16
  # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
17
  gem.name = "validates_ip_format_of"
18
- gem.homepage = "http://github.com/RLovelett/validates_ip_format_of"
18
+ gem.homepage = "http://github.com/wahvee/validates_ip_format_of"
19
19
  gem.license = "MIT"
20
20
  gem.summary = %Q{Validate the format of a IP by regexp in Ruby on Rails.}
21
- gem.description = %Q{Rails plugin that provides a validates_ip_format_of method to ActiveRecord models. IPs are validated by regexp.}
21
+ gem.description = %Q{Rails plugin that provides a validates_ip_format_of method to ActiveRecord models. IPs are validated by regexp. IP validation. Validate IP.}
22
22
  gem.email = "ryan@wahvee.com"
23
23
  gem.authors = ["Ryan Lovelett"]
24
24
  # dependencies defined in Gemfile
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.0
1
+ 1.0.1
data/init.rb CHANGED
@@ -1,47 +1 @@
1
- require 'active_record'
2
-
3
- # encoding: utf-8
4
- module ValidatesIpFormatOf
5
- IPv4_PART = /\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]/ # 0-255
6
-
7
- # http://en.wikipedia.org/wiki/IP_address
8
- # http://en.wikipedia.org/wiki/Default_route
9
- # http://en.wikipedia.org/wiki/Localhost
10
-
11
- # Blocks IPv4 10.0.0.0 - 10.255.255.255
12
- TWENTY_FOUR_BIT_BLOCK = /(?!10\.((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.?)){3})/
13
- # Blocks IPv4 172.16.0.0 - 172.31.255.255
14
- TWENTY_BIT_BLOCK = /(?!172\.(0?3[0-1]|0?2[0-9]|0?1[6-9])\.((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.?)){2})/
15
- # Blocks IPv4 192.168.0.0 - 192.168.255.255
16
- SIXTEEN_BIT_BLOCK = /(?!192\.168\.((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.?)){2})/
17
- # Blocks IPv4 127.0.0.1 (which is also localhost)
18
- LOCALHOST_LOOPBACK = /(?!127\.0\.0\.[0-8])/
19
- ALL_ROUTES = /(?!0\.0\.0\.0)/
20
- RFC_1918_IPS = %r{#{TWENTY_FOUR_BIT_BLOCK}#{TWENTY_BIT_BLOCK}#{SIXTEEN_BIT_BLOCK}}
21
-
22
- REGEXP = %r{
23
- \A
24
- #{LOCALHOST_LOOPBACK} # blocks 127.0.0.0/8
25
- #{ALL_ROUTES} # blocks 0.0.0.0
26
- #{RFC_1918_IPS} # blocks the use of RFC 1918 private network IPv4 addresses
27
- #{IPv4_PART}(\.#{IPv4_PART}){3} # Allow IPv4
28
- \Z
29
- }iux
30
-
31
- DEFAULT_MESSAGE = 'does not appear to be a valid IP Address'
32
-
33
- def validates_ip_format_of(*attr_names)
34
- options = { :allow_nil => false,
35
- :allow_blank => false,
36
- :message => DEFAULT_MESSAGE,
37
- :with => REGEXP
38
- }
39
- options = options.merge(attr_names.pop) if attr_names.last.is_a?(Hash)
40
- attr_names.each do |attr_name|
41
- validates_format_of(attr_name, options)
42
- end
43
- end
44
-
45
- end
46
-
47
- ActiveRecord::Base.extend(ValidatesIpFormatOf)
1
+ require 'validates_ip_format_of'
@@ -0,0 +1,47 @@
1
+ require 'active_record'
2
+
3
+ # encoding: utf-8
4
+ module ValidatesIpFormatOf
5
+ IPv4_PART = /\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]/ # 0-255
6
+
7
+ # http://en.wikipedia.org/wiki/IP_address
8
+ # http://en.wikipedia.org/wiki/Default_route
9
+ # http://en.wikipedia.org/wiki/Localhost
10
+
11
+ # Blocks IPv4 10.0.0.0 - 10.255.255.255
12
+ TWENTY_FOUR_BIT_BLOCK = /(?!10\.((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.?)){3})/
13
+ # Blocks IPv4 172.16.0.0 - 172.31.255.255
14
+ TWENTY_BIT_BLOCK = /(?!172\.(0?3[0-1]|0?2[0-9]|0?1[6-9])\.((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.?)){2})/
15
+ # Blocks IPv4 192.168.0.0 - 192.168.255.255
16
+ SIXTEEN_BIT_BLOCK = /(?!192\.168\.((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.?)){2})/
17
+ # Blocks IPv4 127.0.0.1 (which is also localhost)
18
+ LOCALHOST_LOOPBACK = /(?!127\.0\.0\.[0-8])/
19
+ ALL_ROUTES = /(?!0\.0\.0\.0)/
20
+ RFC_1918_IPS = %r{#{TWENTY_FOUR_BIT_BLOCK}#{TWENTY_BIT_BLOCK}#{SIXTEEN_BIT_BLOCK}}
21
+
22
+ REGEXP = %r{
23
+ \A
24
+ #{LOCALHOST_LOOPBACK} # blocks 127.0.0.0/8
25
+ #{ALL_ROUTES} # blocks 0.0.0.0
26
+ #{RFC_1918_IPS} # blocks the use of RFC 1918 private network IPv4 addresses
27
+ #{IPv4_PART}(\.#{IPv4_PART}){3} # Allow IPv4
28
+ \Z
29
+ }iux
30
+
31
+ DEFAULT_MESSAGE = 'does not appear to be a valid IP Address'
32
+
33
+ def validates_ip_format_of(*attr_names)
34
+ options = { :allow_nil => false,
35
+ :allow_blank => false,
36
+ :message => DEFAULT_MESSAGE,
37
+ :with => REGEXP
38
+ }
39
+ options = options.merge(attr_names.pop) if attr_names.last.is_a?(Hash)
40
+ attr_names.each do |attr_name|
41
+ validates_format_of(attr_name, options)
42
+ end
43
+ end
44
+
45
+ end
46
+
47
+ ActiveRecord::Base.extend(ValidatesIpFormatOf)
@@ -5,12 +5,12 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{validates_ip_format_of}
8
- s.version = "1.0.0"
8
+ s.version = "1.0.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Ryan Lovelett"]
12
- s.date = %q{2011-06-01}
13
- s.description = %q{Rails plugin that provides a validates_ip_format_of method to ActiveRecord models. IPs are validated by regexp.}
12
+ s.date = %q{2011-06-12}
13
+ s.description = %q{Rails plugin that provides a validates_ip_format_of method to ActiveRecord models. IPs are validated by regexp. IP validation. Validate IP.}
14
14
  s.email = %q{ryan@wahvee.com}
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE.txt",
@@ -25,11 +25,12 @@ Gem::Specification.new do |s|
25
25
  "Rakefile",
26
26
  "VERSION",
27
27
  "init.rb",
28
+ "lib/validates_ip_format_of.rb",
28
29
  "spec/spec_helper.rb",
29
30
  "spec/validates_ip_format_of_spec.rb",
30
31
  "validates_ip_format_of.gemspec"
31
32
  ]
32
- s.homepage = %q{http://github.com/RLovelett/validates_ip_format_of}
33
+ s.homepage = %q{http://github.com/wahvee/validates_ip_format_of}
33
34
  s.licenses = ["MIT"]
34
35
  s.require_paths = ["lib"]
35
36
  s.rubygems_version = %q{1.6.2}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: validates_ip_format_of
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,12 +9,12 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-06-01 00:00:00.000000000 -05:00
12
+ date: 2011-06-12 00:00:00.000000000 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: faker
17
- requirement: &69824927566980 !ruby/object:Gem::Requirement
17
+ requirement: &69878279120760 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: '0'
23
23
  type: :development
24
24
  prerelease: false
25
- version_requirements: *69824927566980
25
+ version_requirements: *69878279120760
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: activerecord
28
- requirement: &69824927566500 !ruby/object:Gem::Requirement
28
+ requirement: &69878279120280 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ! '>='
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: 3.0.7
34
34
  type: :development
35
35
  prerelease: false
36
- version_requirements: *69824927566500
36
+ version_requirements: *69878279120280
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: rspec
39
- requirement: &69824927566020 !ruby/object:Gem::Requirement
39
+ requirement: &69878279119800 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ~>
@@ -44,10 +44,10 @@ dependencies:
44
44
  version: 2.3.0
45
45
  type: :development
46
46
  prerelease: false
47
- version_requirements: *69824927566020
47
+ version_requirements: *69878279119800
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: bundler
50
- requirement: &69824927565540 !ruby/object:Gem::Requirement
50
+ requirement: &69878279119320 !ruby/object:Gem::Requirement
51
51
  none: false
52
52
  requirements:
53
53
  - - ~>
@@ -55,10 +55,10 @@ dependencies:
55
55
  version: 1.0.0
56
56
  type: :development
57
57
  prerelease: false
58
- version_requirements: *69824927565540
58
+ version_requirements: *69878279119320
59
59
  - !ruby/object:Gem::Dependency
60
60
  name: jeweler
61
- requirement: &69824927565060 !ruby/object:Gem::Requirement
61
+ requirement: &69878279118840 !ruby/object:Gem::Requirement
62
62
  none: false
63
63
  requirements:
64
64
  - - ~>
@@ -66,10 +66,10 @@ dependencies:
66
66
  version: 1.6.2
67
67
  type: :development
68
68
  prerelease: false
69
- version_requirements: *69824927565060
69
+ version_requirements: *69878279118840
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: rcov
72
- requirement: &69824927564580 !ruby/object:Gem::Requirement
72
+ requirement: &69878279118360 !ruby/object:Gem::Requirement
73
73
  none: false
74
74
  requirements:
75
75
  - - ! '>='
@@ -77,9 +77,9 @@ dependencies:
77
77
  version: '0'
78
78
  type: :development
79
79
  prerelease: false
80
- version_requirements: *69824927564580
80
+ version_requirements: *69878279118360
81
81
  description: Rails plugin that provides a validates_ip_format_of method to ActiveRecord
82
- models. IPs are validated by regexp.
82
+ models. IPs are validated by regexp. IP validation. Validate IP.
83
83
  email: ryan@wahvee.com
84
84
  executables: []
85
85
  extensions: []
@@ -95,11 +95,12 @@ files:
95
95
  - Rakefile
96
96
  - VERSION
97
97
  - init.rb
98
+ - lib/validates_ip_format_of.rb
98
99
  - spec/spec_helper.rb
99
100
  - spec/validates_ip_format_of_spec.rb
100
101
  - validates_ip_format_of.gemspec
101
102
  has_rdoc: true
102
- homepage: http://github.com/RLovelett/validates_ip_format_of
103
+ homepage: http://github.com/wahvee/validates_ip_format_of
103
104
  licenses:
104
105
  - MIT
105
106
  post_install_message:
@@ -114,7 +115,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
114
115
  version: '0'
115
116
  segments:
116
117
  - 0
117
- hash: 1310148042613260488
118
+ hash: -1865952321196246873
118
119
  required_rubygems_version: !ruby/object:Gem::Requirement
119
120
  none: false
120
121
  requirements: