validates_host 0.3.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +5 -4
  3. data/.rubocop.yml +57 -0
  4. data/.ruby-gemset +1 -0
  5. data/.travis.yml +45 -4
  6. data/Gemfile +3 -1
  7. data/README.md +15 -9
  8. data/Rakefile +9 -4
  9. data/gemfiles/Gemfile.rails3 +6 -0
  10. data/gemfiles/Gemfile.rails4 +5 -0
  11. data/gemfiles/Gemfile.rails5 +5 -0
  12. data/gemfiles/Gemfile.rails6 +5 -0
  13. data/lib/validates_host.rb +14 -5
  14. data/lib/validates_host/domain_name.rb +15 -0
  15. data/lib/validates_host/domain_name_validator.rb +10 -17
  16. data/lib/validates_host/host_name.rb +15 -0
  17. data/lib/validates_host/host_name_validator.rb +10 -17
  18. data/lib/validates_host/ip.rb +17 -0
  19. data/lib/validates_host/ip_validator.rb +10 -17
  20. data/lib/validates_host/{shoulda-matchers/domain_name_matcher.rb → require_a_valid_domain_name_matcher.rb} +9 -11
  21. data/lib/validates_host/{shoulda-matchers/host_name_matcher.rb → require_a_valid_host_name_matcher.rb} +9 -11
  22. data/lib/validates_host/{shoulda-matchers/ip_matcher.rb → require_a_valid_ip_matcher.rb} +9 -11
  23. data/lib/validates_host/{shoulda-matchers/subnet_matcher.rb → require_a_valid_subnet_matcher.rb} +9 -11
  24. data/lib/validates_host/subnet.rb +15 -0
  25. data/lib/validates_host/subnet_validator.rb +10 -17
  26. data/lib/validates_host/version.rb +3 -1
  27. data/spec/fake_app/server.rb +19 -5
  28. data/spec/fake_app/subnet.rb +11 -3
  29. data/spec/shoulda/matchers/active_model/require_a_valid_domain_name_matcher_spec.rb +23 -0
  30. data/spec/shoulda/matchers/active_model/require_a_valid_host_name_matcher_spec.rb +23 -0
  31. data/spec/shoulda/matchers/active_model/require_a_valid_ip_matcher_spec.rb +23 -0
  32. data/spec/shoulda/matchers/active_model/require_a_valid_subnet_matcher_spec.rb +23 -0
  33. data/spec/spec_helper.rb +11 -8
  34. data/spec/validates_host/domain_name_validator_spec.rb +23 -22
  35. data/spec/validates_host/host_name_validator_spec.rb +23 -22
  36. data/spec/validates_host/ip_validator_spec.rb +38 -22
  37. data/spec/validates_host/subnet_validator_spec.rb +23 -22
  38. data/validates_host.gemspec +23 -19
  39. metadata +84 -95
  40. data/lib/validates_host/remarkable.rb +0 -4
  41. data/lib/validates_host/remarkable/domain_name_matcher.rb +0 -29
  42. data/lib/validates_host/remarkable/host_name_matcher.rb +0 -29
  43. data/lib/validates_host/remarkable/ip_matcher.rb +0 -29
  44. data/lib/validates_host/remarkable/subnet_matcher.rb +0 -29
  45. data/lib/validates_host/shoulda-matchers.rb +0 -4
  46. data/spec/fake_app/db/migrations/create_servers.rb +0 -13
  47. data/spec/fake_app/db/migrations/create_subnets.rb +0 -12
  48. data/spec/validates_host/remarkable/domain_name_matcher_spec.rb +0 -20
  49. data/spec/validates_host/remarkable/host_name_matcher_spec.rb +0 -20
  50. data/spec/validates_host/remarkable/ip_matcher_spec.rb +0 -20
  51. data/spec/validates_host/remarkable/subnet_matcher_spec.rb +0 -20
  52. data/spec/validates_host/shoulda-matchers/domain_name_matcher_spec.rb +0 -20
  53. data/spec/validates_host/shoulda-matchers/host_name_matcher_spec.rb +0 -20
  54. data/spec/validates_host/shoulda-matchers/ip_matcher_spec.rb +0 -20
  55. data/spec/validates_host/shoulda-matchers/subnet_matcher_spec.rb +0 -20
@@ -1,4 +0,0 @@
1
- require 'validates_host/remarkable/domain_name_matcher'
2
- require 'validates_host/remarkable/host_name_matcher'
3
- require 'validates_host/remarkable/ip_matcher'
4
- require 'validates_host/remarkable/subnet_matcher'
@@ -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,4 +0,0 @@
1
- require 'validates_host/shoulda-matchers/domain_name_matcher'
2
- require 'validates_host/shoulda-matchers/host_name_matcher'
3
- require 'validates_host/shoulda-matchers/ip_matcher'
4
- require 'validates_host/shoulda-matchers/subnet_matcher'
@@ -1,13 +0,0 @@
1
- class CreateServers < ActiveRecord::Migration
2
- def self.up
3
- create_table :servers do |s|
4
- s.string :domain_name
5
- s.string :host_name
6
- s.string :ip
7
- end
8
- end
9
-
10
- def self.down
11
- drop_table :servers
12
- end
13
- end
@@ -1,12 +0,0 @@
1
- class CreateSubnets < ActiveRecord::Migration
2
- def self.up
3
- create_table :subnets do |s|
4
- s.integer :id
5
- s.string :value
6
- end
7
- end
8
-
9
- def self.down
10
- drop_table :subnets
11
- end
12
- 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