validates_host 0.3.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +5 -4
  3. data/.ruby-gemset +1 -0
  4. data/.ruby-version +1 -0
  5. data/.travis.yml +16 -1
  6. data/README.md +14 -9
  7. data/gemfiles/Gemfile.rails3 +6 -0
  8. data/gemfiles/Gemfile.rails4 +5 -0
  9. data/lib/validates_host/domain_name.rb +16 -0
  10. data/lib/validates_host/domain_name_validator.rb +1 -19
  11. data/lib/validates_host/host_name.rb +16 -0
  12. data/lib/validates_host/host_name_validator.rb +1 -19
  13. data/lib/validates_host/ip.rb +16 -0
  14. data/lib/validates_host/ip_validator.rb +1 -19
  15. data/lib/validates_host/{shoulda-matchers/domain_name_matcher.rb → require_a_valid_domain_name_matcher.rb} +2 -2
  16. data/lib/validates_host/{shoulda-matchers/host_name_matcher.rb → require_a_valid_host_name_matcher.rb} +2 -2
  17. data/lib/validates_host/{shoulda-matchers/ip_matcher.rb → require_a_valid_ip_matcher.rb} +2 -2
  18. data/lib/validates_host/{shoulda-matchers/subnet_matcher.rb → require_a_valid_subnet_matcher.rb} +2 -2
  19. data/lib/validates_host/subnet.rb +16 -0
  20. data/lib/validates_host/subnet_validator.rb +1 -19
  21. data/lib/validates_host/version.rb +2 -2
  22. data/lib/validates_host.rb +13 -6
  23. data/spec/fake_app/server.rb +13 -1
  24. data/spec/fake_app/subnet.rb +13 -1
  25. data/spec/spec_helper.rb +8 -9
  26. data/spec/validates_host/{shoulda-matchers/domain_name_matcher_spec.rb → require_a_valid_domain_name_matcher_spec.rb} +1 -2
  27. data/spec/validates_host/{shoulda-matchers/host_name_matcher_spec.rb → require_a_valid_host_name_matcher_spec.rb} +1 -2
  28. data/spec/validates_host/{shoulda-matchers/ip_matcher_spec.rb → require_a_valid_ip_matcher_spec.rb} +1 -2
  29. data/spec/validates_host/{shoulda-matchers/subnet_matcher_spec.rb → require_a_valid_subnet_matcher_spec.rb} +1 -2
  30. data/validates_host.gemspec +17 -18
  31. metadata +55 -107
  32. data/.rvmrc +0 -1
  33. data/lib/validates_host/remarkable/domain_name_matcher.rb +0 -29
  34. data/lib/validates_host/remarkable/host_name_matcher.rb +0 -29
  35. data/lib/validates_host/remarkable/ip_matcher.rb +0 -29
  36. data/lib/validates_host/remarkable/subnet_matcher.rb +0 -29
  37. data/lib/validates_host/remarkable.rb +0 -4
  38. data/lib/validates_host/shoulda-matchers.rb +0 -4
  39. data/spec/fake_app/db/migrations/create_servers.rb +0 -13
  40. data/spec/fake_app/db/migrations/create_subnets.rb +0 -12
  41. data/spec/validates_host/remarkable/domain_name_matcher_spec.rb +0 -20
  42. data/spec/validates_host/remarkable/host_name_matcher_spec.rb +0 -20
  43. data/spec/validates_host/remarkable/ip_matcher_spec.rb +0 -20
  44. data/spec/validates_host/remarkable/subnet_matcher_spec.rb +0 -20
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9119afe646e4f4c22c958cbe83bdbd5a20816d14
4
+ data.tar.gz: 9c469eff107d97f76f5a5030fcc28023ba404656
5
+ SHA512:
6
+ metadata.gz: 1246fba586ce19f532bb2d02ac0d26156354d723e612994b717e5b4b18fdd280664722492317ef9a728c996023c4a8886d638ddf39acb967c0e011295c1816a7
7
+ data.tar.gz: af59833df940100079fb42086ae9cd4503a383ad9cde070446bfd43aa75a360a3560ca8bf2cd49f54cd602b6f6da5638e282331c0277e29fab03f4c0c563fdc0
data/.gitignore CHANGED
@@ -3,7 +3,8 @@
3
3
  .bundle
4
4
  .config
5
5
  .yardoc
6
- .rvmrc
6
+ .coveralls.yml
7
+ *.swp
7
8
  Gemfile.lock
8
9
  InstalledFiles
9
10
  _yardoc
@@ -13,6 +14,6 @@ lib/bundler/man
13
14
  pkg
14
15
  rdoc
15
16
  spec/reports
16
- test/tmp
17
- test/version_tmp
18
- tmp
17
+ tmp
18
+ .*~
19
+ *~
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ validates_host
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.0.0
data/.travis.yml CHANGED
@@ -1,4 +1,19 @@
1
1
  rvm:
2
2
  - 1.8.7
3
3
  - 1.9.2
4
- - 1.9.3
4
+ - 1.9.3
5
+ - 2.0.0
6
+ - 2.1.0
7
+ - jruby
8
+ - ree
9
+ gemfile:
10
+ - gemfiles/Gemfile.rails3
11
+ - gemfiles/Gemfile.rails4
12
+ matrix:
13
+ exclude:
14
+ - rvm: 1.8.7
15
+ gemfile: gemfiles/Gemfile.rails4
16
+ - rvm: 1.9.2
17
+ gemfile: gemfiles/Gemfile.rails4
18
+ - rvm: ree
19
+ gemfile: gemfiles/Gemfile.rails4
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
- # ValidatesHost [![Build Status](https://secure.travis-ci.org/plribeiro3000/validates_host.png?branch=master)](http://travis-ci.org/plribeiro3000/validates_host)
1
+ # ValidatesHost
2
2
 
3
- Rails gem to validate Host Related fields.
3
+ [![Gem Version](https://badge.fury.io/rb/validates_host.png)](http://badge.fury.io/rb/validates_host) [![Build Status](https://secure.travis-ci.org/plribeiro3000/validates_host.png?branch=master)](http://travis-ci.org/plribeiro3000/validates_host) [![Dependency Status](https://gemnasium.com/plribeiro3000/validates_host.png)](https://gemnasium.com/plribeiro3000/validates_host) [![Coverage Status](https://coveralls.io/repos/plribeiro3000/validates_host/badge.png?branch=master)](https://coveralls.io/r/plribeiro3000/validates_host) [![Code Climate](https://codeclimate.com/github/plribeiro3000/validates_host.png)](https://codeclimate.com/github/plribeiro3000/validates_host)
4
+
5
+ Validates host attributes and test it in a simple way
4
6
 
5
7
  ## Installation
6
8
 
@@ -18,23 +20,26 @@ Or install it yourself as:
18
20
 
19
21
  ## Usage
20
22
 
21
- Lets say you have a model that you want to have valid host fields. Just add this to your model:
23
+ Just use like any other validator:
22
24
 
23
25
  ```ruby
24
26
  class Server < ActiveRecord::Base
25
- validates :domain_name, :domain_name => true
26
- validates :host_name, :host_name => true
27
- validates :ip, :ip => true
27
+ validates :domain_name, domain_name: true
28
+ validates :host_name, host_name: true
29
+ validates :ip, ip: true
28
30
  end
29
31
 
30
32
  class Subnet < ActiveRecord::Base
31
- validates :value, :subnet => true
33
+ validates :value, subnet: true
32
34
  end
33
35
  ```
34
36
 
35
- ## Test
37
+ ## Notes
38
+
39
+ It will load a macher to test automatically if the gem is below shoulda-matchers.
36
40
 
37
- This gem has builtin matchers for shoulda-matchers and remarkable.
41
+ ## Mantainers
42
+ [@plribeiro3000](https://github.com/plribeiro3000)
38
43
 
39
44
  ## Contributing
40
45
 
@@ -0,0 +1,6 @@
1
+ source :rubygems
2
+
3
+ gem 'activesupport', '3.2.14'
4
+ gem 'mime-types', '< 2.0'
5
+
6
+ gemspec :path => '../'
@@ -0,0 +1,5 @@
1
+ source :rubygems
2
+
3
+ gem 'activesupport', '>= 4.0.0'
4
+
5
+ gemspec :path => '../'
@@ -0,0 +1,16 @@
1
+ module ValidatesHost
2
+ class DomainName
3
+ def initialize(domain_name)
4
+ @domain_name = domain_name
5
+ end
6
+
7
+ def valid?
8
+ return true if @domain_name.blank?
9
+ @domain_name =~ /^[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$/
10
+ end
11
+
12
+ def domain_name
13
+ @domain_name
14
+ end
15
+ end
16
+ end
@@ -1,23 +1,5 @@
1
1
  class DomainNameValidator < ActiveModel::EachValidator
2
2
  def validate_each(record, attribute, value)
3
- key = :"activerecord.errors.models.#{record.class.name.downcase}.attributes.#{attribute.to_s}.invalid"
4
- record.errors[attribute] << I18n.t(key, :default => :"activerecord.errors.messages.invalid") unless ValidatesHost::DomainName.new(value).valid?
5
- end
6
- end
7
-
8
- module ValidatesHost
9
- class DomainName
10
- def initialize(domain_name)
11
- @domain_name = domain_name
12
- end
13
-
14
- def valid?
15
- return true if @domain_name.nil?
16
- @domain_name =~ /^[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$/
17
- end
18
-
19
- def domain_name
20
- @domain_name
21
- end
3
+ record.errors.add(attribute, :invalid, options) unless ValidatesHost::DomainName.new(value).valid?
22
4
  end
23
5
  end
@@ -0,0 +1,16 @@
1
+ module ValidatesHost
2
+ class HostName
3
+ def initialize(host_name)
4
+ @host_name = host_name
5
+ end
6
+
7
+ def valid?
8
+ return true if @host_name.blank?
9
+ @host_name =~ /^[a-z][a-z0-9-]+$/
10
+ end
11
+
12
+ def host_name
13
+ @host_name
14
+ end
15
+ end
16
+ end
@@ -1,23 +1,5 @@
1
1
  class HostNameValidator < ActiveModel::EachValidator
2
2
  def validate_each(record, attribute, value)
3
- key = :"activerecord.errors.models.#{record.class.name.downcase}.attributes.#{attribute.to_s}.invalid"
4
- record.errors[attribute] << I18n.t(key, :default => :"activerecord.errors.messages.invalid") unless ValidatesHost::HostName.new(value).valid?
5
- end
6
- end
7
-
8
- module ValidatesHost
9
- class HostName
10
- def initialize(host_name)
11
- @host_name = host_name
12
- end
13
-
14
- def valid?
15
- return true if @host_name.blank?
16
- @host_name =~ /^[a-z][a-z0-9-]+$/
17
- end
18
-
19
- def host_name
20
- @host_name
21
- end
3
+ record.errors.add(attribute, :invalid, options) unless ValidatesHost::HostName.new(value).valid?
22
4
  end
23
5
  end
@@ -0,0 +1,16 @@
1
+ module ValidatesHost
2
+ class Ip
3
+ def initialize(ip)
4
+ @ip = ip
5
+ end
6
+
7
+ def valid?
8
+ return true if @ip.blank?
9
+ @ip =~ /^([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}$/
10
+ end
11
+
12
+ def ip
13
+ @ip
14
+ end
15
+ end
16
+ end
@@ -1,23 +1,5 @@
1
1
  class IpValidator < ActiveModel::EachValidator
2
2
  def validate_each(record, attribute, value)
3
- key = :"activerecord.errors.models.#{record.class.name.downcase}.attributes.#{attribute.to_s}.invalid"
4
- record.errors[attribute] << I18n.t(key, :default => :"activerecord.errors.messages.invalid") unless ValidatesHost::Ip.new(value).valid?
5
- end
6
- end
7
-
8
- module ValidatesHost
9
- class Ip
10
- def initialize(ip)
11
- @ip = ip
12
- end
13
-
14
- def valid?
15
- return true if @ip.blank?
16
- @ip =~ /^([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}$/
17
- end
18
-
19
- def ip
20
- @ip
21
- end
3
+ record.errors.add(attribute, :invalid, options) unless ValidatesHost::Ip.new(value).valid?
22
4
  end
23
5
  end
@@ -4,10 +4,10 @@ module Shoulda
4
4
  module Matchers
5
5
  module ActiveModel
6
6
  def require_a_valid_domain_name(attribute = :domain_name)
7
- DomainNameMatcher.new(attribute)
7
+ RequireAValidDomainNameMatcher.new(attribute)
8
8
  end
9
9
 
10
- class DomainNameMatcher < ValidationMatcher
10
+ class RequireAValidDomainNameMatcher < ValidationMatcher
11
11
  def initialize(attribute)
12
12
  @attribute = attribute
13
13
  end
@@ -4,10 +4,10 @@ module Shoulda
4
4
  module Matchers
5
5
  module ActiveModel
6
6
  def require_a_valid_host_name(attribute = :host_name)
7
- HostNameMatcher.new(attribute)
7
+ RequireAValidHostNameMatcher.new(attribute)
8
8
  end
9
9
 
10
- class HostNameMatcher < ValidationMatcher
10
+ class RequireAValidHostNameMatcher < ValidationMatcher
11
11
  def initialize(attribute)
12
12
  @attribute = attribute
13
13
  end
@@ -4,10 +4,10 @@ module Shoulda
4
4
  module Matchers
5
5
  module ActiveModel
6
6
  def require_a_valid_ip(attribute = :ip)
7
- IpMatcher.new(attribute)
7
+ RequireAValidIpMatcher.new(attribute)
8
8
  end
9
9
 
10
- class IpMatcher < ValidationMatcher
10
+ class RequireAValidIpMatcher < ValidationMatcher
11
11
  def initialize(attribute)
12
12
  @attribute = attribute
13
13
  end
@@ -4,10 +4,10 @@ module Shoulda
4
4
  module Matchers
5
5
  module ActiveModel
6
6
  def require_a_valid_subnet(attribute = :value)
7
- SubnetMatcher.new(attribute)
7
+ RequireAValidSubnetMatcher.new(attribute)
8
8
  end
9
9
 
10
- class SubnetMatcher < ValidationMatcher
10
+ class RequireAValidSubnetMatcher < ValidationMatcher
11
11
  def initialize(attribute)
12
12
  @attribute = attribute
13
13
  end
@@ -0,0 +1,16 @@
1
+ module ValidatesHost
2
+ class Subnet
3
+ def initialize(subnet)
4
+ @subnet = subnet
5
+ end
6
+
7
+ def valid?
8
+ return true if @subnet.blank?
9
+ @subnet =~ /^([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
+ end
11
+
12
+ def subnet
13
+ @subnet
14
+ end
15
+ end
16
+ end
@@ -1,23 +1,5 @@
1
1
  class SubnetValidator < ActiveModel::EachValidator
2
2
  def validate_each(record, attribute, value)
3
- key = :"activerecord.errors.models.#{record.class.name.downcase}.attributes.#{attribute.to_s}.invalid"
4
- record.errors[attribute] << I18n.t(key, :default => :"activerecord.errors.messages.invalid") unless ValidatesHost::Subnet.new(value).valid?
5
- end
6
- end
7
-
8
- module ValidatesHost
9
- class Subnet
10
- def initialize(subnet)
11
- @subnet = subnet
12
- end
13
-
14
- def valid?
15
- return true if @subnet.blank?
16
- @subnet =~ /^([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)$/
17
- end
18
-
19
- def subnet
20
- @subnet
21
- end
3
+ record.errors.add(attribute, :invalid, options) unless ValidatesHost::Subnet.new(value).valid?
22
4
  end
23
5
  end
@@ -1,3 +1,3 @@
1
1
  module ValidatesHost
2
- VERSION = "0.3.1"
3
- end
2
+ VERSION = '1.0.0'
3
+ end
@@ -1,12 +1,19 @@
1
- require "validates_host/version"
2
-
3
- #ActiveModel Validators
1
+ require 'active_support/core_ext/array/wrap'
4
2
  require 'validates_host/host_name_validator'
5
3
  require 'validates_host/domain_name_validator'
6
4
  require 'validates_host/ip_validator'
7
5
  require 'validates_host/subnet_validator'
8
6
 
7
+ if defined?(::Shoulda)
8
+ require 'validates_host/require_a_valid_domain_name_matcher'
9
+ require 'validates_host/require_a_valid_host_name_matcher'
10
+ require 'validates_host/require_a_valid_ip_matcher'
11
+ require 'validates_host/require_a_valid_subnet_matcher'
12
+ end
9
13
 
10
- #Rspec Matchers
11
- require "validates_host/shoulda-matchers" if defined?(::Shoulda)
12
- require "validates_host/remarkable" if defined?(::Remarkable)
14
+ module ValidatesHost
15
+ autoload :Subnet, 'validates_host/subnet'
16
+ autoload :Ip, 'validates_host/ip'
17
+ autoload :HostName, 'validates_host/host_name'
18
+ autoload :DomainName, 'validates_host/domain_name'
19
+ end
@@ -1,5 +1,17 @@
1
- class Server < ActiveRecord::Base
1
+ class Server
2
+ include ActiveModel::Validations
3
+ include ActiveModel::Conversion
4
+ extend ActiveModel::Naming
5
+
6
+ attr_accessor :domain_name, :host_name, :ip
7
+
2
8
  validates :domain_name, :domain_name => true
3
9
  validates :host_name, :host_name => true
4
10
  validates :ip, :ip => true
11
+
12
+ def initialize(attributes = {})
13
+ attributes.each do |name, value|
14
+ send("#{name}=", value)
15
+ end
16
+ end
5
17
  end
@@ -1,3 +1,15 @@
1
- class Subnet < ActiveRecord::Base
1
+ class Subnet
2
+ include ActiveModel::Validations
3
+ include ActiveModel::Conversion
4
+ extend ActiveModel::Naming
5
+
6
+ attr_accessor :id, :value
7
+
2
8
  validates :value, :subnet => true
9
+
10
+ def initialize(attributes = {})
11
+ attributes.each do |name, value|
12
+ send("#{name}=", value)
13
+ end
14
+ end
3
15
  end
data/spec/spec_helper.rb CHANGED
@@ -1,11 +1,10 @@
1
- require "rubygems"
2
- require "rspec"
3
- require "active_record"
1
+ require 'rspec'
2
+ require 'active_model'
3
+ require 'coveralls'
4
+ require 'shoulda-matchers'
4
5
 
5
- Dir.glob(File.dirname(__FILE__) + "/../lib/**/*.rb").each { |file| require file }
6
- Dir.glob(File.dirname(__FILE__) + "/fake_app/**/*.rb").each { |file| require file }
6
+ Coveralls.wear!
7
7
 
8
- ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :database => ":memory:")
9
-
10
- CreateServers.migrate(:up)
11
- CreateSubnets.migrate(:up)
8
+ require 'validates_host'
9
+ require 'fake_app/server'
10
+ require 'fake_app/subnet'
@@ -1,7 +1,6 @@
1
1
  require 'spec_helper'
2
- require 'shoulda-matchers'
3
2
 
4
- describe Shoulda::Matchers::ActiveModel::DomainNameMatcher do
3
+ describe Shoulda::Matchers::ActiveModel::RequireAValidDomainNameMatcher do
5
4
  before :each do
6
5
  @server = Server.new
7
6
  end
@@ -1,7 +1,6 @@
1
1
  require 'spec_helper'
2
- require 'shoulda-matchers'
3
2
 
4
- describe Shoulda::Matchers::ActiveModel::HostNameMatcher do
3
+ describe Shoulda::Matchers::ActiveModel::RequireAValidHostNameMatcher do
5
4
  before :each do
6
5
  @server = Server.new
7
6
  end
@@ -1,7 +1,6 @@
1
1
  require 'spec_helper'
2
- require 'shoulda-matchers'
3
2
 
4
- describe Shoulda::Matchers::ActiveModel::IpMatcher do
3
+ describe Shoulda::Matchers::ActiveModel::RequireAValidIpMatcher do
5
4
  before :each do
6
5
  @server = Server.new
7
6
  end
@@ -1,7 +1,6 @@
1
1
  require 'spec_helper'
2
- require 'shoulda-matchers'
3
2
 
4
- describe Shoulda::Matchers::ActiveModel::SubnetMatcher do
3
+ describe Shoulda::Matchers::ActiveModel::RequireAValidSubnetMatcher do
5
4
  before :each do
6
5
  @subnet = Subnet.new
7
6
  end
@@ -2,24 +2,23 @@
2
2
  require File.expand_path('../lib/validates_host/version', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |gem|
5
- gem.authors = ["Paulo Henrique Lopes Ribeiro"]
6
- gem.email = %q{plribeiro3000@gmail.com}
7
- gem.description = %q{Validates Host, Domain and IP}
8
- gem.summary = %q{Host Validation Gem}
9
- gem.homepage = ""
5
+ gem.name = 'validates_host'
6
+ gem.version = ValidatesHost::VERSION
7
+ gem.authors = %q{Paulo Henrique Lopes Ribeiro}
8
+ gem.email = %q{plribeiro3000@gmail.com}
9
+ gem.summary = %q{Validates Host, Domain and IP and test it with matchers in a simple way.}
10
10
 
11
11
  gem.files = `git ls-files`.split($\)
12
- gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
- gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
- gem.name = "validates_host"
15
- gem.require_paths = ["lib"]
16
- gem.version = ValidatesHost::VERSION
12
+ 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(lib)
17
15
 
18
- gem.add_dependency "activemodel", ">= 3.0.0"
19
- gem.add_development_dependency "activerecord", ">= 3.0.0"
20
- gem.add_development_dependency "rake"
21
- gem.add_development_dependency "rspec", ">= 2.0.0"
22
- gem.add_development_dependency "shoulda-matchers", ">= 1.0.0"
23
- gem.add_development_dependency "remarkable_activerecord", "= 4.0.0.alpha4"
24
- gem.add_development_dependency "sqlite3"
25
- end
16
+ gem.license = 'MIT'
17
+
18
+ gem.add_development_dependency 'rake'
19
+ gem.add_development_dependency 'rspec'
20
+ gem.add_development_dependency 'shoulda-matchers', '2.0.0'
21
+ gem.add_development_dependency 'coveralls'
22
+
23
+ gem.add_dependency 'activemodel', '>= 3.0.0'
24
+ end
metadata CHANGED
@@ -1,129 +1,86 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: validates_host
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
5
- prerelease:
4
+ version: 1.0.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Paulo Henrique Lopes Ribeiro
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-08-26 00:00:00.000000000 Z
11
+ date: 2014-02-24 00:00:00.000000000 Z
13
12
  dependencies:
14
- - !ruby/object:Gem::Dependency
15
- name: activemodel
16
- requirement: !ruby/object:Gem::Requirement
17
- none: false
18
- requirements:
19
- - - ! '>='
20
- - !ruby/object:Gem::Version
21
- version: 3.0.0
22
- type: :runtime
23
- prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ! '>='
28
- - !ruby/object:Gem::Version
29
- version: 3.0.0
30
- - !ruby/object:Gem::Dependency
31
- name: activerecord
32
- requirement: !ruby/object:Gem::Requirement
33
- none: false
34
- requirements:
35
- - - ! '>='
36
- - !ruby/object:Gem::Version
37
- version: 3.0.0
38
- type: :development
39
- prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ! '>='
44
- - !ruby/object:Gem::Version
45
- version: 3.0.0
46
13
  - !ruby/object:Gem::Dependency
47
14
  name: rake
48
15
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
16
  requirements:
51
- - - ! '>='
17
+ - - '>='
52
18
  - !ruby/object:Gem::Version
53
19
  version: '0'
54
20
  type: :development
55
21
  prerelease: false
56
22
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
23
  requirements:
59
- - - ! '>='
24
+ - - '>='
60
25
  - !ruby/object:Gem::Version
61
26
  version: '0'
62
27
  - !ruby/object:Gem::Dependency
63
28
  name: rspec
64
29
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
30
  requirements:
67
- - - ! '>='
31
+ - - '>='
68
32
  - !ruby/object:Gem::Version
69
- version: 2.0.0
33
+ version: '0'
70
34
  type: :development
71
35
  prerelease: false
72
36
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
37
  requirements:
75
- - - ! '>='
38
+ - - '>='
76
39
  - !ruby/object:Gem::Version
77
- version: 2.0.0
40
+ version: '0'
78
41
  - !ruby/object:Gem::Dependency
79
42
  name: shoulda-matchers
80
43
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
44
  requirements:
83
- - - ! '>='
45
+ - - '='
84
46
  - !ruby/object:Gem::Version
85
- version: 1.0.0
47
+ version: 2.0.0
86
48
  type: :development
87
49
  prerelease: false
88
50
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
51
  requirements:
91
- - - ! '>='
52
+ - - '='
92
53
  - !ruby/object:Gem::Version
93
- version: 1.0.0
54
+ version: 2.0.0
94
55
  - !ruby/object:Gem::Dependency
95
- name: remarkable_activerecord
56
+ name: coveralls
96
57
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
58
  requirements:
99
- - - '='
59
+ - - '>='
100
60
  - !ruby/object:Gem::Version
101
- version: 4.0.0.alpha4
61
+ version: '0'
102
62
  type: :development
103
63
  prerelease: false
104
64
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
65
  requirements:
107
- - - '='
66
+ - - '>='
108
67
  - !ruby/object:Gem::Version
109
- version: 4.0.0.alpha4
68
+ version: '0'
110
69
  - !ruby/object:Gem::Dependency
111
- name: sqlite3
70
+ name: activemodel
112
71
  requirement: !ruby/object:Gem::Requirement
113
- none: false
114
72
  requirements:
115
- - - ! '>='
73
+ - - '>='
116
74
  - !ruby/object:Gem::Version
117
- version: '0'
118
- type: :development
75
+ version: 3.0.0
76
+ type: :runtime
119
77
  prerelease: false
120
78
  version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
79
  requirements:
123
- - - ! '>='
80
+ - - '>='
124
81
  - !ruby/object:Gem::Version
125
- version: '0'
126
- description: Validates Host, Domain and IP
82
+ version: 3.0.0
83
+ description:
127
84
  email: plribeiro3000@gmail.com
128
85
  executables: []
129
86
  extensions: []
@@ -131,85 +88,76 @@ extra_rdoc_files: []
131
88
  files:
132
89
  - .gitignore
133
90
  - .rspec
134
- - .rvmrc
91
+ - .ruby-gemset
92
+ - .ruby-version
135
93
  - .travis.yml
136
94
  - Gemfile
137
95
  - LICENSE
138
96
  - README.md
139
97
  - Rakefile
98
+ - gemfiles/Gemfile.rails3
99
+ - gemfiles/Gemfile.rails4
140
100
  - lib/validates_host.rb
101
+ - lib/validates_host/domain_name.rb
141
102
  - lib/validates_host/domain_name_validator.rb
103
+ - lib/validates_host/host_name.rb
142
104
  - lib/validates_host/host_name_validator.rb
105
+ - lib/validates_host/ip.rb
143
106
  - lib/validates_host/ip_validator.rb
144
- - lib/validates_host/remarkable.rb
145
- - lib/validates_host/remarkable/domain_name_matcher.rb
146
- - lib/validates_host/remarkable/host_name_matcher.rb
147
- - lib/validates_host/remarkable/ip_matcher.rb
148
- - lib/validates_host/remarkable/subnet_matcher.rb
149
- - lib/validates_host/shoulda-matchers.rb
150
- - lib/validates_host/shoulda-matchers/domain_name_matcher.rb
151
- - lib/validates_host/shoulda-matchers/host_name_matcher.rb
152
- - lib/validates_host/shoulda-matchers/ip_matcher.rb
153
- - lib/validates_host/shoulda-matchers/subnet_matcher.rb
107
+ - lib/validates_host/require_a_valid_domain_name_matcher.rb
108
+ - lib/validates_host/require_a_valid_host_name_matcher.rb
109
+ - lib/validates_host/require_a_valid_ip_matcher.rb
110
+ - lib/validates_host/require_a_valid_subnet_matcher.rb
111
+ - lib/validates_host/subnet.rb
154
112
  - lib/validates_host/subnet_validator.rb
155
113
  - lib/validates_host/version.rb
156
- - spec/fake_app/db/migrations/create_servers.rb
157
- - spec/fake_app/db/migrations/create_subnets.rb
158
114
  - spec/fake_app/server.rb
159
115
  - spec/fake_app/subnet.rb
160
116
  - spec/spec_helper.rb
161
117
  - spec/validates_host/domain_name_validator_spec.rb
162
118
  - spec/validates_host/host_name_validator_spec.rb
163
119
  - spec/validates_host/ip_validator_spec.rb
164
- - spec/validates_host/remarkable/domain_name_matcher_spec.rb
165
- - spec/validates_host/remarkable/host_name_matcher_spec.rb
166
- - spec/validates_host/remarkable/ip_matcher_spec.rb
167
- - spec/validates_host/remarkable/subnet_matcher_spec.rb
168
- - spec/validates_host/shoulda-matchers/domain_name_matcher_spec.rb
169
- - spec/validates_host/shoulda-matchers/host_name_matcher_spec.rb
170
- - spec/validates_host/shoulda-matchers/ip_matcher_spec.rb
171
- - spec/validates_host/shoulda-matchers/subnet_matcher_spec.rb
120
+ - spec/validates_host/require_a_valid_domain_name_matcher_spec.rb
121
+ - spec/validates_host/require_a_valid_host_name_matcher_spec.rb
122
+ - spec/validates_host/require_a_valid_ip_matcher_spec.rb
123
+ - spec/validates_host/require_a_valid_subnet_matcher_spec.rb
172
124
  - spec/validates_host/subnet_validator_spec.rb
173
125
  - validates_host.gemspec
174
- homepage: ''
175
- licenses: []
126
+ homepage:
127
+ licenses:
128
+ - MIT
129
+ metadata: {}
176
130
  post_install_message:
177
131
  rdoc_options: []
178
132
  require_paths:
179
133
  - lib
180
134
  required_ruby_version: !ruby/object:Gem::Requirement
181
- none: false
182
135
  requirements:
183
- - - ! '>='
136
+ - - '>='
184
137
  - !ruby/object:Gem::Version
185
138
  version: '0'
186
139
  required_rubygems_version: !ruby/object:Gem::Requirement
187
- none: false
188
140
  requirements:
189
- - - ! '>='
141
+ - - '>='
190
142
  - !ruby/object:Gem::Version
191
143
  version: '0'
192
144
  requirements: []
193
145
  rubyforge_project:
194
- rubygems_version: 1.8.24
146
+ rubygems_version: 2.1.11
195
147
  signing_key:
196
- specification_version: 3
197
- summary: Host Validation Gem
148
+ specification_version: 4
149
+ summary: Validates Host, Domain and IP and test it with matchers in a simple way.
198
150
  test_files:
199
- - spec/fake_app/db/migrations/create_servers.rb
200
- - spec/fake_app/db/migrations/create_subnets.rb
151
+ - gemfiles/Gemfile.rails3
152
+ - gemfiles/Gemfile.rails4
201
153
  - spec/fake_app/server.rb
202
154
  - spec/fake_app/subnet.rb
203
155
  - spec/spec_helper.rb
204
156
  - spec/validates_host/domain_name_validator_spec.rb
205
157
  - spec/validates_host/host_name_validator_spec.rb
206
158
  - spec/validates_host/ip_validator_spec.rb
207
- - spec/validates_host/remarkable/domain_name_matcher_spec.rb
208
- - spec/validates_host/remarkable/host_name_matcher_spec.rb
209
- - spec/validates_host/remarkable/ip_matcher_spec.rb
210
- - spec/validates_host/remarkable/subnet_matcher_spec.rb
211
- - spec/validates_host/shoulda-matchers/domain_name_matcher_spec.rb
212
- - spec/validates_host/shoulda-matchers/host_name_matcher_spec.rb
213
- - spec/validates_host/shoulda-matchers/ip_matcher_spec.rb
214
- - spec/validates_host/shoulda-matchers/subnet_matcher_spec.rb
159
+ - spec/validates_host/require_a_valid_domain_name_matcher_spec.rb
160
+ - spec/validates_host/require_a_valid_host_name_matcher_spec.rb
161
+ - spec/validates_host/require_a_valid_ip_matcher_spec.rb
162
+ - spec/validates_host/require_a_valid_subnet_matcher_spec.rb
215
163
  - spec/validates_host/subnet_validator_spec.rb
data/.rvmrc DELETED
@@ -1 +0,0 @@
1
- rvm use 1.9.3@validates_host
@@ -1,29 +0,0 @@
1
- require 'remarkable/active_model'
2
-
3
- module Remarkable
4
- module ActiveModel
5
- module Matchers
6
- class DomainNameMatcher < Remarkable::ActiveModel::Base
7
- arguments :domain_name
8
-
9
- collection_assertions :accept_valid_value?, :reject_valid_value?
10
-
11
- protected
12
-
13
- def accept_valid_value?
14
- @subject.domain_name = 'example.com'
15
- @subject.valid?.errors[:domain_name].should == []
16
- end
17
-
18
- def reject_valid_value?
19
- @subject.domain_name = 'example'
20
- @subject.valid?.errors[:domain_name].should == ['is invalid']
21
- end
22
- end
23
-
24
- def require_a_valid_domain_name(*args, &block)
25
- DomainNameMatcher.new(*args, &block).spec(self)
26
- end
27
- end
28
- end
29
- end
@@ -1,29 +0,0 @@
1
- require 'remarkable/active_model'
2
-
3
- module Remarkable
4
- module ActiveModel
5
- module Matchers
6
- class HostNameMatcher < Remarkable::ActiveModel::Base
7
- arguments :host_name
8
-
9
- collection_assertions :accept_valid_value?, :reject_valid_value?
10
-
11
- protected
12
-
13
- def accept_valid_value?
14
- @subject.domain_name = 'bd01'
15
- @subject.valid?.errors[:host_name].should == []
16
- end
17
-
18
- def reject_valid_value?
19
- @subject.domain_name = '01'
20
- @subject.valid?.errors[:host_name].should == ['is invalid']
21
- end
22
- end
23
-
24
- def require_a_valid_domain_name(*args, &block)
25
- HostNameMatcher.new(*args, &block).spec(self)
26
- end
27
- end
28
- end
29
- end
@@ -1,29 +0,0 @@
1
- require 'remarkable/active_model'
2
-
3
- module Remarkable
4
- module ActiveModel
5
- module Matchers
6
- class IpMatcher < Remarkable::ActiveModel::Base
7
- arguments :ip
8
-
9
- collection_assertions :accept_valid_value?, :reject_valid_value?
10
-
11
- protected
12
-
13
- def accept_valid_value?
14
- @subject.domain_name = '10.10.10.1'
15
- @subject.valid?.errors[:ip].should == []
16
- end
17
-
18
- def reject_valid_value?
19
- @subject.domain_name = '01'
20
- @subject.valid?.errors[:ip].should == ['is invalid']
21
- end
22
- end
23
-
24
- def require_a_valid_ip(*args, &block)
25
- IpMatcher.new(*args, &block).spec(self)
26
- end
27
- end
28
- end
29
- end
@@ -1,29 +0,0 @@
1
- require 'remarkable/active_model'
2
-
3
- module Remarkable
4
- module ActiveModel
5
- module Matchers
6
- class SubnetMatcher < Remarkable::ActiveModel::Base
7
- arguments :value
8
-
9
- collection_assertions :accept_valid_value?, :reject_valid_value?
10
-
11
- protected
12
-
13
- def accept_valid_value?
14
- @subject.value = '10.10.10.1/28'
15
- @subject.valid?.errors[:value].should == []
16
- end
17
-
18
- def reject_valid_value?
19
- @subject.value = '01'
20
- @subject.valid?.errors[:value].should == ['is invalid']
21
- end
22
- end
23
-
24
- def require_a_valid_domain_name(*args, &block)
25
- SubnetMatcher.new(*args, &block).spec(self)
26
- end
27
- end
28
- end
29
- end
@@ -1,4 +0,0 @@
1
- require 'validates_host/remarkable/domain_name_matcher'
2
- require 'validates_host/remarkable/host_name_matcher'
3
- require 'validates_host/remarkable/ip_matcher'
4
- require 'validates_host/remarkable/subnet_matcher'
@@ -1,4 +0,0 @@
1
- require 'validates_host/shoulda-matchers/domain_name_matcher'
2
- require 'validates_host/shoulda-matchers/host_name_matcher'
3
- require 'validates_host/shoulda-matchers/ip_matcher'
4
- require 'validates_host/shoulda-matchers/subnet_matcher'
@@ -1,13 +0,0 @@
1
- class CreateServers < ActiveRecord::Migration
2
- def self.up
3
- create_table :servers do |s|
4
- s.string :domain_name
5
- s.string :host_name
6
- s.string :ip
7
- end
8
- end
9
-
10
- def self.down
11
- drop_table :servers
12
- end
13
- end
@@ -1,12 +0,0 @@
1
- class CreateSubnets < ActiveRecord::Migration
2
- def self.up
3
- create_table :subnets do |s|
4
- s.integer :id
5
- s.string :value
6
- end
7
- end
8
-
9
- def self.down
10
- drop_table :subnets
11
- end
12
- end
@@ -1,20 +0,0 @@
1
- require 'spec_helper'
2
- require 'remarkable/active_model'
3
-
4
- describe Remarkable::ActiveModel::Matchers::DomainNameMatcher do
5
- before :each do
6
- @server = Server.new
7
- end
8
-
9
- it "should accept on domain_name" do
10
- @server.should require_a_valid_domain_name(:domain_name)
11
- end
12
-
13
- it "should accept without a specified attribute" do
14
- @server.should require_a_valid_domain_name
15
- end
16
-
17
- it "should reject on host_name" do
18
- @server.should_not require_a_valid_domain_name(:host_name)
19
- end
20
- end
@@ -1,20 +0,0 @@
1
- require 'spec_helper'
2
- require 'remarkable/active_model'
3
-
4
- describe Remarkable::ActiveModel::Matchers::HostNameMatcher do
5
- before :each do
6
- @server = Server.new
7
- end
8
-
9
- it "should accept on host_name" do
10
- @server.should require_a_valid_host_name(:host_name)
11
- end
12
-
13
- it "should accept without a specified attribute" do
14
- @server.should require_a_valid_domain_name
15
- end
16
-
17
- it "should reject on domain_name" do
18
- @server.should_not require_a_valid_host_name(:domain_name)
19
- end
20
- end
@@ -1,20 +0,0 @@
1
- require 'spec_helper'
2
- require 'remarkable/active_model'
3
-
4
- describe Remarkable::ActiveModel::Matchers::IpMatcher do
5
- before :each do
6
- @server = Server.new
7
- end
8
-
9
- it "should accept on ip" do
10
- @server.should require_a_valid_ip(:ip)
11
- end
12
-
13
- it "should accept without a specified attribute" do
14
- @server.should require_a_valid_ip
15
- end
16
-
17
- it "should reject on domain_name" do
18
- @server.should_not require_a_valid_ip(:domain_name)
19
- end
20
- end
@@ -1,20 +0,0 @@
1
- require 'spec_helper'
2
- require 'remarkable/active_model'
3
-
4
- describe Remarkable::ActiveModel::Matchers::SubnetMatcher do
5
- before :each do
6
- @subnet = Subnet.new
7
- end
8
-
9
- it "should accept on value" do
10
- @subnet.should require_a_valid_subnet(:value)
11
- end
12
-
13
- it "should accept without a specified attribute" do
14
- @subnet.should require_a_valid_subnet
15
- end
16
-
17
- it "should reject on id" do
18
- @subnet.should_not require_a_valid_subnet(:id)
19
- end
20
- end