validates_host 1.1.0 → 1.2.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 +5 -5
 - data/.rubocop.yml +53 -0
 - data/.travis.yml +26 -17
 - data/Gemfile +3 -1
 - data/README.md +1 -1
 - data/Rakefile +9 -4
 - data/lib/validates_host.rb +3 -1
 - data/lib/validates_host/domain_name.rb +5 -2
 - data/lib/validates_host/domain_name_validator.rb +3 -1
 - data/lib/validates_host/host_name.rb +4 -1
 - data/lib/validates_host/host_name_validator.rb +3 -1
 - data/lib/validates_host/ip.rb +10 -5
 - data/lib/validates_host/ip_validator.rb +3 -1
 - data/lib/validates_host/require_a_valid_domain_name_matcher.rb +7 -5
 - data/lib/validates_host/require_a_valid_host_name_matcher.rb +7 -5
 - data/lib/validates_host/require_a_valid_ip_matcher.rb +7 -5
 - data/lib/validates_host/require_a_valid_subnet_matcher.rb +7 -5
 - data/lib/validates_host/subnet.rb +5 -2
 - data/lib/validates_host/subnet_validator.rb +3 -1
 - data/lib/validates_host/version.rb +4 -2
 - data/spec/fake_app/server.rb +6 -4
 - data/spec/fake_app/subnet.rb +4 -8
 - 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 +3 -1
 - data/spec/validates_host/domain_name_validator_spec.rb +21 -18
 - data/spec/validates_host/host_name_validator_spec.rb +21 -18
 - data/spec/validates_host/ip_validator_spec.rb +37 -19
 - data/spec/validates_host/subnet_validator_spec.rb +21 -18
 - data/validates_host.gemspec +13 -10
 - metadata +42 -15
 - data/.ruby-version +0 -1
 - data/spec/validates_host/require_a_valid_domain_name_matcher_spec.rb +0 -23
 - data/spec/validates_host/require_a_valid_host_name_matcher_spec.rb +0 -23
 - data/spec/validates_host/require_a_valid_ip_matcher_spec.rb +0 -23
 - data/spec/validates_host/require_a_valid_subnet_matcher_spec.rb +0 -23
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 2 
     | 
    
         
            +
            SHA256:
         
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: f5b11543c72bb9ea5223f7f216d24f79606ca13e2f9d97967718132ef9589158
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 3338ae72f989b7fa89cc546918519b69cd2000ef0c081a14afe465720ce0ae4f
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: e4146e5334ec9aa078d6f715f225296e73625a10c3508bfa67bbaca3a85092326049873ae7cf8a7d0a5cec4bbbdd5a04c262bc1d7b70e6c100b8101d0263e755
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 8d122306cf4753d4e077a0b76c92d5f8da7c9623f17cf1ff3c5f40368c42794f3da1ccb02e2cb66d68e923cd767e367fcfbfc63585bf5082780a7f97454b1530
         
     | 
    
        data/.rubocop.yml
    ADDED
    
    | 
         @@ -0,0 +1,53 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require: rubocop-rspec
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            Layout/EmptyLinesAroundAttributeAccessor:
         
     | 
| 
      
 4 
     | 
    
         
            +
              Enabled: true
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            Layout/LineLength:
         
     | 
| 
      
 7 
     | 
    
         
            +
              Max: 150
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            Layout/SpaceAroundMethodCallOperator:
         
     | 
| 
      
 10 
     | 
    
         
            +
              Enabled: true
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
            Lint/DeprecatedOpenSSLConstant:
         
     | 
| 
      
 13 
     | 
    
         
            +
              Enabled: true
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
            Lint/MixedRegexpCaptureTypes:
         
     | 
| 
      
 16 
     | 
    
         
            +
              Enabled: true
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
            Lint/RaiseException:
         
     | 
| 
      
 19 
     | 
    
         
            +
              Enabled: true
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
            Lint/StructNewOverride:
         
     | 
| 
      
 22 
     | 
    
         
            +
              Enabled: true
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
            Metrics/BlockLength:
         
     | 
| 
      
 25 
     | 
    
         
            +
              Enabled: false
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
            Style/Documentation:
         
     | 
| 
      
 28 
     | 
    
         
            +
              Enabled: false
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
            Style/ExponentialNotation:
         
     | 
| 
      
 31 
     | 
    
         
            +
              Enabled: true
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
            Style/HashEachMethods:
         
     | 
| 
      
 34 
     | 
    
         
            +
              Enabled: true
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
            Style/HashTransformKeys:
         
     | 
| 
      
 37 
     | 
    
         
            +
              Enabled: true
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
            Style/HashTransformValues:
         
     | 
| 
      
 40 
     | 
    
         
            +
              Enabled: true
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
            Style/MixinUsage:
         
     | 
| 
      
 43 
     | 
    
         
            +
              Exclude:
         
     | 
| 
      
 44 
     | 
    
         
            +
                - 'spec/spec_helper.rb'
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
            Style/RedundantRegexpCharacterClass:
         
     | 
| 
      
 47 
     | 
    
         
            +
              Enabled: true
         
     | 
| 
      
 48 
     | 
    
         
            +
             
     | 
| 
      
 49 
     | 
    
         
            +
            Style/RedundantRegexpEscape:
         
     | 
| 
      
 50 
     | 
    
         
            +
              Enabled: true
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
      
 52 
     | 
    
         
            +
            Style/SlicingWithRange:
         
     | 
| 
      
 53 
     | 
    
         
            +
              Enabled: true
         
     | 
    
        data/.travis.yml
    CHANGED
    
    | 
         @@ -1,22 +1,31 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            rvm:
         
     | 
| 
       2 
     | 
    
         
            -
              - 2.0
         
     | 
| 
       3 
     | 
    
         
            -
              - 2.1
         
     | 
| 
       4 
     | 
    
         
            -
              - 2.2
         
     | 
| 
       5 
     | 
    
         
            -
              - 2.3
         
     | 
| 
       6 
     | 
    
         
            -
              - 2.4
         
     | 
| 
       7 
     | 
    
         
            -
            gemfile:
         
     | 
| 
       8 
     | 
    
         
            -
              - gemfiles/Gemfile.rails3
         
     | 
| 
       9 
     | 
    
         
            -
              - gemfiles/Gemfile.rails4
         
     | 
| 
       10 
     | 
    
         
            -
              - gemfiles/Gemfile.rails5
         
     | 
| 
       11 
1 
     | 
    
         
             
            matrix:
         
     | 
| 
       12 
     | 
    
         
            -
               
     | 
| 
       13 
     | 
    
         
            -
                - rvm: 2. 
     | 
| 
      
 2 
     | 
    
         
            +
              include:
         
     | 
| 
      
 3 
     | 
    
         
            +
                - rvm: 2.0
         
     | 
| 
       14 
4 
     | 
    
         
             
                  gemfile: gemfiles/Gemfile.rails3
         
     | 
| 
       15 
     | 
    
         
            -
                - rvm: 2. 
     | 
| 
      
 5 
     | 
    
         
            +
                - rvm: 2.0
         
     | 
| 
      
 6 
     | 
    
         
            +
                  gemfile: gemfiles/Gemfile.rails4
         
     | 
| 
      
 7 
     | 
    
         
            +
                - rvm: 2.1
         
     | 
| 
       16 
8 
     | 
    
         
             
                  gemfile: gemfiles/Gemfile.rails3
         
     | 
| 
      
 9 
     | 
    
         
            +
                - rvm: 2.1
         
     | 
| 
      
 10 
     | 
    
         
            +
                  gemfile: gemfiles/Gemfile.rails4
         
     | 
| 
      
 11 
     | 
    
         
            +
                - rvm: 2.2
         
     | 
| 
      
 12 
     | 
    
         
            +
                  gemfile: gemfiles/Gemfile.rails4
         
     | 
| 
      
 13 
     | 
    
         
            +
                - rvm: 2.2
         
     | 
| 
      
 14 
     | 
    
         
            +
                  gemfile: gemfiles/Gemfile.rails5
         
     | 
| 
      
 15 
     | 
    
         
            +
                - rvm: 2.3
         
     | 
| 
      
 16 
     | 
    
         
            +
                  gemfile: gemfiles/Gemfile.rails4
         
     | 
| 
      
 17 
     | 
    
         
            +
                - rvm: 2.3
         
     | 
| 
      
 18 
     | 
    
         
            +
                  gemfile: gemfiles/Gemfile.rails5
         
     | 
| 
      
 19 
     | 
    
         
            +
                - rvm: 2.4
         
     | 
| 
      
 20 
     | 
    
         
            +
                  gemfile: gemfiles/Gemfile.rails4
         
     | 
| 
       17 
21 
     | 
    
         
             
                - rvm: 2.4
         
     | 
| 
       18 
     | 
    
         
            -
                  gemfile: gemfiles/Gemfile.rails3
         
     | 
| 
       19 
     | 
    
         
            -
                - rvm: 2.0
         
     | 
| 
       20 
22 
     | 
    
         
             
                  gemfile: gemfiles/Gemfile.rails5
         
     | 
| 
       21 
     | 
    
         
            -
                - rvm: 2. 
     | 
| 
       22 
     | 
    
         
            -
                  gemfile: gemfiles/Gemfile. 
     | 
| 
      
 23 
     | 
    
         
            +
                - rvm: 2.5
         
     | 
| 
      
 24 
     | 
    
         
            +
                  gemfile: gemfiles/Gemfile.rails4
         
     | 
| 
      
 25 
     | 
    
         
            +
                - rvm: 2.5
         
     | 
| 
      
 26 
     | 
    
         
            +
                  gemfile: gemfiles/Gemfile.rails5
         
     | 
| 
      
 27 
     | 
    
         
            +
                - rvm: 2.6
         
     | 
| 
      
 28 
     | 
    
         
            +
                  gemfile: gemfiles/Gemfile.rails4
         
     | 
| 
      
 29 
     | 
    
         
            +
                - rvm: 2.6
         
     | 
| 
      
 30 
     | 
    
         
            +
                  gemfile: gemfiles/Gemfile.rails5
         
     | 
| 
      
 31 
     | 
    
         
            +
                  script: rake complete
         
     | 
    
        data/Gemfile
    CHANGED
    
    
    
        data/README.md
    CHANGED
    
    | 
         @@ -1,6 +1,6 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # ValidatesHost 
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
            [](http://badge.fury.io/rb/validates_host) [](http://travis-ci.org/plribeiro3000/validates_host) [](http://badge.fury.io/rb/validates_host) [](http://travis-ci.org/plribeiro3000/validates_host) [](https://coveralls.io/r/plribeiro3000/validates_host)  [](https://codeclimate.com/github/plribeiro3000/validates_host)
         
     | 
| 
       4 
4 
     | 
    
         | 
| 
       5 
5 
     | 
    
         
             
            Validates host attributes and test it in a simple way
         
     | 
| 
       6 
6 
     | 
    
         | 
    
        data/Rakefile
    CHANGED
    
    | 
         @@ -1,7 +1,12 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
             
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require 'bundler/gem_tasks'
         
     | 
| 
      
 4 
     | 
    
         
            +
            require 'rspec/core/rake_task'
         
     | 
| 
      
 5 
     | 
    
         
            +
            require 'rubocop/rake_task'
         
     | 
| 
       3 
6 
     | 
    
         | 
| 
       4 
7 
     | 
    
         
             
            RSpec::Core::RakeTask.new
         
     | 
| 
      
 8 
     | 
    
         
            +
            RuboCop::RakeTask.new
         
     | 
| 
       5 
9 
     | 
    
         | 
| 
       6 
     | 
    
         
            -
            desc  
     | 
| 
       7 
     | 
    
         
            -
            task : 
     | 
| 
      
 10 
     | 
    
         
            +
            desc 'Default Task'
         
     | 
| 
      
 11 
     | 
    
         
            +
            task default: [:spec]
         
     | 
| 
      
 12 
     | 
    
         
            +
            task complete: %i[spec rubocop]
         
     | 
    
        data/lib/validates_host.rb
    CHANGED
    
    | 
         @@ -1,3 +1,5 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
       1 
3 
     | 
    
         
             
            require 'active_support/core_ext/array/wrap'
         
     | 
| 
       2 
4 
     | 
    
         
             
            require 'validates_host/host_name_validator'
         
     | 
| 
       3 
5 
     | 
    
         
             
            require 'validates_host/domain_name_validator'
         
     | 
| 
         @@ -16,4 +18,4 @@ module ValidatesHost 
     | 
|
| 
       16 
18 
     | 
    
         
             
              autoload :Ip, 'validates_host/ip'
         
     | 
| 
       17 
19 
     | 
    
         
             
              autoload :HostName, 'validates_host/host_name'
         
     | 
| 
       18 
20 
     | 
    
         
             
              autoload :DomainName, 'validates_host/domain_name'
         
     | 
| 
       19 
     | 
    
         
            -
            end
         
     | 
| 
      
 21 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -1,3 +1,5 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
       1 
3 
     | 
    
         
             
            module ValidatesHost
         
     | 
| 
       2 
4 
     | 
    
         
             
              class DomainName
         
     | 
| 
       3 
5 
     | 
    
         
             
                def initialize(domain_name)
         
     | 
| 
         @@ -6,7 +8,8 @@ module ValidatesHost 
     | 
|
| 
       6 
8 
     | 
    
         | 
| 
       7 
9 
     | 
    
         
             
                def valid?
         
     | 
| 
       8 
10 
     | 
    
         
             
                  return true if @domain_name.blank?
         
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                  @domain_name =~ %r{^[a-z0-9]+([\-.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(/.*)?$}
         
     | 
| 
       10 
13 
     | 
    
         
             
                end
         
     | 
| 
       11 
14 
     | 
    
         
             
              end
         
     | 
| 
       12 
     | 
    
         
            -
            end
         
     | 
| 
      
 15 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -1,3 +1,5 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
       1 
3 
     | 
    
         
             
            module ValidatesHost
         
     | 
| 
       2 
4 
     | 
    
         
             
              class HostName
         
     | 
| 
       3 
5 
     | 
    
         
             
                def initialize(host_name)
         
     | 
| 
         @@ -6,7 +8,8 @@ module ValidatesHost 
     | 
|
| 
       6 
8 
     | 
    
         | 
| 
       7 
9 
     | 
    
         
             
                def valid?
         
     | 
| 
       8 
10 
     | 
    
         
             
                  return true if @host_name.blank?
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
       9 
12 
     | 
    
         
             
                  @host_name =~ /^[a-z][a-z0-9-]+$/
         
     | 
| 
       10 
13 
     | 
    
         
             
                end
         
     | 
| 
       11 
14 
     | 
    
         
             
              end
         
     | 
| 
       12 
     | 
    
         
            -
            end
         
     | 
| 
      
 15 
     | 
    
         
            +
            end
         
     | 
    
        data/lib/validates_host/ip.rb
    CHANGED
    
    | 
         @@ -1,12 +1,17 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require 'resolv'
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
       1 
5 
     | 
    
         
             
            module ValidatesHost
         
     | 
| 
       2 
6 
     | 
    
         
             
              class Ip
         
     | 
| 
       3 
     | 
    
         
            -
                def initialize( 
     | 
| 
       4 
     | 
    
         
            -
                  @ 
     | 
| 
      
 7 
     | 
    
         
            +
                def initialize(value)
         
     | 
| 
      
 8 
     | 
    
         
            +
                  @value = value
         
     | 
| 
       5 
9 
     | 
    
         
             
                end
         
     | 
| 
       6 
10 
     | 
    
         | 
| 
       7 
11 
     | 
    
         
             
                def valid?
         
     | 
| 
       8 
     | 
    
         
            -
                  return true if @ 
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
      
 12 
     | 
    
         
            +
                  return true if @value.blank?
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
                  @value =~ Regexp.union(Resolv::IPv4::Regex, Resolv::IPv6::Regex)
         
     | 
| 
       10 
15 
     | 
    
         
             
                end
         
     | 
| 
       11 
16 
     | 
    
         
             
              end
         
     | 
| 
       12 
     | 
    
         
            -
            end
         
     | 
| 
      
 17 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -1,4 +1,6 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
             
     | 
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require 'shoulda-matchers'
         
     | 
| 
       2 
4 
     | 
    
         | 
| 
       3 
5 
     | 
    
         
             
            module Shoulda
         
     | 
| 
       4 
6 
     | 
    
         
             
              module Matchers
         
     | 
| 
         @@ -15,19 +17,19 @@ module Shoulda 
     | 
|
| 
       15 
17 
     | 
    
         
             
                    def matches?(subject)
         
     | 
| 
       16 
18 
     | 
    
         
             
                      super(subject)
         
     | 
| 
       17 
19 
     | 
    
         | 
| 
       18 
     | 
    
         
            -
                      disallows_invalid_value  
     | 
| 
      
 20 
     | 
    
         
            +
                      disallows_invalid_value && allows_valid_value
         
     | 
| 
       19 
21 
     | 
    
         
             
                    end
         
     | 
| 
       20 
22 
     | 
    
         | 
| 
       21 
23 
     | 
    
         
             
                    private
         
     | 
| 
       22 
24 
     | 
    
         | 
| 
       23 
25 
     | 
    
         
             
                    def disallows_invalid_value
         
     | 
| 
       24 
     | 
    
         
            -
                      disallows_value_of( 
     | 
| 
      
 26 
     | 
    
         
            +
                      disallows_value_of('example')
         
     | 
| 
       25 
27 
     | 
    
         
             
                    end
         
     | 
| 
       26 
28 
     | 
    
         | 
| 
       27 
29 
     | 
    
         
             
                    def allows_valid_value
         
     | 
| 
       28 
     | 
    
         
            -
                      allows_value_of( 
     | 
| 
      
 30 
     | 
    
         
            +
                      allows_value_of('example.com')
         
     | 
| 
       29 
31 
     | 
    
         
             
                    end
         
     | 
| 
       30 
32 
     | 
    
         
             
                  end
         
     | 
| 
       31 
33 
     | 
    
         
             
                end
         
     | 
| 
       32 
34 
     | 
    
         
             
              end
         
     | 
| 
       33 
     | 
    
         
            -
            end
         
     | 
| 
      
 35 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -1,4 +1,6 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
             
     | 
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require 'shoulda-matchers'
         
     | 
| 
       2 
4 
     | 
    
         | 
| 
       3 
5 
     | 
    
         
             
            module Shoulda
         
     | 
| 
       4 
6 
     | 
    
         
             
              module Matchers
         
     | 
| 
         @@ -15,19 +17,19 @@ module Shoulda 
     | 
|
| 
       15 
17 
     | 
    
         
             
                    def matches?(subject)
         
     | 
| 
       16 
18 
     | 
    
         
             
                      super(subject)
         
     | 
| 
       17 
19 
     | 
    
         | 
| 
       18 
     | 
    
         
            -
                      disallows_invalid_value  
     | 
| 
      
 20 
     | 
    
         
            +
                      disallows_invalid_value && allows_valid_value
         
     | 
| 
       19 
21 
     | 
    
         
             
                    end
         
     | 
| 
       20 
22 
     | 
    
         | 
| 
       21 
23 
     | 
    
         
             
                    private
         
     | 
| 
       22 
24 
     | 
    
         | 
| 
       23 
25 
     | 
    
         
             
                    def disallows_invalid_value
         
     | 
| 
       24 
     | 
    
         
            -
                      disallows_value_of( 
     | 
| 
      
 26 
     | 
    
         
            +
                      disallows_value_of('1bd')
         
     | 
| 
       25 
27 
     | 
    
         
             
                    end
         
     | 
| 
       26 
28 
     | 
    
         | 
| 
       27 
29 
     | 
    
         
             
                    def allows_valid_value
         
     | 
| 
       28 
     | 
    
         
            -
                      allows_value_of( 
     | 
| 
      
 30 
     | 
    
         
            +
                      allows_value_of('bd01')
         
     | 
| 
       29 
31 
     | 
    
         
             
                    end
         
     | 
| 
       30 
32 
     | 
    
         
             
                  end
         
     | 
| 
       31 
33 
     | 
    
         
             
                end
         
     | 
| 
       32 
34 
     | 
    
         
             
              end
         
     | 
| 
       33 
     | 
    
         
            -
            end
         
     | 
| 
      
 35 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -1,4 +1,6 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
             
     | 
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require 'shoulda-matchers'
         
     | 
| 
       2 
4 
     | 
    
         | 
| 
       3 
5 
     | 
    
         
             
            module Shoulda
         
     | 
| 
       4 
6 
     | 
    
         
             
              module Matchers
         
     | 
| 
         @@ -15,19 +17,19 @@ module Shoulda 
     | 
|
| 
       15 
17 
     | 
    
         
             
                    def matches?(subject)
         
     | 
| 
       16 
18 
     | 
    
         
             
                      super(subject)
         
     | 
| 
       17 
19 
     | 
    
         | 
| 
       18 
     | 
    
         
            -
                      disallows_invalid_value  
     | 
| 
      
 20 
     | 
    
         
            +
                      disallows_invalid_value && allows_valid_value
         
     | 
| 
       19 
21 
     | 
    
         
             
                    end
         
     | 
| 
       20 
22 
     | 
    
         | 
| 
       21 
23 
     | 
    
         
             
                    private
         
     | 
| 
       22 
24 
     | 
    
         | 
| 
       23 
25 
     | 
    
         
             
                    def disallows_invalid_value
         
     | 
| 
       24 
     | 
    
         
            -
                      disallows_value_of( 
     | 
| 
      
 26 
     | 
    
         
            +
                      disallows_value_of('10.0.0')
         
     | 
| 
       25 
27 
     | 
    
         
             
                    end
         
     | 
| 
       26 
28 
     | 
    
         | 
| 
       27 
29 
     | 
    
         
             
                    def allows_valid_value
         
     | 
| 
       28 
     | 
    
         
            -
                      allows_value_of( 
     | 
| 
      
 30 
     | 
    
         
            +
                      allows_value_of('10.10.10.1')
         
     | 
| 
       29 
31 
     | 
    
         
             
                    end
         
     | 
| 
       30 
32 
     | 
    
         
             
                  end
         
     | 
| 
       31 
33 
     | 
    
         
             
                end
         
     | 
| 
       32 
34 
     | 
    
         
             
              end
         
     | 
| 
       33 
     | 
    
         
            -
            end
         
     | 
| 
      
 35 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -1,4 +1,6 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
             
     | 
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require 'shoulda-matchers'
         
     | 
| 
       2 
4 
     | 
    
         | 
| 
       3 
5 
     | 
    
         
             
            module Shoulda
         
     | 
| 
       4 
6 
     | 
    
         
             
              module Matchers
         
     | 
| 
         @@ -15,19 +17,19 @@ module Shoulda 
     | 
|
| 
       15 
17 
     | 
    
         
             
                    def matches?(subject)
         
     | 
| 
       16 
18 
     | 
    
         
             
                      super(subject)
         
     | 
| 
       17 
19 
     | 
    
         | 
| 
       18 
     | 
    
         
            -
                      disallows_invalid_value  
     | 
| 
      
 20 
     | 
    
         
            +
                      disallows_invalid_value && allows_valid_value
         
     | 
| 
       19 
21 
     | 
    
         
             
                    end
         
     | 
| 
       20 
22 
     | 
    
         | 
| 
       21 
23 
     | 
    
         
             
                    private
         
     | 
| 
       22 
24 
     | 
    
         | 
| 
       23 
25 
     | 
    
         
             
                    def disallows_invalid_value
         
     | 
| 
       24 
     | 
    
         
            -
                      disallows_value_of( 
     | 
| 
      
 26 
     | 
    
         
            +
                      disallows_value_of('10.0.0')
         
     | 
| 
       25 
27 
     | 
    
         
             
                    end
         
     | 
| 
       26 
28 
     | 
    
         | 
| 
       27 
29 
     | 
    
         
             
                    def allows_valid_value
         
     | 
| 
       28 
     | 
    
         
            -
                      allows_value_of( 
     | 
| 
      
 30 
     | 
    
         
            +
                      allows_value_of('10.10.10.1/28')
         
     | 
| 
       29 
31 
     | 
    
         
             
                    end
         
     | 
| 
       30 
32 
     | 
    
         
             
                  end
         
     | 
| 
       31 
33 
     | 
    
         
             
                end
         
     | 
| 
       32 
34 
     | 
    
         
             
              end
         
     | 
| 
       33 
     | 
    
         
            -
            end
         
     | 
| 
      
 35 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -1,3 +1,5 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
       1 
3 
     | 
    
         
             
            module ValidatesHost
         
     | 
| 
       2 
4 
     | 
    
         
             
              class Subnet
         
     | 
| 
       3 
5 
     | 
    
         
             
                def initialize(subnet)
         
     | 
| 
         @@ -6,7 +8,8 @@ module ValidatesHost 
     | 
|
| 
       6 
8 
     | 
    
         | 
| 
       7 
9 
     | 
    
         
             
                def valid?
         
     | 
| 
       8 
10 
     | 
    
         
             
                  return true if @subnet.blank?
         
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                  @subnet =~ %r{^([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}/(2[4-9]|30)$}
         
     | 
| 
       10 
13 
     | 
    
         
             
                end
         
     | 
| 
       11 
14 
     | 
    
         
             
              end
         
     | 
| 
       12 
     | 
    
         
            -
            end
         
     | 
| 
      
 15 
     | 
    
         
            +
            end
         
     | 
    
        data/spec/fake_app/server.rb
    CHANGED
    
    | 
         @@ -1,3 +1,5 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
       1 
3 
     | 
    
         
             
            class Server
         
     | 
| 
       2 
4 
     | 
    
         
             
              include ActiveModel::Validations
         
     | 
| 
       3 
5 
     | 
    
         
             
              include ActiveModel::Conversion
         
     | 
| 
         @@ -5,13 +7,13 @@ class Server 
     | 
|
| 
       5 
7 
     | 
    
         | 
| 
       6 
8 
     | 
    
         
             
              attr_accessor :domain_name, :host_name, :ip
         
     | 
| 
       7 
9 
     | 
    
         | 
| 
       8 
     | 
    
         
            -
              validates :domain_name, : 
     | 
| 
       9 
     | 
    
         
            -
              validates :host_name, : 
     | 
| 
       10 
     | 
    
         
            -
              validates :ip, : 
     | 
| 
      
 10 
     | 
    
         
            +
              validates :domain_name, domain_name: true
         
     | 
| 
      
 11 
     | 
    
         
            +
              validates :host_name, host_name: true
         
     | 
| 
      
 12 
     | 
    
         
            +
              validates :ip, ip: true
         
     | 
| 
       11 
13 
     | 
    
         | 
| 
       12 
14 
     | 
    
         
             
              def initialize(attributes = {})
         
     | 
| 
       13 
15 
     | 
    
         
             
                attributes.each do |name, value|
         
     | 
| 
       14 
16 
     | 
    
         
             
                  send("#{name}=", value)
         
     | 
| 
       15 
17 
     | 
    
         
             
                end
         
     | 
| 
       16 
18 
     | 
    
         
             
              end
         
     | 
| 
       17 
     | 
    
         
            -
            end
         
     | 
| 
      
 19 
     | 
    
         
            +
            end
         
     | 
    
        data/spec/fake_app/subnet.rb
    CHANGED
    
    | 
         @@ -1,3 +1,5 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
       1 
3 
     | 
    
         
             
            class Subnet
         
     | 
| 
       2 
4 
     | 
    
         
             
              include ActiveModel::Validations
         
     | 
| 
       3 
5 
     | 
    
         
             
              include ActiveModel::Conversion
         
     | 
| 
         @@ -5,11 +7,5 @@ class Subnet 
     | 
|
| 
       5 
7 
     | 
    
         | 
| 
       6 
8 
     | 
    
         
             
              attr_accessor :id, :value
         
     | 
| 
       7 
9 
     | 
    
         | 
| 
       8 
     | 
    
         
            -
              validates :value, : 
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
     | 
    
         
            -
              def initialize(attributes = {})
         
     | 
| 
       11 
     | 
    
         
            -
                attributes.each do |name, value|
         
     | 
| 
       12 
     | 
    
         
            -
                  send("#{name}=", value)
         
     | 
| 
       13 
     | 
    
         
            -
                end
         
     | 
| 
       14 
     | 
    
         
            -
              end
         
     | 
| 
       15 
     | 
    
         
            -
            end
         
     | 
| 
      
 10 
     | 
    
         
            +
              validates :value, subnet: true
         
     | 
| 
      
 11 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,23 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require 'spec_helper'
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            describe Shoulda::Matchers::ActiveModel::RequireAValidDomainNameMatcher do
         
     | 
| 
      
 6 
     | 
    
         
            +
              let(:server) { Server.new }
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
              it 'accepts on domain_name' do
         
     | 
| 
      
 9 
     | 
    
         
            +
                expect(server).to require_a_valid_domain_name(:domain_name)
         
     | 
| 
      
 10 
     | 
    
         
            +
              end
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
              it 'accepts without a specified attribute' do
         
     | 
| 
      
 13 
     | 
    
         
            +
                expect(server).to require_a_valid_domain_name
         
     | 
| 
      
 14 
     | 
    
         
            +
              end
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
              it 'rejects on host_name' do
         
     | 
| 
      
 17 
     | 
    
         
            +
                expect(server).not_to require_a_valid_domain_name(:host_name)
         
     | 
| 
      
 18 
     | 
    
         
            +
              end
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
              it 'has a description message' do
         
     | 
| 
      
 21 
     | 
    
         
            +
                expect(require_a_valid_domain_name.description).to eq('require domain_name to be a valid domain name')
         
     | 
| 
      
 22 
     | 
    
         
            +
              end
         
     | 
| 
      
 23 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,23 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require 'spec_helper'
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            describe Shoulda::Matchers::ActiveModel::RequireAValidHostNameMatcher do
         
     | 
| 
      
 6 
     | 
    
         
            +
              let(:server) { Server.new }
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
              it 'accepts on host_name' do
         
     | 
| 
      
 9 
     | 
    
         
            +
                expect(server).to require_a_valid_host_name(:host_name)
         
     | 
| 
      
 10 
     | 
    
         
            +
              end
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
              it 'accepts without a specified attribute' do
         
     | 
| 
      
 13 
     | 
    
         
            +
                expect(server).to require_a_valid_host_name
         
     | 
| 
      
 14 
     | 
    
         
            +
              end
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
              it 'rejects on domain_name' do
         
     | 
| 
      
 17 
     | 
    
         
            +
                expect(server).not_to require_a_valid_host_name(:domain_name)
         
     | 
| 
      
 18 
     | 
    
         
            +
              end
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
              it 'has a description message' do
         
     | 
| 
      
 21 
     | 
    
         
            +
                expect(require_a_valid_host_name.description).to eq('require host_name to be a valid host name')
         
     | 
| 
      
 22 
     | 
    
         
            +
              end
         
     | 
| 
      
 23 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,23 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require 'spec_helper'
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            describe Shoulda::Matchers::ActiveModel::RequireAValidIpMatcher do
         
     | 
| 
      
 6 
     | 
    
         
            +
              let(:server) { Server.new }
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
              it 'accepts on ip' do
         
     | 
| 
      
 9 
     | 
    
         
            +
                expect(server).to require_a_valid_ip(:ip)
         
     | 
| 
      
 10 
     | 
    
         
            +
              end
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
              it 'accepts without a specified attribute' do
         
     | 
| 
      
 13 
     | 
    
         
            +
                expect(server).to require_a_valid_ip
         
     | 
| 
      
 14 
     | 
    
         
            +
              end
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
              it 'rejects on domain_name' do
         
     | 
| 
      
 17 
     | 
    
         
            +
                expect(server).not_to require_a_valid_ip(:domain_name)
         
     | 
| 
      
 18 
     | 
    
         
            +
              end
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
              it 'has a description message' do
         
     | 
| 
      
 21 
     | 
    
         
            +
                expect(require_a_valid_ip.description).to eq('require ip to be a valid ip')
         
     | 
| 
      
 22 
     | 
    
         
            +
              end
         
     | 
| 
      
 23 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,23 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require 'spec_helper'
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            describe Shoulda::Matchers::ActiveModel::RequireAValidSubnetMatcher do
         
     | 
| 
      
 6 
     | 
    
         
            +
              let(:subnet) { Subnet.new }
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
              it 'accepts on value' do
         
     | 
| 
      
 9 
     | 
    
         
            +
                expect(subnet).to require_a_valid_subnet(:value)
         
     | 
| 
      
 10 
     | 
    
         
            +
              end
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
              it 'accepts without a specified attribute' do
         
     | 
| 
      
 13 
     | 
    
         
            +
                expect(subnet).to require_a_valid_subnet
         
     | 
| 
      
 14 
     | 
    
         
            +
              end
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
              it 'rejects on id' do
         
     | 
| 
      
 17 
     | 
    
         
            +
                expect(subnet).not_to require_a_valid_subnet(:id)
         
     | 
| 
      
 18 
     | 
    
         
            +
              end
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
              it 'has a description message' do
         
     | 
| 
      
 21 
     | 
    
         
            +
                expect(require_a_valid_subnet.description).to eq('require value to be a valid subnet')
         
     | 
| 
      
 22 
     | 
    
         
            +
              end
         
     | 
| 
      
 23 
     | 
    
         
            +
            end
         
     | 
    
        data/spec/spec_helper.rb
    CHANGED
    
    | 
         @@ -1,3 +1,5 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
       1 
3 
     | 
    
         
             
            require 'rspec'
         
     | 
| 
       2 
4 
     | 
    
         
             
            require 'active_model'
         
     | 
| 
       3 
5 
     | 
    
         
             
            require 'coveralls'
         
     | 
| 
         @@ -9,4 +11,4 @@ require 'validates_host' 
     | 
|
| 
       9 
11 
     | 
    
         
             
            require 'fake_app/server'
         
     | 
| 
       10 
12 
     | 
    
         
             
            require 'fake_app/subnet'
         
     | 
| 
       11 
13 
     | 
    
         | 
| 
       12 
     | 
    
         
            -
            include Shoulda::Matchers::ActiveModel
         
     | 
| 
      
 14 
     | 
    
         
            +
            include Shoulda::Matchers::ActiveModel
         
     | 
| 
         @@ -1,38 +1,41 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
       1 
3 
     | 
    
         
             
            require 'spec_helper'
         
     | 
| 
       2 
4 
     | 
    
         | 
| 
       3 
5 
     | 
    
         
             
            describe DomainNameValidator do
         
     | 
| 
      
 6 
     | 
    
         
            +
              let(:server) { Server.new }
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
       4 
8 
     | 
    
         
             
              context 'when domain_name is invalid' do
         
     | 
| 
       5 
     | 
    
         
            -
                before  
     | 
| 
       6 
     | 
    
         
            -
                   
     | 
| 
      
 9 
     | 
    
         
            +
                before do
         
     | 
| 
      
 10 
     | 
    
         
            +
                  server.domain_name = 'http://'
         
     | 
| 
      
 11 
     | 
    
         
            +
                  server.valid?
         
     | 
| 
       7 
12 
     | 
    
         
             
                end
         
     | 
| 
       8 
13 
     | 
    
         | 
| 
       9 
     | 
    
         
            -
                it ' 
     | 
| 
       10 
     | 
    
         
            -
                  expect( 
     | 
| 
      
 14 
     | 
    
         
            +
                it 'sets object as invalid' do
         
     | 
| 
      
 15 
     | 
    
         
            +
                  expect(server).not_to be_valid
         
     | 
| 
       11 
16 
     | 
    
         
             
                end
         
     | 
| 
       12 
17 
     | 
    
         | 
| 
       13 
     | 
    
         
            -
                it ' 
     | 
| 
       14 
     | 
    
         
            -
                   
     | 
| 
       15 
     | 
    
         
            -
                  expect(@server.errors[:domain_name]).to eq(['is invalid'])
         
     | 
| 
      
 18 
     | 
    
         
            +
                it 'sets an error' do
         
     | 
| 
      
 19 
     | 
    
         
            +
                  expect(server.errors[:domain_name]).to eq(['is invalid'])
         
     | 
| 
       16 
20 
     | 
    
         
             
                end
         
     | 
| 
       17 
21 
     | 
    
         
             
              end
         
     | 
| 
       18 
22 
     | 
    
         | 
| 
       19 
23 
     | 
    
         
             
              context 'when domain_name is valid' do
         
     | 
| 
       20 
     | 
    
         
            -
                before  
     | 
| 
       21 
     | 
    
         
            -
                   
     | 
| 
      
 24 
     | 
    
         
            +
                before do
         
     | 
| 
      
 25 
     | 
    
         
            +
                  server.domain_name = 'example.com'
         
     | 
| 
      
 26 
     | 
    
         
            +
                  server.valid?
         
     | 
| 
       22 
27 
     | 
    
         
             
                end
         
     | 
| 
       23 
28 
     | 
    
         | 
| 
       24 
     | 
    
         
            -
                it ' 
     | 
| 
       25 
     | 
    
         
            -
                  expect( 
     | 
| 
      
 29 
     | 
    
         
            +
                it 'sets object as valid' do
         
     | 
| 
      
 30 
     | 
    
         
            +
                  expect(server).to be_valid
         
     | 
| 
       26 
31 
     | 
    
         
             
                end
         
     | 
| 
       27 
32 
     | 
    
         | 
| 
       28 
     | 
    
         
            -
                it ' 
     | 
| 
       29 
     | 
    
         
            -
                   
     | 
| 
       30 
     | 
    
         
            -
                  expect(@server.errors[:domain_name]).to be_blank
         
     | 
| 
      
 33 
     | 
    
         
            +
                it 'does not set an error on attribute' do
         
     | 
| 
      
 34 
     | 
    
         
            +
                  expect(server.errors[:domain_name]).to be_blank
         
     | 
| 
       31 
35 
     | 
    
         
             
                end
         
     | 
| 
       32 
36 
     | 
    
         
             
              end
         
     | 
| 
       33 
37 
     | 
    
         | 
| 
       34 
     | 
    
         
            -
              it ' 
     | 
| 
       35 
     | 
    
         
            -
                 
     | 
| 
       36 
     | 
    
         
            -
                expect(@server.valid?).to be_truthy
         
     | 
| 
      
 38 
     | 
    
         
            +
              it 'is valid with a nil value' do
         
     | 
| 
      
 39 
     | 
    
         
            +
                expect(server).to be_valid
         
     | 
| 
       37 
40 
     | 
    
         
             
              end
         
     | 
| 
       38 
     | 
    
         
            -
            end
         
     | 
| 
      
 41 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -1,38 +1,41 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
       1 
3 
     | 
    
         
             
            require 'spec_helper'
         
     | 
| 
       2 
4 
     | 
    
         | 
| 
       3 
5 
     | 
    
         
             
            describe HostNameValidator do
         
     | 
| 
      
 6 
     | 
    
         
            +
              let(:server) { Server.new }
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
       4 
8 
     | 
    
         
             
              context 'when host_name is invalid' do
         
     | 
| 
       5 
     | 
    
         
            -
                before  
     | 
| 
       6 
     | 
    
         
            -
                   
     | 
| 
      
 9 
     | 
    
         
            +
                before do
         
     | 
| 
      
 10 
     | 
    
         
            +
                  server.host_name = 'http://'
         
     | 
| 
      
 11 
     | 
    
         
            +
                  server.valid?
         
     | 
| 
       7 
12 
     | 
    
         
             
                end
         
     | 
| 
       8 
13 
     | 
    
         | 
| 
       9 
     | 
    
         
            -
                it ' 
     | 
| 
       10 
     | 
    
         
            -
                  expect( 
     | 
| 
      
 14 
     | 
    
         
            +
                it 'sets object as invalid' do
         
     | 
| 
      
 15 
     | 
    
         
            +
                  expect(server).not_to be_valid
         
     | 
| 
       11 
16 
     | 
    
         
             
                end
         
     | 
| 
       12 
17 
     | 
    
         | 
| 
       13 
     | 
    
         
            -
                it ' 
     | 
| 
       14 
     | 
    
         
            -
                   
     | 
| 
       15 
     | 
    
         
            -
                  expect(@server.errors[:host_name]).to eq(['is invalid'])
         
     | 
| 
      
 18 
     | 
    
         
            +
                it 'sets an error' do
         
     | 
| 
      
 19 
     | 
    
         
            +
                  expect(server.errors[:host_name]).to eq(['is invalid'])
         
     | 
| 
       16 
20 
     | 
    
         
             
                end
         
     | 
| 
       17 
21 
     | 
    
         
             
              end
         
     | 
| 
       18 
22 
     | 
    
         | 
| 
       19 
23 
     | 
    
         
             
              context 'when host_name is valid' do
         
     | 
| 
       20 
     | 
    
         
            -
                before  
     | 
| 
       21 
     | 
    
         
            -
                   
     | 
| 
      
 24 
     | 
    
         
            +
                before do
         
     | 
| 
      
 25 
     | 
    
         
            +
                  server.host_name = 'bd01'
         
     | 
| 
      
 26 
     | 
    
         
            +
                  server.valid?
         
     | 
| 
       22 
27 
     | 
    
         
             
                end
         
     | 
| 
       23 
28 
     | 
    
         | 
| 
       24 
     | 
    
         
            -
                it ' 
     | 
| 
       25 
     | 
    
         
            -
                  expect( 
     | 
| 
      
 29 
     | 
    
         
            +
                it 'sets object as valid' do
         
     | 
| 
      
 30 
     | 
    
         
            +
                  expect(server).to be_valid
         
     | 
| 
       26 
31 
     | 
    
         
             
                end
         
     | 
| 
       27 
32 
     | 
    
         | 
| 
       28 
     | 
    
         
            -
                it ' 
     | 
| 
       29 
     | 
    
         
            -
                   
     | 
| 
       30 
     | 
    
         
            -
                  expect(@server.errors[:host_name]).to be_blank
         
     | 
| 
      
 33 
     | 
    
         
            +
                it 'does not set an error on attribute' do
         
     | 
| 
      
 34 
     | 
    
         
            +
                  expect(server.errors[:host_name]).to be_blank
         
     | 
| 
       31 
35 
     | 
    
         
             
                end
         
     | 
| 
       32 
36 
     | 
    
         
             
              end
         
     | 
| 
       33 
37 
     | 
    
         | 
| 
       34 
     | 
    
         
            -
              it ' 
     | 
| 
       35 
     | 
    
         
            -
                 
     | 
| 
       36 
     | 
    
         
            -
                expect(@server.valid?).to be_truthy
         
     | 
| 
      
 38 
     | 
    
         
            +
              it 'is valid with a nil value' do
         
     | 
| 
      
 39 
     | 
    
         
            +
                expect(server).to be_valid
         
     | 
| 
       37 
40 
     | 
    
         
             
              end
         
     | 
| 
       38 
     | 
    
         
            -
            end
         
     | 
| 
      
 41 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -1,38 +1,56 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
       1 
3 
     | 
    
         
             
            require 'spec_helper'
         
     | 
| 
       2 
4 
     | 
    
         | 
| 
       3 
5 
     | 
    
         
             
            describe IpValidator do
         
     | 
| 
      
 6 
     | 
    
         
            +
              let(:server) { Server.new }
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
       4 
8 
     | 
    
         
             
              context 'when ip is invalid' do
         
     | 
| 
       5 
     | 
    
         
            -
                before  
     | 
| 
       6 
     | 
    
         
            -
                   
     | 
| 
      
 9 
     | 
    
         
            +
                before do
         
     | 
| 
      
 10 
     | 
    
         
            +
                  server.ip = '127.0.0'
         
     | 
| 
      
 11 
     | 
    
         
            +
                  server.valid?
         
     | 
| 
      
 12 
     | 
    
         
            +
                end
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
                it 'sets object as invalid' do
         
     | 
| 
      
 15 
     | 
    
         
            +
                  expect(server).not_to be_valid
         
     | 
| 
      
 16 
     | 
    
         
            +
                end
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
                it 'sets an error' do
         
     | 
| 
      
 19 
     | 
    
         
            +
                  expect(server.errors[:ip]).to eq(['is invalid'])
         
     | 
| 
      
 20 
     | 
    
         
            +
                end
         
     | 
| 
      
 21 
     | 
    
         
            +
              end
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
              context 'when ip is IPV4 valid' do
         
     | 
| 
      
 24 
     | 
    
         
            +
                before do
         
     | 
| 
      
 25 
     | 
    
         
            +
                  server.ip = '10.10.10.1'
         
     | 
| 
      
 26 
     | 
    
         
            +
                  server.valid?
         
     | 
| 
       7 
27 
     | 
    
         
             
                end
         
     | 
| 
       8 
28 
     | 
    
         | 
| 
       9 
     | 
    
         
            -
                it ' 
     | 
| 
       10 
     | 
    
         
            -
                  expect( 
     | 
| 
      
 29 
     | 
    
         
            +
                it 'sets object as valid' do
         
     | 
| 
      
 30 
     | 
    
         
            +
                  expect(server).to be_valid
         
     | 
| 
       11 
31 
     | 
    
         
             
                end
         
     | 
| 
       12 
32 
     | 
    
         | 
| 
       13 
     | 
    
         
            -
                it ' 
     | 
| 
       14 
     | 
    
         
            -
                   
     | 
| 
       15 
     | 
    
         
            -
                  expect(@server.errors[:ip]).to eq(['is invalid'])
         
     | 
| 
      
 33 
     | 
    
         
            +
                it 'does not set an error on attribute' do
         
     | 
| 
      
 34 
     | 
    
         
            +
                  expect(server.errors[:ip]).to be_blank
         
     | 
| 
       16 
35 
     | 
    
         
             
                end
         
     | 
| 
       17 
36 
     | 
    
         
             
              end
         
     | 
| 
       18 
37 
     | 
    
         | 
| 
       19 
     | 
    
         
            -
              context 'when ip is valid' do
         
     | 
| 
       20 
     | 
    
         
            -
                before  
     | 
| 
       21 
     | 
    
         
            -
                   
     | 
| 
      
 38 
     | 
    
         
            +
              context 'when ip is IPV6 valid' do
         
     | 
| 
      
 39 
     | 
    
         
            +
                before do
         
     | 
| 
      
 40 
     | 
    
         
            +
                  server.ip = 'fd92:fe56:b43a:062e:ffff:ffff:ffff:ffff'
         
     | 
| 
      
 41 
     | 
    
         
            +
                  server.valid?
         
     | 
| 
       22 
42 
     | 
    
         
             
                end
         
     | 
| 
       23 
43 
     | 
    
         | 
| 
       24 
     | 
    
         
            -
                it ' 
     | 
| 
       25 
     | 
    
         
            -
                  expect( 
     | 
| 
      
 44 
     | 
    
         
            +
                it 'sets object as valid' do
         
     | 
| 
      
 45 
     | 
    
         
            +
                  expect(server).to be_valid
         
     | 
| 
       26 
46 
     | 
    
         
             
                end
         
     | 
| 
       27 
47 
     | 
    
         | 
| 
       28 
     | 
    
         
            -
                it ' 
     | 
| 
       29 
     | 
    
         
            -
                   
     | 
| 
       30 
     | 
    
         
            -
                  expect(@server.errors[:ip]).to be_blank
         
     | 
| 
      
 48 
     | 
    
         
            +
                it 'does not set an error on attribute' do
         
     | 
| 
      
 49 
     | 
    
         
            +
                  expect(server.errors[:ip]).to be_blank
         
     | 
| 
       31 
50 
     | 
    
         
             
                end
         
     | 
| 
       32 
51 
     | 
    
         
             
              end
         
     | 
| 
       33 
52 
     | 
    
         | 
| 
       34 
     | 
    
         
            -
              it ' 
     | 
| 
       35 
     | 
    
         
            -
                 
     | 
| 
       36 
     | 
    
         
            -
                expect(@server.valid?).to be_truthy
         
     | 
| 
      
 53 
     | 
    
         
            +
              it 'is valid with a nil value' do
         
     | 
| 
      
 54 
     | 
    
         
            +
                expect(server).to be_valid
         
     | 
| 
       37 
55 
     | 
    
         
             
              end
         
     | 
| 
       38 
     | 
    
         
            -
            end
         
     | 
| 
      
 56 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -1,38 +1,41 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
       1 
3 
     | 
    
         
             
            require 'spec_helper'
         
     | 
| 
       2 
4 
     | 
    
         | 
| 
       3 
5 
     | 
    
         
             
            describe SubnetValidator do
         
     | 
| 
      
 6 
     | 
    
         
            +
              let(:subnet) { Subnet.new }
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
       4 
8 
     | 
    
         
             
              context 'when subnet is invalid' do
         
     | 
| 
       5 
     | 
    
         
            -
                before  
     | 
| 
       6 
     | 
    
         
            -
                   
     | 
| 
      
 9 
     | 
    
         
            +
                before do
         
     | 
| 
      
 10 
     | 
    
         
            +
                  subnet.value = '127.0.0'
         
     | 
| 
      
 11 
     | 
    
         
            +
                  subnet.valid?
         
     | 
| 
       7 
12 
     | 
    
         
             
                end
         
     | 
| 
       8 
13 
     | 
    
         | 
| 
       9 
     | 
    
         
            -
                it ' 
     | 
| 
       10 
     | 
    
         
            -
                  expect( 
     | 
| 
      
 14 
     | 
    
         
            +
                it 'sets object as invalid' do
         
     | 
| 
      
 15 
     | 
    
         
            +
                  expect(subnet).not_to be_valid
         
     | 
| 
       11 
16 
     | 
    
         
             
                end
         
     | 
| 
       12 
17 
     | 
    
         | 
| 
       13 
     | 
    
         
            -
                it ' 
     | 
| 
       14 
     | 
    
         
            -
                   
     | 
| 
       15 
     | 
    
         
            -
                  expect(@subnet.errors[:value]).to eq(['is invalid'])
         
     | 
| 
      
 18 
     | 
    
         
            +
                it 'sets an error' do
         
     | 
| 
      
 19 
     | 
    
         
            +
                  expect(subnet.errors[:value]).to eq(['is invalid'])
         
     | 
| 
       16 
20 
     | 
    
         
             
                end
         
     | 
| 
       17 
21 
     | 
    
         
             
              end
         
     | 
| 
       18 
22 
     | 
    
         | 
| 
       19 
23 
     | 
    
         
             
              context 'when subnet is valid' do
         
     | 
| 
       20 
     | 
    
         
            -
                before  
     | 
| 
       21 
     | 
    
         
            -
                   
     | 
| 
      
 24 
     | 
    
         
            +
                before do
         
     | 
| 
      
 25 
     | 
    
         
            +
                  subnet.value = '10.10.10.1/28'
         
     | 
| 
      
 26 
     | 
    
         
            +
                  subnet.valid?
         
     | 
| 
       22 
27 
     | 
    
         
             
                end
         
     | 
| 
       23 
28 
     | 
    
         | 
| 
       24 
     | 
    
         
            -
                it ' 
     | 
| 
       25 
     | 
    
         
            -
                  expect( 
     | 
| 
      
 29 
     | 
    
         
            +
                it 'sets object as valid' do
         
     | 
| 
      
 30 
     | 
    
         
            +
                  expect(subnet).to be_valid
         
     | 
| 
       26 
31 
     | 
    
         
             
                end
         
     | 
| 
       27 
32 
     | 
    
         | 
| 
       28 
     | 
    
         
            -
                it ' 
     | 
| 
       29 
     | 
    
         
            -
                   
     | 
| 
       30 
     | 
    
         
            -
                  expect(@subnet.errors[:value]).to be_blank
         
     | 
| 
      
 33 
     | 
    
         
            +
                it 'does not set an error on attribute' do
         
     | 
| 
      
 34 
     | 
    
         
            +
                  expect(subnet.errors[:value]).to be_blank
         
     | 
| 
       31 
35 
     | 
    
         
             
                end
         
     | 
| 
       32 
36 
     | 
    
         
             
              end
         
     | 
| 
       33 
37 
     | 
    
         | 
| 
       34 
     | 
    
         
            -
              it ' 
     | 
| 
       35 
     | 
    
         
            -
                 
     | 
| 
       36 
     | 
    
         
            -
                expect(@subnet.valid?).to be_truthy
         
     | 
| 
      
 38 
     | 
    
         
            +
              it 'is valid with a nil value' do
         
     | 
| 
      
 39 
     | 
    
         
            +
                expect(subnet).to be_valid
         
     | 
| 
       37 
40 
     | 
    
         
             
              end
         
     | 
| 
       38 
     | 
    
         
            -
            end
         
     | 
| 
      
 41 
     | 
    
         
            +
            end
         
     | 
    
        data/validates_host.gemspec
    CHANGED
    
    | 
         @@ -1,24 +1,27 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            #  
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require File.expand_path('lib/validates_host/version', __dir__)
         
     | 
| 
       3 
4 
     | 
    
         | 
| 
       4 
5 
     | 
    
         
             
            Gem::Specification.new do |gem|
         
     | 
| 
       5 
6 
     | 
    
         
             
              gem.name        = 'validates_host'
         
     | 
| 
       6 
7 
     | 
    
         
             
              gem.version     = ValidatesHost::VERSION
         
     | 
| 
       7 
     | 
    
         
            -
              gem.authors     =  
     | 
| 
       8 
     | 
    
         
            -
              gem.email       =  
     | 
| 
       9 
     | 
    
         
            -
              gem.summary     =  
     | 
| 
      
 8 
     | 
    
         
            +
              gem.authors     = 'Paulo Henrique Lopes Ribeiro'
         
     | 
| 
      
 9 
     | 
    
         
            +
              gem.email       = 'plribeiro3000@gmail.com'
         
     | 
| 
      
 10 
     | 
    
         
            +
              gem.summary     = 'Validates Host, Domain and IP and test it with matchers in a simple way.'
         
     | 
| 
       10 
11 
     | 
    
         | 
| 
       11 
     | 
    
         
            -
              gem.files         = `git ls-files`.split( 
     | 
| 
      
 12 
     | 
    
         
            +
              gem.files         = `git ls-files`.split($OUTPUT_RECORD_SEPARATOR)
         
     | 
| 
       12 
13 
     | 
    
         
             
              gem.test_files    = `git ls-files -- {test,spec,features,examples,gemfiles}/*`.split("\n")
         
     | 
| 
       13 
     | 
    
         
            -
              gem.executables   = `git ls-files -- bin/*`.split('\n').map{ |f| File.basename(f) }
         
     | 
| 
       14 
     | 
    
         
            -
              gem.require_paths = %w 
     | 
| 
      
 14 
     | 
    
         
            +
              gem.executables   = `git ls-files -- bin/*`.split('\n').map { |f| File.basename(f) }
         
     | 
| 
      
 15 
     | 
    
         
            +
              gem.require_paths = %w[lib]
         
     | 
| 
       15 
16 
     | 
    
         | 
| 
       16 
17 
     | 
    
         
             
              gem.license = 'MIT'
         
     | 
| 
       17 
18 
     | 
    
         | 
| 
      
 19 
     | 
    
         
            +
              gem.add_development_dependency 'coveralls'
         
     | 
| 
       18 
20 
     | 
    
         
             
              gem.add_development_dependency 'rake'
         
     | 
| 
       19 
21 
     | 
    
         
             
              gem.add_development_dependency 'rspec'
         
     | 
| 
      
 22 
     | 
    
         
            +
              gem.add_development_dependency 'rubocop'
         
     | 
| 
      
 23 
     | 
    
         
            +
              gem.add_development_dependency 'rubocop-rspec'
         
     | 
| 
       20 
24 
     | 
    
         
             
              gem.add_development_dependency 'shoulda-matchers'
         
     | 
| 
       21 
     | 
    
         
            -
              gem.add_development_dependency 'coveralls'
         
     | 
| 
       22 
25 
     | 
    
         | 
| 
       23 
26 
     | 
    
         
             
              gem.add_dependency 'activemodel', '>= 3.0.0'
         
     | 
| 
       24 
     | 
    
         
            -
            end
         
     | 
| 
      
 27 
     | 
    
         
            +
            end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,15 +1,29 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: validates_host
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 1. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 1.2.0
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Paulo Henrique Lopes Ribeiro
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date:  
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2020-06-07 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
      
 13 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 14 
     | 
    
         
            +
              name: coveralls
         
     | 
| 
      
 15 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 16 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 17 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 18 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 19 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 20 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 21 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 22 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 23 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 24 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 25 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 26 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
       13 
27 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
28 
     | 
    
         
             
              name: rake
         
     | 
| 
       15 
29 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
         @@ -39,7 +53,7 @@ dependencies: 
     | 
|
| 
       39 
53 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       40 
54 
     | 
    
         
             
                    version: '0'
         
     | 
| 
       41 
55 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       42 
     | 
    
         
            -
              name:  
     | 
| 
      
 56 
     | 
    
         
            +
              name: rubocop
         
     | 
| 
       43 
57 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       44 
58 
     | 
    
         
             
                requirements:
         
     | 
| 
       45 
59 
     | 
    
         
             
                - - ">="
         
     | 
| 
         @@ -53,7 +67,21 @@ dependencies: 
     | 
|
| 
       53 
67 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       54 
68 
     | 
    
         
             
                    version: '0'
         
     | 
| 
       55 
69 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       56 
     | 
    
         
            -
              name:  
     | 
| 
      
 70 
     | 
    
         
            +
              name: rubocop-rspec
         
     | 
| 
      
 71 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 72 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 73 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 74 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 75 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 76 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 77 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 78 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 79 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 80 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 81 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 82 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 83 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 84 
     | 
    
         
            +
              name: shoulda-matchers
         
     | 
| 
       57 
85 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       58 
86 
     | 
    
         
             
                requirements:
         
     | 
| 
       59 
87 
     | 
    
         
             
                - - ">="
         
     | 
| 
         @@ -88,8 +116,8 @@ extra_rdoc_files: [] 
     | 
|
| 
       88 
116 
     | 
    
         
             
            files:
         
     | 
| 
       89 
117 
     | 
    
         
             
            - ".gitignore"
         
     | 
| 
       90 
118 
     | 
    
         
             
            - ".rspec"
         
     | 
| 
      
 119 
     | 
    
         
            +
            - ".rubocop.yml"
         
     | 
| 
       91 
120 
     | 
    
         
             
            - ".ruby-gemset"
         
     | 
| 
       92 
     | 
    
         
            -
            - ".ruby-version"
         
     | 
| 
       93 
121 
     | 
    
         
             
            - ".travis.yml"
         
     | 
| 
       94 
122 
     | 
    
         
             
            - Gemfile
         
     | 
| 
       95 
123 
     | 
    
         
             
            - LICENSE
         
     | 
| 
         @@ -114,14 +142,14 @@ files: 
     | 
|
| 
       114 
142 
     | 
    
         
             
            - lib/validates_host/version.rb
         
     | 
| 
       115 
143 
     | 
    
         
             
            - spec/fake_app/server.rb
         
     | 
| 
       116 
144 
     | 
    
         
             
            - spec/fake_app/subnet.rb
         
     | 
| 
      
 145 
     | 
    
         
            +
            - spec/shoulda/matchers/active_model/require_a_valid_domain_name_matcher_spec.rb
         
     | 
| 
      
 146 
     | 
    
         
            +
            - spec/shoulda/matchers/active_model/require_a_valid_host_name_matcher_spec.rb
         
     | 
| 
      
 147 
     | 
    
         
            +
            - spec/shoulda/matchers/active_model/require_a_valid_ip_matcher_spec.rb
         
     | 
| 
      
 148 
     | 
    
         
            +
            - spec/shoulda/matchers/active_model/require_a_valid_subnet_matcher_spec.rb
         
     | 
| 
       117 
149 
     | 
    
         
             
            - spec/spec_helper.rb
         
     | 
| 
       118 
150 
     | 
    
         
             
            - spec/validates_host/domain_name_validator_spec.rb
         
     | 
| 
       119 
151 
     | 
    
         
             
            - spec/validates_host/host_name_validator_spec.rb
         
     | 
| 
       120 
152 
     | 
    
         
             
            - spec/validates_host/ip_validator_spec.rb
         
     | 
| 
       121 
     | 
    
         
            -
            - spec/validates_host/require_a_valid_domain_name_matcher_spec.rb
         
     | 
| 
       122 
     | 
    
         
            -
            - spec/validates_host/require_a_valid_host_name_matcher_spec.rb
         
     | 
| 
       123 
     | 
    
         
            -
            - spec/validates_host/require_a_valid_ip_matcher_spec.rb
         
     | 
| 
       124 
     | 
    
         
            -
            - spec/validates_host/require_a_valid_subnet_matcher_spec.rb
         
     | 
| 
       125 
153 
     | 
    
         
             
            - spec/validates_host/subnet_validator_spec.rb
         
     | 
| 
       126 
154 
     | 
    
         
             
            - validates_host.gemspec
         
     | 
| 
       127 
155 
     | 
    
         
             
            homepage: 
         
     | 
| 
         @@ -143,8 +171,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       143 
171 
     | 
    
         
             
                - !ruby/object:Gem::Version
         
     | 
| 
       144 
172 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       145 
173 
     | 
    
         
             
            requirements: []
         
     | 
| 
       146 
     | 
    
         
            -
             
     | 
| 
       147 
     | 
    
         
            -
            rubygems_version: 2.6.14
         
     | 
| 
      
 174 
     | 
    
         
            +
            rubygems_version: 3.1.3
         
     | 
| 
       148 
175 
     | 
    
         
             
            signing_key: 
         
     | 
| 
       149 
176 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       150 
177 
     | 
    
         
             
            summary: Validates Host, Domain and IP and test it with matchers in a simple way.
         
     | 
| 
         @@ -154,12 +181,12 @@ test_files: 
     | 
|
| 
       154 
181 
     | 
    
         
             
            - gemfiles/Gemfile.rails5
         
     | 
| 
       155 
182 
     | 
    
         
             
            - spec/fake_app/server.rb
         
     | 
| 
       156 
183 
     | 
    
         
             
            - spec/fake_app/subnet.rb
         
     | 
| 
      
 184 
     | 
    
         
            +
            - spec/shoulda/matchers/active_model/require_a_valid_domain_name_matcher_spec.rb
         
     | 
| 
      
 185 
     | 
    
         
            +
            - spec/shoulda/matchers/active_model/require_a_valid_host_name_matcher_spec.rb
         
     | 
| 
      
 186 
     | 
    
         
            +
            - spec/shoulda/matchers/active_model/require_a_valid_ip_matcher_spec.rb
         
     | 
| 
      
 187 
     | 
    
         
            +
            - spec/shoulda/matchers/active_model/require_a_valid_subnet_matcher_spec.rb
         
     | 
| 
       157 
188 
     | 
    
         
             
            - spec/spec_helper.rb
         
     | 
| 
       158 
189 
     | 
    
         
             
            - spec/validates_host/domain_name_validator_spec.rb
         
     | 
| 
       159 
190 
     | 
    
         
             
            - spec/validates_host/host_name_validator_spec.rb
         
     | 
| 
       160 
191 
     | 
    
         
             
            - spec/validates_host/ip_validator_spec.rb
         
     | 
| 
       161 
     | 
    
         
            -
            - spec/validates_host/require_a_valid_domain_name_matcher_spec.rb
         
     | 
| 
       162 
     | 
    
         
            -
            - spec/validates_host/require_a_valid_host_name_matcher_spec.rb
         
     | 
| 
       163 
     | 
    
         
            -
            - spec/validates_host/require_a_valid_ip_matcher_spec.rb
         
     | 
| 
       164 
     | 
    
         
            -
            - spec/validates_host/require_a_valid_subnet_matcher_spec.rb
         
     | 
| 
       165 
192 
     | 
    
         
             
            - spec/validates_host/subnet_validator_spec.rb
         
     | 
    
        data/.ruby-version
    DELETED
    
    | 
         @@ -1 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            2.3.6
         
     | 
| 
         @@ -1,23 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require 'spec_helper'
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            describe Shoulda::Matchers::ActiveModel::RequireAValidDomainNameMatcher do
         
     | 
| 
       4 
     | 
    
         
            -
              before :each do
         
     | 
| 
       5 
     | 
    
         
            -
                @server = Server.new
         
     | 
| 
       6 
     | 
    
         
            -
              end
         
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
              it 'should accept on domain_name' do
         
     | 
| 
       9 
     | 
    
         
            -
                expect(@server).to require_a_valid_domain_name(:domain_name)
         
     | 
| 
       10 
     | 
    
         
            -
              end
         
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
              it 'should accept without a specified attribute' do
         
     | 
| 
       13 
     | 
    
         
            -
                expect(@server).to require_a_valid_domain_name
         
     | 
| 
       14 
     | 
    
         
            -
              end
         
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
              it 'should reject on host_name' do
         
     | 
| 
       17 
     | 
    
         
            -
                expect(@server).not_to require_a_valid_domain_name(:host_name)
         
     | 
| 
       18 
     | 
    
         
            -
              end
         
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
              it 'should have a description message' do
         
     | 
| 
       21 
     | 
    
         
            -
                expect(require_a_valid_domain_name.description).to eq('require domain_name to be a valid domain name')
         
     | 
| 
       22 
     | 
    
         
            -
              end
         
     | 
| 
       23 
     | 
    
         
            -
            end
         
     | 
| 
         @@ -1,23 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require 'spec_helper'
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            describe Shoulda::Matchers::ActiveModel::RequireAValidHostNameMatcher do
         
     | 
| 
       4 
     | 
    
         
            -
              before :each do
         
     | 
| 
       5 
     | 
    
         
            -
                @server = Server.new
         
     | 
| 
       6 
     | 
    
         
            -
              end
         
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
              it 'should accept on host_name' do
         
     | 
| 
       9 
     | 
    
         
            -
                expect(@server).to require_a_valid_host_name(:host_name)
         
     | 
| 
       10 
     | 
    
         
            -
              end
         
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
              it 'should accept without a specified attribute' do
         
     | 
| 
       13 
     | 
    
         
            -
                expect(@server).to require_a_valid_host_name
         
     | 
| 
       14 
     | 
    
         
            -
              end
         
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
              it 'should reject on domain_name' do
         
     | 
| 
       17 
     | 
    
         
            -
                expect(@server).not_to require_a_valid_host_name(:domain_name)
         
     | 
| 
       18 
     | 
    
         
            -
              end
         
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
              it 'should have a description message' do
         
     | 
| 
       21 
     | 
    
         
            -
                expect(require_a_valid_host_name.description).to eq('require host_name to be a valid host name')
         
     | 
| 
       22 
     | 
    
         
            -
              end
         
     | 
| 
       23 
     | 
    
         
            -
            end
         
     | 
| 
         @@ -1,23 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require 'spec_helper'
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            describe Shoulda::Matchers::ActiveModel::RequireAValidIpMatcher do
         
     | 
| 
       4 
     | 
    
         
            -
              before :each do
         
     | 
| 
       5 
     | 
    
         
            -
                @server = Server.new
         
     | 
| 
       6 
     | 
    
         
            -
              end
         
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
              it 'should accept on ip' do
         
     | 
| 
       9 
     | 
    
         
            -
                expect(@server).to require_a_valid_ip(:ip)
         
     | 
| 
       10 
     | 
    
         
            -
              end
         
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
              it 'should accept without a specified attribute' do
         
     | 
| 
       13 
     | 
    
         
            -
                expect(@server).to require_a_valid_ip
         
     | 
| 
       14 
     | 
    
         
            -
              end
         
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
              it 'should reject on domain_name' do
         
     | 
| 
       17 
     | 
    
         
            -
                expect(@server).not_to require_a_valid_ip(:domain_name)
         
     | 
| 
       18 
     | 
    
         
            -
              end
         
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
              it 'should have a description message' do
         
     | 
| 
       21 
     | 
    
         
            -
                expect(require_a_valid_ip.description).to eq('require ip to be a valid ip')
         
     | 
| 
       22 
     | 
    
         
            -
              end
         
     | 
| 
       23 
     | 
    
         
            -
            end
         
     | 
| 
         @@ -1,23 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require 'spec_helper'
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            describe Shoulda::Matchers::ActiveModel::RequireAValidSubnetMatcher do
         
     | 
| 
       4 
     | 
    
         
            -
              before :each do
         
     | 
| 
       5 
     | 
    
         
            -
                @subnet = Subnet.new
         
     | 
| 
       6 
     | 
    
         
            -
              end
         
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
              it 'should accept on value' do
         
     | 
| 
       9 
     | 
    
         
            -
                expect(@subnet).to require_a_valid_subnet(:value)
         
     | 
| 
       10 
     | 
    
         
            -
              end
         
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
              it 'should accept without a specified attribute' do
         
     | 
| 
       13 
     | 
    
         
            -
                expect(@subnet).to require_a_valid_subnet
         
     | 
| 
       14 
     | 
    
         
            -
              end
         
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
              it 'should reject on id' do
         
     | 
| 
       17 
     | 
    
         
            -
                expect(@subnet).not_to require_a_valid_subnet(:id)
         
     | 
| 
       18 
     | 
    
         
            -
              end
         
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
              it 'should have a description message' do
         
     | 
| 
       21 
     | 
    
         
            -
                expect(require_a_valid_subnet.description).to eq('require value to be a valid subnet')
         
     | 
| 
       22 
     | 
    
         
            -
              end
         
     | 
| 
       23 
     | 
    
         
            -
            end
         
     |