validates_host 0.3.0 → 1.3.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/.gitignore +5 -4
- data/.rubocop.yml +57 -0
- data/.ruby-gemset +1 -0
- data/.travis.yml +45 -4
- data/Gemfile +3 -1
- data/README.md +15 -9
- data/Rakefile +9 -4
- data/gemfiles/Gemfile.rails3 +6 -0
- data/gemfiles/Gemfile.rails4 +5 -0
- data/gemfiles/Gemfile.rails5 +5 -0
- data/gemfiles/Gemfile.rails6 +5 -0
- data/lib/validates_host.rb +14 -5
- data/lib/validates_host/domain_name.rb +15 -0
- data/lib/validates_host/domain_name_validator.rb +10 -17
- data/lib/validates_host/host_name.rb +15 -0
- data/lib/validates_host/host_name_validator.rb +10 -17
- data/lib/validates_host/ip.rb +17 -0
- data/lib/validates_host/ip_validator.rb +10 -17
- data/lib/validates_host/{shoulda-matchers/domain_name_matcher.rb → require_a_valid_domain_name_matcher.rb} +9 -11
- data/lib/validates_host/{shoulda-matchers/host_name_matcher.rb → require_a_valid_host_name_matcher.rb} +9 -11
- data/lib/validates_host/{shoulda-matchers/ip_matcher.rb → require_a_valid_ip_matcher.rb} +9 -11
- data/lib/validates_host/{shoulda-matchers/subnet_matcher.rb → require_a_valid_subnet_matcher.rb} +9 -11
- data/lib/validates_host/subnet.rb +15 -0
- data/lib/validates_host/subnet_validator.rb +10 -17
- data/lib/validates_host/version.rb +3 -1
- data/spec/fake_app/server.rb +19 -5
- data/spec/fake_app/subnet.rb +11 -3
- data/spec/shoulda/matchers/active_model/require_a_valid_domain_name_matcher_spec.rb +23 -0
- data/spec/shoulda/matchers/active_model/require_a_valid_host_name_matcher_spec.rb +23 -0
- data/spec/shoulda/matchers/active_model/require_a_valid_ip_matcher_spec.rb +23 -0
- data/spec/shoulda/matchers/active_model/require_a_valid_subnet_matcher_spec.rb +23 -0
- data/spec/spec_helper.rb +11 -8
- data/spec/validates_host/domain_name_validator_spec.rb +23 -22
- data/spec/validates_host/host_name_validator_spec.rb +23 -22
- data/spec/validates_host/ip_validator_spec.rb +38 -22
- data/spec/validates_host/subnet_validator_spec.rb +23 -22
- data/validates_host.gemspec +23 -19
- metadata +84 -95
- data/lib/validates_host/remarkable.rb +0 -4
- data/lib/validates_host/remarkable/domain_name_matcher.rb +0 -29
- data/lib/validates_host/remarkable/host_name_matcher.rb +0 -29
- data/lib/validates_host/remarkable/ip_matcher.rb +0 -29
- data/lib/validates_host/remarkable/subnet_matcher.rb +0 -29
- data/lib/validates_host/shoulda-matchers.rb +0 -4
- data/spec/fake_app/db/migrations/create_servers.rb +0 -13
- data/spec/fake_app/db/migrations/create_subnets.rb +0 -12
- data/spec/validates_host/remarkable/domain_name_matcher_spec.rb +0 -20
- data/spec/validates_host/remarkable/host_name_matcher_spec.rb +0 -20
- data/spec/validates_host/remarkable/ip_matcher_spec.rb +0 -20
- data/spec/validates_host/remarkable/subnet_matcher_spec.rb +0 -20
- data/spec/validates_host/shoulda-matchers/domain_name_matcher_spec.rb +0 -20
- data/spec/validates_host/shoulda-matchers/host_name_matcher_spec.rb +0 -20
- data/spec/validates_host/shoulda-matchers/ip_matcher_spec.rb +0 -20
- data/spec/validates_host/shoulda-matchers/subnet_matcher_spec.rb +0 -20
@@ -1,29 +0,0 @@
|
|
1
|
-
require 'remarkable/active_model'
|
2
|
-
|
3
|
-
module Remarkable
|
4
|
-
module ActiveModel
|
5
|
-
module Matchers
|
6
|
-
class DomainNameMatcher < Remarkable::ActiveModel::Base
|
7
|
-
arguments :domain_name
|
8
|
-
|
9
|
-
collection_assertions :accept_valid_value?, :reject_valid_value?
|
10
|
-
|
11
|
-
protected
|
12
|
-
|
13
|
-
def accept_valid_value?
|
14
|
-
@subject.domain_name = 'example.com'
|
15
|
-
@subject.valid?.errors[:domain_name].should == []
|
16
|
-
end
|
17
|
-
|
18
|
-
def reject_valid_value?
|
19
|
-
@subject.domain_name = 'example'
|
20
|
-
@subject.valid?.errors[:domain_name].should == ['is invalid']
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
def require_a_valid_domain_name(*args, &block)
|
25
|
-
DomainNameMatcher.new(*args, &block).spec(self)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
require 'remarkable/active_model'
|
2
|
-
|
3
|
-
module Remarkable
|
4
|
-
module ActiveModel
|
5
|
-
module Matchers
|
6
|
-
class HostNameMatcher < Remarkable::ActiveModel::Base
|
7
|
-
arguments :host_name
|
8
|
-
|
9
|
-
collection_assertions :accept_valid_value?, :reject_valid_value?
|
10
|
-
|
11
|
-
protected
|
12
|
-
|
13
|
-
def accept_valid_value?
|
14
|
-
@subject.domain_name = 'bd01'
|
15
|
-
@subject.valid?.errors[:host_name].should == []
|
16
|
-
end
|
17
|
-
|
18
|
-
def reject_valid_value?
|
19
|
-
@subject.domain_name = '01'
|
20
|
-
@subject.valid?.errors[:host_name].should == ['is invalid']
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
def require_a_valid_domain_name(*args, &block)
|
25
|
-
HostNameMatcher.new(*args, &block).spec(self)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
require 'remarkable/active_model'
|
2
|
-
|
3
|
-
module Remarkable
|
4
|
-
module ActiveModel
|
5
|
-
module Matchers
|
6
|
-
class IpMatcher < Remarkable::ActiveModel::Base
|
7
|
-
arguments :ip
|
8
|
-
|
9
|
-
collection_assertions :accept_valid_value?, :reject_valid_value?
|
10
|
-
|
11
|
-
protected
|
12
|
-
|
13
|
-
def accept_valid_value?
|
14
|
-
@subject.domain_name = '10.10.10.1'
|
15
|
-
@subject.valid?.errors[:ip].should == []
|
16
|
-
end
|
17
|
-
|
18
|
-
def reject_valid_value?
|
19
|
-
@subject.domain_name = '01'
|
20
|
-
@subject.valid?.errors[:ip].should == ['is invalid']
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
def require_a_valid_ip(*args, &block)
|
25
|
-
IpMatcher.new(*args, &block).spec(self)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
require 'remarkable/active_model'
|
2
|
-
|
3
|
-
module Remarkable
|
4
|
-
module ActiveModel
|
5
|
-
module Matchers
|
6
|
-
class SubnetMatcher < Remarkable::ActiveModel::Base
|
7
|
-
arguments :value
|
8
|
-
|
9
|
-
collection_assertions :accept_valid_value?, :reject_valid_value?
|
10
|
-
|
11
|
-
protected
|
12
|
-
|
13
|
-
def accept_valid_value?
|
14
|
-
@subject.value = '10.10.10.1/28'
|
15
|
-
@subject.valid?.errors[:value].should == []
|
16
|
-
end
|
17
|
-
|
18
|
-
def reject_valid_value?
|
19
|
-
@subject.value = '01'
|
20
|
-
@subject.valid?.errors[:value].should == ['is invalid']
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
def require_a_valid_domain_name(*args, &block)
|
25
|
-
SubnetMatcher.new(*args, &block).spec(self)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'remarkable/active_model'
|
3
|
-
|
4
|
-
describe Remarkable::ActiveModel::Matchers::DomainNameMatcher do
|
5
|
-
before :each do
|
6
|
-
@server = Server.new
|
7
|
-
end
|
8
|
-
|
9
|
-
it "should accept on domain_name" do
|
10
|
-
@server.should require_a_valid_domain_name(:domain_name)
|
11
|
-
end
|
12
|
-
|
13
|
-
it "should accept without a specified attribute" do
|
14
|
-
@server.should require_a_valid_domain_name
|
15
|
-
end
|
16
|
-
|
17
|
-
it "should reject on host_name" do
|
18
|
-
@server.should_not require_a_valid_domain_name(:host_name)
|
19
|
-
end
|
20
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'remarkable/active_model'
|
3
|
-
|
4
|
-
describe Remarkable::ActiveModel::Matchers::HostNameMatcher do
|
5
|
-
before :each do
|
6
|
-
@server = Server.new
|
7
|
-
end
|
8
|
-
|
9
|
-
it "should accept on host_name" do
|
10
|
-
@server.should require_a_valid_host_name(:host_name)
|
11
|
-
end
|
12
|
-
|
13
|
-
it "should accept without a specified attribute" do
|
14
|
-
@server.should require_a_valid_domain_name
|
15
|
-
end
|
16
|
-
|
17
|
-
it "should reject on domain_name" do
|
18
|
-
@server.should_not require_a_valid_host_name(:domain_name)
|
19
|
-
end
|
20
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'remarkable/active_model'
|
3
|
-
|
4
|
-
describe Remarkable::ActiveModel::Matchers::IpMatcher do
|
5
|
-
before :each do
|
6
|
-
@server = Server.new
|
7
|
-
end
|
8
|
-
|
9
|
-
it "should accept on ip" do
|
10
|
-
@server.should require_a_valid_ip(:ip)
|
11
|
-
end
|
12
|
-
|
13
|
-
it "should accept without a specified attribute" do
|
14
|
-
@server.should require_a_valid_ip
|
15
|
-
end
|
16
|
-
|
17
|
-
it "should reject on domain_name" do
|
18
|
-
@server.should_not require_a_valid_ip(:domain_name)
|
19
|
-
end
|
20
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'remarkable/active_model'
|
3
|
-
|
4
|
-
describe Remarkable::ActiveModel::Matchers::SubnetMatcher do
|
5
|
-
before :each do
|
6
|
-
@subnet = Subnet.new
|
7
|
-
end
|
8
|
-
|
9
|
-
it "should accept on value" do
|
10
|
-
@subnet.should require_a_valid_subnet(:value)
|
11
|
-
end
|
12
|
-
|
13
|
-
it "should accept without a specified attribute" do
|
14
|
-
@subnet.should require_a_valid_subnet
|
15
|
-
end
|
16
|
-
|
17
|
-
it "should reject on id" do
|
18
|
-
@subnet.should_not require_a_valid_subnet(:id)
|
19
|
-
end
|
20
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'shoulda-matchers'
|
3
|
-
|
4
|
-
describe Shoulda::Matchers::ActiveModel::DomainNameMatcher do
|
5
|
-
before :each do
|
6
|
-
@server = Server.new
|
7
|
-
end
|
8
|
-
|
9
|
-
it "should accept on domain_name" do
|
10
|
-
@server.should require_a_valid_domain_name(:domain_name)
|
11
|
-
end
|
12
|
-
|
13
|
-
it "should accept without a specified attribute" do
|
14
|
-
@server.should require_a_valid_domain_name
|
15
|
-
end
|
16
|
-
|
17
|
-
it "should reject on host_name" do
|
18
|
-
@server.should_not require_a_valid_domain_name(:host_name)
|
19
|
-
end
|
20
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'shoulda-matchers'
|
3
|
-
|
4
|
-
describe Shoulda::Matchers::ActiveModel::HostNameMatcher do
|
5
|
-
before :each do
|
6
|
-
@server = Server.new
|
7
|
-
end
|
8
|
-
|
9
|
-
it "should accept on host_name" do
|
10
|
-
@server.should require_a_valid_host_name(:host_name)
|
11
|
-
end
|
12
|
-
|
13
|
-
it "should accept without a specified attribute" do
|
14
|
-
@server.should require_a_valid_host_name
|
15
|
-
end
|
16
|
-
|
17
|
-
it "should reject on domain_name" do
|
18
|
-
@server.should_not require_a_valid_host_name(:domain_name)
|
19
|
-
end
|
20
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'shoulda-matchers'
|
3
|
-
|
4
|
-
describe Shoulda::Matchers::ActiveModel::IpMatcher do
|
5
|
-
before :each do
|
6
|
-
@server = Server.new
|
7
|
-
end
|
8
|
-
|
9
|
-
it "should accept on ip" do
|
10
|
-
@server.should require_a_valid_ip(:ip)
|
11
|
-
end
|
12
|
-
|
13
|
-
it "should accept without a specified attribute" do
|
14
|
-
@server.should require_a_valid_ip
|
15
|
-
end
|
16
|
-
|
17
|
-
it "should reject on domain_name" do
|
18
|
-
@server.should_not require_a_valid_ip(:domain_name)
|
19
|
-
end
|
20
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'shoulda-matchers'
|
3
|
-
|
4
|
-
describe Shoulda::Matchers::ActiveModel::SubnetMatcher do
|
5
|
-
before :each do
|
6
|
-
@subnet = Subnet.new
|
7
|
-
end
|
8
|
-
|
9
|
-
it "should accept on value" do
|
10
|
-
@subnet.should require_a_valid_subnet(:value)
|
11
|
-
end
|
12
|
-
|
13
|
-
it "should accept without a specified attribute" do
|
14
|
-
@subnet.should require_a_valid_subnet
|
15
|
-
end
|
16
|
-
|
17
|
-
it "should reject on id" do
|
18
|
-
@subnet.should_not require_a_valid_subnet(:id)
|
19
|
-
end
|
20
|
-
end
|