ip_address_validator 1.0.0 → 2.0.0
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.
- checksums.yaml +7 -0
- data/.rspec +3 -0
- data/.rubocop.yml +12 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/CHANGELOG.md +44 -0
- data/README.md +85 -0
- data/Rakefile +6 -30
- data/ip_address_validator.gemspec +44 -53
- data/lib/ip_address_validator/version.rb +9 -0
- data/lib/ip_address_validator.rb +96 -18
- metadata +98 -98
- data/Gemfile +0 -9
- data/Gemfile.lock +0 -37
- data/README.textile +0 -40
- data/VERSION +0 -1
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: db0a7b1739ea1d25b0acc928c0b5ba6352bb64e13f5338c0ce5906b7a229404a
|
|
4
|
+
data.tar.gz: e5250255f4e377d10c638156aad4b80b1fa5913bc386f764e44ded225c8182da
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 9c3e940aaa1d893353a21616e5ea48682dacd029771a24879666ac83bfd3f191a11ab34c21e57583aac7d971f2385f33eb5739b252011316529441ca93f9dc8e
|
|
7
|
+
data.tar.gz: 54952b376c8b9bd6495dbc1b8fd9a80655b015dd72e3742bdfdc014eed7190be2ff0510460006928051db06aad4dfede63048a51eef0062256caeabab62dc030
|
data/.rspec
ADDED
data/.rubocop.yml
ADDED
data/.ruby-gemset
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
lev
|
data/.ruby-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ruby-4.0.3
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
## [2.0.0] - 2026-05-14
|
|
6
|
+
|
|
7
|
+
### Breaking
|
|
8
|
+
- Bumped minimum Ruby to **3.1**.
|
|
9
|
+
- Bumped `activemodel` runtime dependency to **>= 6.1**. `activerecord` is no
|
|
10
|
+
longer a (transitive) dependency; the validator only needs ActiveModel.
|
|
11
|
+
- `localized_each_validator` runtime dependency bumped to **>= 2.0**.
|
|
12
|
+
- CIDR strings (e.g. `"10.0.0.0/24"`) are **no longer accepted by default**.
|
|
13
|
+
In 1.x they silently passed because `IPAddr.new` accepts them, so subnets
|
|
14
|
+
validated as "IP addresses". Pass `allow_cidr: true` to restore the old
|
|
15
|
+
behavior.
|
|
16
|
+
- Non-`String` values are now explicitly rejected.
|
|
17
|
+
|
|
18
|
+
### Added
|
|
19
|
+
- `:allow_cidr` option (default `false`) — opt back in to CIDR notation.
|
|
20
|
+
- `:no_loopback` option — rejects `127.0.0.0/8` and `::1`.
|
|
21
|
+
- `:no_private` option — rejects RFC 1918 ranges and IPv6 unique local
|
|
22
|
+
(`fc00::/7`).
|
|
23
|
+
- `:no_reserved` option — rejects link-local, multicast, broadcast,
|
|
24
|
+
documentation, benchmarking, TEST-NET and other reserved blocks.
|
|
25
|
+
- `:allow_blank` is now documented (it was already inherited from
|
|
26
|
+
`LocalizedEachValidator`).
|
|
27
|
+
- `IpAddressValidator::VERSION` constant in `lib/ip_address_validator/version.rb`.
|
|
28
|
+
- Real test suite (`spec/ip_address_validator_spec.rb`) — previously zero
|
|
29
|
+
tests shipped with the gem.
|
|
30
|
+
|
|
31
|
+
### Changed
|
|
32
|
+
- Replaced jeweler-generated gemspec with a hand-written one using
|
|
33
|
+
`git ls-files` and modern `spec.metadata` (including
|
|
34
|
+
`rubygems_mfa_required`).
|
|
35
|
+
- Replaced jeweler-flavored Rakefile with a small RSpec + bundler/gem_tasks
|
|
36
|
+
Rakefile.
|
|
37
|
+
- Modernized README; removed Rails-3-era framing.
|
|
38
|
+
- Added GitHub Actions matrix (Ruby 3.1–3.4 × activemodel 7.0–8.0).
|
|
39
|
+
|
|
40
|
+
### Removed
|
|
41
|
+
- `jeweler`, `yard`, and `RedCloth`/`redcarpet` dev dependencies.
|
|
42
|
+
- `.travis.yml`.
|
|
43
|
+
- Stale `README.textile` references.
|
|
44
|
+
- The duplicate `add_dependency` lines in the old gemspec.
|
data/README.md
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# ip_address_validator
|
|
2
|
+
|
|
3
|
+
[](https://github.com/RISCfuture/ip_address_validator/actions/workflows/ci.yml)
|
|
4
|
+
[](https://rubygems.org/gems/ip_address_validator)
|
|
5
|
+
[](LICENSE)
|
|
6
|
+
|
|
7
|
+
A localizable `EachValidator` for IPv4 and IPv6 address fields, with optional
|
|
8
|
+
restrictions on CIDR, loopback, private, and reserved ranges. Works with any
|
|
9
|
+
class that uses `ActiveModel::Validations` (Rails models, plain Ruby objects
|
|
10
|
+
that `include ActiveModel::Validations`, etc.).
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
```ruby
|
|
15
|
+
gem "ip_address_validator", "~> 2.0"
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Requires Ruby 3.1 or newer and `activemodel >= 6.1`.
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
22
|
+
```ruby
|
|
23
|
+
class User
|
|
24
|
+
include ActiveModel::Validations
|
|
25
|
+
attr_accessor :last_login_ip
|
|
26
|
+
|
|
27
|
+
validates :last_login_ip, ip_address: true
|
|
28
|
+
end
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Options
|
|
32
|
+
|
|
33
|
+
| Option | Default | Description |
|
|
34
|
+
|:---------------|:-------:|:-----------------------------------------------------------------------------------------------------------|
|
|
35
|
+
| `:ipv4_only` | `false` | If `true`, IPv6 addresses are considered invalid. |
|
|
36
|
+
| `:ipv6_only` | `false` | If `true`, IPv4 addresses are considered invalid. |
|
|
37
|
+
| `:allow_cidr` | `false` | If `true`, CIDR notation (e.g. `10.0.0.0/24`) is accepted. Otherwise any value containing `/` is rejected. |
|
|
38
|
+
| `:no_loopback` | `false` | If `true`, loopback addresses (`127.0.0.0/8`, `::1`) are rejected. |
|
|
39
|
+
| `:no_private` | `false` | If `true`, RFC 1918 ranges and IPv6 unique local (`fc00::/7`) are rejected. |
|
|
40
|
+
| `:no_reserved` | `false` | If `true`, link-local, multicast, broadcast, documentation, and other reserved blocks are rejected. |
|
|
41
|
+
| `:message` | — | Custom error message. |
|
|
42
|
+
| `:allow_nil` | `false` | If `true`, `nil` values are allowed. |
|
|
43
|
+
| `:allow_blank` | `false` | If `true`, blank values are allowed. |
|
|
44
|
+
|
|
45
|
+
### Examples
|
|
46
|
+
|
|
47
|
+
```ruby
|
|
48
|
+
# Only allow public, non-CIDR IPv4 addresses.
|
|
49
|
+
validates :webhook_source_ip, ip_address: {
|
|
50
|
+
ipv4_only: true,
|
|
51
|
+
no_loopback: true,
|
|
52
|
+
no_private: true,
|
|
53
|
+
no_reserved: true
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
# Allow a CIDR block (e.g. for an IP allowlist field).
|
|
57
|
+
validates :allowlist_entry, ip_address: { allow_cidr: true }
|
|
58
|
+
|
|
59
|
+
# Custom message.
|
|
60
|
+
validates :remote_ip, ip_address: { message: "must be a valid IP" }
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Localization
|
|
64
|
+
|
|
65
|
+
The error key is `invalid_ip`. Define it under the usual ActiveModel
|
|
66
|
+
errors hierarchy:
|
|
67
|
+
|
|
68
|
+
```yaml
|
|
69
|
+
en:
|
|
70
|
+
activemodel:
|
|
71
|
+
errors:
|
|
72
|
+
messages:
|
|
73
|
+
invalid_ip: "is not a valid IP address"
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Development
|
|
77
|
+
|
|
78
|
+
```sh
|
|
79
|
+
bin/setup
|
|
80
|
+
bundle exec rspec
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## License
|
|
84
|
+
|
|
85
|
+
Released under the MIT License. See `LICENSE`.
|
data/Rakefile
CHANGED
|
@@ -1,32 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
require 'bundler'
|
|
3
|
-
begin
|
|
4
|
-
Bundler.setup(:default, :development)
|
|
5
|
-
rescue Bundler::BundlerError => e
|
|
6
|
-
$stderr.puts e.message
|
|
7
|
-
$stderr.puts "Run `bundle install` to install missing gems"
|
|
8
|
-
exit e.status_code
|
|
9
|
-
end
|
|
10
|
-
require 'rake'
|
|
1
|
+
# frozen_string_literal: true
|
|
11
2
|
|
|
12
|
-
require
|
|
13
|
-
|
|
14
|
-
gem.name = "ip_address_validator"
|
|
15
|
-
gem.summary = %Q{Simple IP address validation in Rails 3}
|
|
16
|
-
gem.description = %Q{A simple, localizable EachValidator for IPv4 and IPv6 address fields in ActiveRecord 3.0.}
|
|
17
|
-
gem.email = "git@timothymorgan.info"
|
|
18
|
-
gem.homepage = "http://github.com/riscfuture/ip_address_validator"
|
|
19
|
-
gem.authors = [ "Tim Morgan" ]
|
|
20
|
-
end
|
|
21
|
-
Jeweler::RubygemsDotOrgTasks.new
|
|
3
|
+
require "bundler/gem_tasks"
|
|
4
|
+
require "rspec/core/rake_task"
|
|
22
5
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
doc.options << "--protected"
|
|
27
|
-
doc.options << "-r" << "README.textile"
|
|
28
|
-
doc.options << "-o" << "doc"
|
|
29
|
-
doc.options << "--title" << "ip_address_validator Documentation".inspect
|
|
30
|
-
|
|
31
|
-
doc.files = [ 'lib/*.rb', 'README.textile' ]
|
|
32
|
-
end
|
|
6
|
+
RSpec::Core::RakeTask.new(:spec)
|
|
7
|
+
|
|
8
|
+
task default: :spec
|
|
@@ -1,56 +1,47 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
".
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
|
39
|
-
s.add_runtime_dependency(%q<localized_each_validator>, [">= 1.0.1"])
|
|
40
|
-
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
|
41
|
-
s.add_development_dependency(%q<yard>, [">= 0"])
|
|
42
|
-
s.add_development_dependency(%q<RedCloth>, [">= 0"])
|
|
43
|
-
else
|
|
44
|
-
s.add_dependency(%q<localized_each_validator>, [">= 1.0.1"])
|
|
45
|
-
s.add_dependency(%q<jeweler>, [">= 0"])
|
|
46
|
-
s.add_dependency(%q<yard>, [">= 0"])
|
|
47
|
-
s.add_dependency(%q<RedCloth>, [">= 0"])
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "lib/ip_address_validator/version"
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |spec|
|
|
6
|
+
spec.name = "ip_address_validator"
|
|
7
|
+
spec.version = IpAddressValidatorGem::VERSION
|
|
8
|
+
spec.authors = ["Tim Morgan"]
|
|
9
|
+
spec.email = ["git@timothymorgan.info"]
|
|
10
|
+
|
|
11
|
+
spec.summary = "Simple IP address validator for ActiveModel"
|
|
12
|
+
spec.description = "A localizable EachValidator for IPv4 and IPv6 address fields, with optional " \
|
|
13
|
+
"restrictions on CIDR, loopback, private, and reserved ranges."
|
|
14
|
+
spec.homepage = "https://github.com/RISCfuture/ip_address_validator"
|
|
15
|
+
spec.license = "MIT"
|
|
16
|
+
|
|
17
|
+
spec.required_ruby_version = ">= 3.1"
|
|
18
|
+
|
|
19
|
+
spec.metadata = {
|
|
20
|
+
"source_code_uri" => "https://github.com/RISCfuture/ip_address_validator",
|
|
21
|
+
"changelog_uri" => "https://github.com/RISCfuture/ip_address_validator/blob/master/CHANGELOG.md",
|
|
22
|
+
"bug_tracker_uri" => "https://github.com/RISCfuture/ip_address_validator/issues",
|
|
23
|
+
"rubygems_mfa_required" => "true"
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
spec.files = Dir.chdir(__dir__) do
|
|
27
|
+
tracked =
|
|
28
|
+
begin
|
|
29
|
+
`git ls-files -z`.split("\x0")
|
|
30
|
+
rescue StandardError
|
|
31
|
+
[]
|
|
32
|
+
end
|
|
33
|
+
candidates = tracked.empty? ? Dir["**/*"] : tracked
|
|
34
|
+
candidates.select { |f| File.file?(f) }.reject do |f|
|
|
35
|
+
(File.expand_path(f) == __FILE__) ||
|
|
36
|
+
f.start_with?(*%w[bin/ test/ spec/ features/ .git .github .idea Gemfile])
|
|
48
37
|
end
|
|
49
|
-
else
|
|
50
|
-
s.add_dependency(%q<localized_each_validator>, [">= 1.0.1"])
|
|
51
|
-
s.add_dependency(%q<jeweler>, [">= 0"])
|
|
52
|
-
s.add_dependency(%q<yard>, [">= 0"])
|
|
53
|
-
s.add_dependency(%q<RedCloth>, [">= 0"])
|
|
54
38
|
end
|
|
55
|
-
|
|
39
|
+
spec.require_paths = ["lib"]
|
|
56
40
|
|
|
41
|
+
spec.add_dependency "activemodel", ">= 6.1"
|
|
42
|
+
spec.add_dependency "localized_each_validator", ">= 2.0"
|
|
43
|
+
|
|
44
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
|
45
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
|
46
|
+
spec.add_development_dependency "standard", ">= 1.0"
|
|
47
|
+
end
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Bare version constant. Lives in its own module so this file can be required
|
|
4
|
+
# from the gemspec without pulling in the rest of the gem (or its runtime
|
|
5
|
+
# dependencies). `lib/ip_address_validator.rb` re-exposes this as
|
|
6
|
+
# `IpAddressValidator::VERSION` once the validator class is defined.
|
|
7
|
+
module IpAddressValidatorGem
|
|
8
|
+
VERSION = "2.0.0"
|
|
9
|
+
end
|
data/lib/ip_address_validator.rb
CHANGED
|
@@ -1,32 +1,110 @@
|
|
|
1
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
require "ipaddr"
|
|
4
|
+
require "localized_each_validator"
|
|
5
|
+
|
|
6
|
+
require_relative "ip_address_validator/version"
|
|
7
|
+
|
|
8
|
+
# `IpAddressValidator` is defined here (not in `version.rb`) because its
|
|
9
|
+
# superclass `LocalizedEachValidator` isn't loaded until this file runs.
|
|
10
|
+
|
|
11
|
+
# Validates IPv4 and IPv6 addresses. Uses the `invalid_ip` error message key.
|
|
4
12
|
#
|
|
5
13
|
# @example
|
|
6
14
|
# validates :last_login_ip, ip_address: true
|
|
7
15
|
#
|
|
8
|
-
#
|
|
16
|
+
# Options
|
|
17
|
+
# -------
|
|
9
18
|
#
|
|
10
|
-
# |
|
|
11
|
-
#
|
|
12
|
-
# |
|
|
13
|
-
# |
|
|
19
|
+
# | | |
|
|
20
|
+
# |:----------------|:-------------------------------------------------------------|
|
|
21
|
+
# | `:ipv4_only` | If `true`, IPv6 addresses are considered invalid. |
|
|
22
|
+
# | `:ipv6_only` | If `true`, IPv4 addresses are considered invalid. |
|
|
23
|
+
# | `:allow_cidr` | If `true`, CIDR notation (e.g. `10.0.0.0/24`) is allowed. |
|
|
24
|
+
# | | Defaults to `false`, so values containing `/` are rejected. |
|
|
25
|
+
# | `:no_loopback` | If `true`, loopback addresses (e.g. `127.0.0.1`, `::1`) |
|
|
26
|
+
# | | are considered invalid. |
|
|
27
|
+
# | `:no_private` | If `true`, RFC 1918 / unique local addresses (e.g. |
|
|
28
|
+
# | | `10.0.0.0/8`, `fc00::/7`) are considered invalid. |
|
|
29
|
+
# | `:no_reserved` | If `true`, reserved addresses (link-local, multicast, |
|
|
30
|
+
# | | unspecified, etc.) are considered invalid. |
|
|
31
|
+
# | `:message` | A custom message to use if the IP is invalid. |
|
|
32
|
+
# | `:allow_nil` | If `true`, `nil` values are allowed. |
|
|
33
|
+
# | `:allow_blank` | If `true`, blank values are allowed. |
|
|
14
34
|
|
|
15
35
|
class IpAddressValidator < LocalizedEachValidator
|
|
36
|
+
VERSION = IpAddressValidatorGem::VERSION
|
|
37
|
+
|
|
16
38
|
error_key :invalid_ip
|
|
17
39
|
|
|
18
40
|
# @private
|
|
19
|
-
def valid?(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
41
|
+
def valid?(_record, _attribute, value)
|
|
42
|
+
return false unless value.is_a?(String)
|
|
43
|
+
return false if !options[:allow_cidr] && value.include?("/")
|
|
44
|
+
|
|
45
|
+
ip =
|
|
46
|
+
begin
|
|
47
|
+
IPAddr.new(value)
|
|
48
|
+
rescue IPAddr::Error, ArgumentError
|
|
49
|
+
return false
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
return false if ip.ipv4? && options[:ipv6_only]
|
|
53
|
+
return false if ip.ipv6? && options[:ipv4_only]
|
|
54
|
+
|
|
55
|
+
return false if options[:no_loopback] && ip.loopback?
|
|
56
|
+
return false if options[:no_private] && private_ip?(ip)
|
|
57
|
+
return false if options[:no_reserved] && reserved_ip?(ip)
|
|
58
|
+
|
|
59
|
+
true
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
private
|
|
63
|
+
|
|
64
|
+
def private_ip?(ip)
|
|
65
|
+
return true if ip.respond_to?(:private?) && ip.private?
|
|
66
|
+
|
|
67
|
+
# Fallback for older Ruby versions: cover RFC 1918 + unique local IPv6.
|
|
68
|
+
if ip.ipv4?
|
|
69
|
+
%w[10.0.0.0/8 172.16.0.0/12 192.168.0.0/16].any? { |r| IPAddr.new(r).include?(ip) }
|
|
70
|
+
elsif ip.ipv6?
|
|
71
|
+
IPAddr.new("fc00::/7").include?(ip)
|
|
72
|
+
else
|
|
73
|
+
false
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def reserved_ip?(ip)
|
|
78
|
+
return true if ip.link_local?
|
|
79
|
+
return true if ip.respond_to?(:multicast?) ? ip.multicast? : false
|
|
80
|
+
return true if ip.to_s == "0.0.0.0" || ip.to_s == "::"
|
|
81
|
+
|
|
82
|
+
if ip.ipv4?
|
|
83
|
+
reserved_v4 = %w[
|
|
84
|
+
0.0.0.0/8
|
|
85
|
+
100.64.0.0/10
|
|
86
|
+
169.254.0.0/16
|
|
87
|
+
192.0.0.0/24
|
|
88
|
+
192.0.2.0/24
|
|
89
|
+
198.18.0.0/15
|
|
90
|
+
198.51.100.0/24
|
|
91
|
+
203.0.113.0/24
|
|
92
|
+
224.0.0.0/4
|
|
93
|
+
240.0.0.0/4
|
|
94
|
+
255.255.255.255/32
|
|
95
|
+
]
|
|
96
|
+
reserved_v4.any? { |r| IPAddr.new(r).include?(ip) }
|
|
97
|
+
elsif ip.ipv6?
|
|
98
|
+
reserved_v6 = %w[
|
|
99
|
+
::/128
|
|
100
|
+
::1/128
|
|
101
|
+
ff00::/8
|
|
102
|
+
2001:db8::/32
|
|
103
|
+
100::/64
|
|
104
|
+
]
|
|
105
|
+
reserved_v6.any? { |r| IPAddr.new(r).include?(ip) }
|
|
106
|
+
else
|
|
107
|
+
false
|
|
25
108
|
end
|
|
26
|
-
|
|
27
|
-
return false if ip.ipv4? and options[:ipv6_only]
|
|
28
|
-
return false if ip.ipv6? and options[:ipv4_only]
|
|
29
|
-
|
|
30
|
-
return true
|
|
31
109
|
end
|
|
32
110
|
end
|
metadata
CHANGED
|
@@ -1,127 +1,127 @@
|
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ip_address_validator
|
|
3
|
-
version: !ruby/object:Gem::Version
|
|
4
|
-
|
|
5
|
-
segments:
|
|
6
|
-
- 1
|
|
7
|
-
- 0
|
|
8
|
-
- 0
|
|
9
|
-
version: 1.0.0
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 2.0.0
|
|
10
5
|
platform: ruby
|
|
11
|
-
authors:
|
|
6
|
+
authors:
|
|
12
7
|
- Tim Morgan
|
|
13
|
-
autorequire:
|
|
14
8
|
bindir: bin
|
|
15
9
|
cert_chain: []
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies:
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: activemodel
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
- - ">="
|
|
17
|
+
- !ruby/object:Gem::Version
|
|
18
|
+
version: '6.1'
|
|
19
|
+
type: :runtime
|
|
20
|
+
prerelease: false
|
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
22
|
+
requirements:
|
|
23
|
+
- - ">="
|
|
24
|
+
- !ruby/object:Gem::Version
|
|
25
|
+
version: '6.1'
|
|
26
|
+
- !ruby/object:Gem::Dependency
|
|
21
27
|
name: localized_each_validator
|
|
22
|
-
requirement:
|
|
23
|
-
|
|
24
|
-
requirements:
|
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
|
29
|
+
requirements:
|
|
25
30
|
- - ">="
|
|
26
|
-
- !ruby/object:Gem::Version
|
|
27
|
-
|
|
28
|
-
- 1
|
|
29
|
-
- 0
|
|
30
|
-
- 1
|
|
31
|
-
version: 1.0.1
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '2.0'
|
|
32
33
|
type: :runtime
|
|
33
34
|
prerelease: false
|
|
34
|
-
version_requirements:
|
|
35
|
-
|
|
36
|
-
name: jeweler
|
|
37
|
-
requirement: &id002 !ruby/object:Gem::Requirement
|
|
38
|
-
none: false
|
|
39
|
-
requirements:
|
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
40
37
|
- - ">="
|
|
41
|
-
- !ruby/object:Gem::Version
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: '2.0'
|
|
40
|
+
- !ruby/object:Gem::Dependency
|
|
41
|
+
name: rake
|
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
|
43
|
+
requirements:
|
|
44
|
+
- - "~>"
|
|
45
|
+
- !ruby/object:Gem::Version
|
|
46
|
+
version: '13.0'
|
|
45
47
|
type: :development
|
|
46
48
|
prerelease: false
|
|
47
|
-
version_requirements:
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
50
|
+
requirements:
|
|
51
|
+
- - "~>"
|
|
52
|
+
- !ruby/object:Gem::Version
|
|
53
|
+
version: '13.0'
|
|
54
|
+
- !ruby/object:Gem::Dependency
|
|
55
|
+
name: rspec
|
|
56
|
+
requirement: !ruby/object:Gem::Requirement
|
|
57
|
+
requirements:
|
|
58
|
+
- - "~>"
|
|
59
|
+
- !ruby/object:Gem::Version
|
|
60
|
+
version: '3.0'
|
|
58
61
|
type: :development
|
|
59
62
|
prerelease: false
|
|
60
|
-
version_requirements:
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
63
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
64
|
+
requirements:
|
|
65
|
+
- - "~>"
|
|
66
|
+
- !ruby/object:Gem::Version
|
|
67
|
+
version: '3.0'
|
|
68
|
+
- !ruby/object:Gem::Dependency
|
|
69
|
+
name: standard
|
|
70
|
+
requirement: !ruby/object:Gem::Requirement
|
|
71
|
+
requirements:
|
|
66
72
|
- - ">="
|
|
67
|
-
- !ruby/object:Gem::Version
|
|
68
|
-
|
|
69
|
-
- 0
|
|
70
|
-
version: "0"
|
|
73
|
+
- !ruby/object:Gem::Version
|
|
74
|
+
version: '1.0'
|
|
71
75
|
type: :development
|
|
72
76
|
prerelease: false
|
|
73
|
-
version_requirements:
|
|
74
|
-
|
|
75
|
-
|
|
77
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
78
|
+
requirements:
|
|
79
|
+
- - ">="
|
|
80
|
+
- !ruby/object:Gem::Version
|
|
81
|
+
version: '1.0'
|
|
82
|
+
description: A localizable EachValidator for IPv4 and IPv6 address fields, with optional
|
|
83
|
+
restrictions on CIDR, loopback, private, and reserved ranges.
|
|
84
|
+
email:
|
|
85
|
+
- git@timothymorgan.info
|
|
76
86
|
executables: []
|
|
77
|
-
|
|
78
87
|
extensions: []
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
-
|
|
82
|
-
-
|
|
83
|
-
|
|
84
|
-
- .
|
|
85
|
-
-
|
|
86
|
-
-
|
|
88
|
+
extra_rdoc_files: []
|
|
89
|
+
files:
|
|
90
|
+
- ".document"
|
|
91
|
+
- ".rspec"
|
|
92
|
+
- ".rubocop.yml"
|
|
93
|
+
- ".ruby-gemset"
|
|
94
|
+
- ".ruby-version"
|
|
95
|
+
- CHANGELOG.md
|
|
87
96
|
- LICENSE
|
|
88
|
-
- README.
|
|
97
|
+
- README.md
|
|
89
98
|
- Rakefile
|
|
90
|
-
- VERSION
|
|
91
99
|
- ip_address_validator.gemspec
|
|
92
100
|
- lib/ip_address_validator.rb
|
|
93
|
-
|
|
94
|
-
homepage:
|
|
95
|
-
licenses:
|
|
96
|
-
|
|
97
|
-
|
|
101
|
+
- lib/ip_address_validator/version.rb
|
|
102
|
+
homepage: https://github.com/RISCfuture/ip_address_validator
|
|
103
|
+
licenses:
|
|
104
|
+
- MIT
|
|
105
|
+
metadata:
|
|
106
|
+
source_code_uri: https://github.com/RISCfuture/ip_address_validator
|
|
107
|
+
changelog_uri: https://github.com/RISCfuture/ip_address_validator/blob/master/CHANGELOG.md
|
|
108
|
+
bug_tracker_uri: https://github.com/RISCfuture/ip_address_validator/issues
|
|
109
|
+
rubygems_mfa_required: 'true'
|
|
98
110
|
rdoc_options: []
|
|
99
|
-
|
|
100
|
-
require_paths:
|
|
111
|
+
require_paths:
|
|
101
112
|
- lib
|
|
102
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
|
103
|
-
|
|
104
|
-
requirements:
|
|
113
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
114
|
+
requirements:
|
|
105
115
|
- - ">="
|
|
106
|
-
- !ruby/object:Gem::Version
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
version: "0"
|
|
111
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
112
|
-
none: false
|
|
113
|
-
requirements:
|
|
116
|
+
- !ruby/object:Gem::Version
|
|
117
|
+
version: '3.1'
|
|
118
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
119
|
+
requirements:
|
|
114
120
|
- - ">="
|
|
115
|
-
- !ruby/object:Gem::Version
|
|
116
|
-
|
|
117
|
-
- 0
|
|
118
|
-
version: "0"
|
|
121
|
+
- !ruby/object:Gem::Version
|
|
122
|
+
version: '0'
|
|
119
123
|
requirements: []
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
signing_key:
|
|
124
|
-
specification_version: 3
|
|
125
|
-
summary: Simple IP address validation in Rails 3
|
|
124
|
+
rubygems_version: 4.0.11
|
|
125
|
+
specification_version: 4
|
|
126
|
+
summary: Simple IP address validator for ActiveModel
|
|
126
127
|
test_files: []
|
|
127
|
-
|
data/Gemfile
DELETED
data/Gemfile.lock
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
GEM
|
|
2
|
-
remote: http://rubygems.org/
|
|
3
|
-
specs:
|
|
4
|
-
RedCloth (4.2.3)
|
|
5
|
-
activemodel (3.0.3)
|
|
6
|
-
activesupport (= 3.0.3)
|
|
7
|
-
builder (~> 2.1.2)
|
|
8
|
-
i18n (~> 0.4)
|
|
9
|
-
activerecord (3.0.3)
|
|
10
|
-
activemodel (= 3.0.3)
|
|
11
|
-
activesupport (= 3.0.3)
|
|
12
|
-
arel (~> 2.0.2)
|
|
13
|
-
tzinfo (~> 0.3.23)
|
|
14
|
-
activesupport (3.0.3)
|
|
15
|
-
arel (2.0.3)
|
|
16
|
-
builder (2.1.2)
|
|
17
|
-
git (1.2.5)
|
|
18
|
-
i18n (0.4.2)
|
|
19
|
-
jeweler (1.5.1)
|
|
20
|
-
bundler (~> 1.0.0)
|
|
21
|
-
git (>= 1.2.5)
|
|
22
|
-
rake
|
|
23
|
-
localized_each_validator (1.0.1)
|
|
24
|
-
activerecord (>= 3.0)
|
|
25
|
-
activesupport (>= 3.0)
|
|
26
|
-
rake (0.8.7)
|
|
27
|
-
tzinfo (0.3.23)
|
|
28
|
-
yard (0.6.2)
|
|
29
|
-
|
|
30
|
-
PLATFORMS
|
|
31
|
-
ruby
|
|
32
|
-
|
|
33
|
-
DEPENDENCIES
|
|
34
|
-
RedCloth
|
|
35
|
-
jeweler
|
|
36
|
-
localized_each_validator (>= 1.0.1)
|
|
37
|
-
yard
|
data/README.textile
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
h1. ip_address_validator -- Simple IP validator for Rails 3
|
|
2
|
-
|
|
3
|
-
| *Author* | Tim Morgan |
|
|
4
|
-
| *Version* | 1.0 (Oct 30, 2010) |
|
|
5
|
-
| *License* | Released under the MIT license. |
|
|
6
|
-
|
|
7
|
-
h2. About
|
|
8
|
-
|
|
9
|
-
This gem adds a very simple IP address format validator to be used with
|
|
10
|
-
ActiveRecord models in Rails 3.0. It supports localized error messages.
|
|
11
|
-
|
|
12
|
-
h2. Installation
|
|
13
|
-
|
|
14
|
-
Add the gem to your project's @Gemfile@:
|
|
15
|
-
|
|
16
|
-
<pre><code>
|
|
17
|
-
gem 'ip_address_validator'
|
|
18
|
-
</code></pre>
|
|
19
|
-
|
|
20
|
-
h2. Usage
|
|
21
|
-
|
|
22
|
-
This gem is an @EachValidator@, and thus is used with the @validates@ method:
|
|
23
|
-
|
|
24
|
-
<pre><code>
|
|
25
|
-
class User < ActiveRecord::Base
|
|
26
|
-
validates :last_login_ip,
|
|
27
|
-
ip_address: true
|
|
28
|
-
end
|
|
29
|
-
</code></pre>
|
|
30
|
-
|
|
31
|
-
The localization key is @invalid_ip@, and can be specified in the localized
|
|
32
|
-
YAML file like so:
|
|
33
|
-
|
|
34
|
-
<pre><code>
|
|
35
|
-
en:
|
|
36
|
-
activerecord:
|
|
37
|
-
errors:
|
|
38
|
-
messages:
|
|
39
|
-
invalid_ip: IP address is invalid.
|
|
40
|
-
</code></pre>
|
data/VERSION
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
1.0.0
|