validates_host 0.2.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.
Files changed (53) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +5 -4
  3. data/.rubocop.yml +53 -0
  4. data/.ruby-gemset +1 -0
  5. data/.travis.yml +31 -0
  6. data/Gemfile +3 -1
  7. data/README.md +24 -3
  8. data/Rakefile +9 -4
  9. data/gemfiles/Gemfile.rails3 +6 -0
  10. data/gemfiles/Gemfile.rails4 +5 -0
  11. data/gemfiles/Gemfile.rails5 +5 -0
  12. data/lib/validates_host.rb +16 -5
  13. data/lib/validates_host/domain_name.rb +15 -0
  14. data/lib/validates_host/domain_name_validator.rb +3 -19
  15. data/lib/validates_host/host_name.rb +15 -0
  16. data/lib/validates_host/host_name_validator.rb +3 -19
  17. data/lib/validates_host/ip.rb +17 -0
  18. data/lib/validates_host/ip_validator.rb +3 -19
  19. data/lib/validates_host/{shoulda-matchers/domain_name_matcher.rb → require_a_valid_domain_name_matcher.rb} +9 -11
  20. data/lib/validates_host/{shoulda-matchers/host_name_matcher.rb → require_a_valid_host_name_matcher.rb} +9 -11
  21. data/lib/validates_host/{shoulda-matchers/ip_matcher.rb → require_a_valid_ip_matcher.rb} +9 -11
  22. data/lib/validates_host/require_a_valid_subnet_matcher.rb +35 -0
  23. data/lib/validates_host/subnet.rb +15 -0
  24. data/lib/validates_host/subnet_validator.rb +7 -0
  25. data/lib/validates_host/version.rb +3 -1
  26. data/spec/fake_app/server.rb +19 -5
  27. data/spec/fake_app/subnet.rb +11 -0
  28. data/spec/shoulda/matchers/active_model/require_a_valid_domain_name_matcher_spec.rb +23 -0
  29. data/spec/shoulda/matchers/active_model/require_a_valid_host_name_matcher_spec.rb +23 -0
  30. data/spec/shoulda/matchers/active_model/require_a_valid_ip_matcher_spec.rb +23 -0
  31. data/spec/shoulda/matchers/active_model/require_a_valid_subnet_matcher_spec.rb +23 -0
  32. data/spec/spec_helper.rb +11 -7
  33. data/spec/validates_host/domain_name_validator_spec.rb +41 -0
  34. data/spec/validates_host/host_name_validator_spec.rb +41 -0
  35. data/spec/validates_host/ip_validator_spec.rb +56 -0
  36. data/spec/validates_host/subnet_validator_spec.rb +41 -0
  37. data/validates_host.gemspec +22 -19
  38. metadata +89 -88
  39. data/lib/validates_host/remarkable.rb +0 -3
  40. data/lib/validates_host/remarkable/domain_name_matcher.rb +0 -29
  41. data/lib/validates_host/remarkable/host_name_matcher.rb +0 -29
  42. data/lib/validates_host/remarkable/ip_matcher.rb +0 -29
  43. data/lib/validates_host/shoulda-matchers.rb +0 -3
  44. data/spec/fake_app/db/migrations/create_servers.rb +0 -13
  45. data/spec/validates_host.rb/domain_name_validator_spec.rb +0 -40
  46. data/spec/validates_host.rb/host_name_validator_spec.rb +0 -40
  47. data/spec/validates_host.rb/ip_validator_spec.rb +0 -40
  48. data/spec/validates_host.rb/remarkable/domain_name_matcher_spec.rb +0 -20
  49. data/spec/validates_host.rb/remarkable/host_name_matcher_spec.rb +0 -20
  50. data/spec/validates_host.rb/remarkable/ip_matcher_spec.rb +0 -20
  51. data/spec/validates_host.rb/shoulda-matchers/domain_name_matcher_spec.rb +0 -20
  52. data/spec/validates_host.rb/shoulda-matchers/host_name_matcher_spec.rb +0 -20
  53. data/spec/validates_host.rb/shoulda-matchers/ip_matcher_spec.rb +0 -20
@@ -1,24 +1,27 @@
1
- # -*- encoding: utf-8 -*-
2
- require File.expand_path('../lib/validates_host/version', __FILE__)
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
- 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 = ""
6
+ gem.name = 'validates_host'
7
+ gem.version = ValidatesHost::VERSION
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.'
11
+
12
+ gem.files = `git ls-files`.split($OUTPUT_RECORD_SEPARATOR)
13
+ gem.test_files = `git ls-files -- {test,spec,features,examples,gemfiles}/*`.split("\n")
14
+ gem.executables = `git ls-files -- bin/*`.split('\n').map { |f| File.basename(f) }
15
+ gem.require_paths = %w[lib]
16
+
17
+ gem.license = 'MIT'
10
18
 
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
19
+ gem.add_development_dependency 'coveralls'
20
+ gem.add_development_dependency 'rake'
21
+ gem.add_development_dependency 'rspec'
22
+ gem.add_development_dependency 'rubocop'
23
+ gem.add_development_dependency 'rubocop-rspec'
24
+ gem.add_development_dependency 'shoulda-matchers'
17
25
 
18
- gem.add_dependency("activerecord", ">= 3.0.0")
19
- gem.add_development_dependency "rake"
20
- gem.add_development_dependency "rspec", ">= 2.0.0"
21
- gem.add_development_dependency "shoulda-matchers", ">= 1.0.0"
22
- gem.add_development_dependency "remarkable_activerecord", "= 4.0.0.alpha4"
23
- gem.add_development_dependency "sqlite3"
26
+ gem.add_dependency 'activemodel', '>= 3.0.0'
24
27
  end
metadata CHANGED
@@ -1,191 +1,192 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: validates_host
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
5
- prerelease:
4
+ version: 1.2.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-06 00:00:00.000000000 Z
11
+ date: 2020-06-07 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
- name: activerecord
14
+ name: coveralls
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
- version: 3.0.0
22
- type: :runtime
19
+ version: '0'
20
+ type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - ">="
28
25
  - !ruby/object:Gem::Version
29
- version: 3.0.0
26
+ version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rake
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ">="
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - ">="
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: rspec
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - ">="
52
46
  - !ruby/object:Gem::Version
53
- version: 2.0.0
47
+ version: '0'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - ">="
60
53
  - !ruby/object:Gem::Version
61
- version: 2.0.0
54
+ version: '0'
62
55
  - !ruby/object:Gem::Dependency
63
- name: shoulda-matchers
56
+ name: rubocop
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ! '>='
59
+ - - ">="
68
60
  - !ruby/object:Gem::Version
69
- version: 1.0.0
61
+ version: '0'
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ! '>='
66
+ - - ">="
76
67
  - !ruby/object:Gem::Version
77
- version: 1.0.0
68
+ version: '0'
78
69
  - !ruby/object:Gem::Dependency
79
- name: remarkable_activerecord
70
+ name: rubocop-rspec
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
- - - '='
73
+ - - ">="
84
74
  - !ruby/object:Gem::Version
85
- version: 4.0.0.alpha4
75
+ version: '0'
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
- - - '='
80
+ - - ">="
92
81
  - !ruby/object:Gem::Version
93
- version: 4.0.0.alpha4
82
+ version: '0'
94
83
  - !ruby/object:Gem::Dependency
95
- name: sqlite3
84
+ name: shoulda-matchers
96
85
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
86
  requirements:
99
- - - ! '>='
87
+ - - ">="
100
88
  - !ruby/object:Gem::Version
101
89
  version: '0'
102
90
  type: :development
103
91
  prerelease: false
104
92
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
93
  requirements:
107
- - - ! '>='
94
+ - - ">="
108
95
  - !ruby/object:Gem::Version
109
96
  version: '0'
110
- description: Validates Host, Domain and IP
97
+ - !ruby/object:Gem::Dependency
98
+ name: activemodel
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: 3.0.0
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: 3.0.0
111
+ description:
111
112
  email: plribeiro3000@gmail.com
112
113
  executables: []
113
114
  extensions: []
114
115
  extra_rdoc_files: []
115
116
  files:
116
- - .gitignore
117
- - .rspec
118
- - .rvmrc
117
+ - ".gitignore"
118
+ - ".rspec"
119
+ - ".rubocop.yml"
120
+ - ".ruby-gemset"
121
+ - ".travis.yml"
119
122
  - Gemfile
120
123
  - LICENSE
121
124
  - README.md
122
125
  - Rakefile
126
+ - gemfiles/Gemfile.rails3
127
+ - gemfiles/Gemfile.rails4
128
+ - gemfiles/Gemfile.rails5
123
129
  - lib/validates_host.rb
130
+ - lib/validates_host/domain_name.rb
124
131
  - lib/validates_host/domain_name_validator.rb
132
+ - lib/validates_host/host_name.rb
125
133
  - lib/validates_host/host_name_validator.rb
134
+ - lib/validates_host/ip.rb
126
135
  - lib/validates_host/ip_validator.rb
127
- - lib/validates_host/remarkable.rb
128
- - lib/validates_host/remarkable/domain_name_matcher.rb
129
- - lib/validates_host/remarkable/host_name_matcher.rb
130
- - lib/validates_host/remarkable/ip_matcher.rb
131
- - lib/validates_host/shoulda-matchers.rb
132
- - lib/validates_host/shoulda-matchers/domain_name_matcher.rb
133
- - lib/validates_host/shoulda-matchers/host_name_matcher.rb
134
- - lib/validates_host/shoulda-matchers/ip_matcher.rb
136
+ - lib/validates_host/require_a_valid_domain_name_matcher.rb
137
+ - lib/validates_host/require_a_valid_host_name_matcher.rb
138
+ - lib/validates_host/require_a_valid_ip_matcher.rb
139
+ - lib/validates_host/require_a_valid_subnet_matcher.rb
140
+ - lib/validates_host/subnet.rb
141
+ - lib/validates_host/subnet_validator.rb
135
142
  - lib/validates_host/version.rb
136
- - spec/fake_app/db/migrations/create_servers.rb
137
143
  - spec/fake_app/server.rb
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
138
149
  - spec/spec_helper.rb
139
- - spec/validates_host.rb/domain_name_validator_spec.rb
140
- - spec/validates_host.rb/host_name_validator_spec.rb
141
- - spec/validates_host.rb/ip_validator_spec.rb
142
- - spec/validates_host.rb/remarkable/domain_name_matcher_spec.rb
143
- - spec/validates_host.rb/remarkable/host_name_matcher_spec.rb
144
- - spec/validates_host.rb/remarkable/ip_matcher_spec.rb
145
- - spec/validates_host.rb/shoulda-matchers/domain_name_matcher_spec.rb
146
- - spec/validates_host.rb/shoulda-matchers/host_name_matcher_spec.rb
147
- - spec/validates_host.rb/shoulda-matchers/ip_matcher_spec.rb
150
+ - spec/validates_host/domain_name_validator_spec.rb
151
+ - spec/validates_host/host_name_validator_spec.rb
152
+ - spec/validates_host/ip_validator_spec.rb
153
+ - spec/validates_host/subnet_validator_spec.rb
148
154
  - validates_host.gemspec
149
- homepage: ''
150
- licenses: []
155
+ homepage:
156
+ licenses:
157
+ - MIT
158
+ metadata: {}
151
159
  post_install_message:
152
160
  rdoc_options: []
153
161
  require_paths:
154
162
  - lib
155
163
  required_ruby_version: !ruby/object:Gem::Requirement
156
- none: false
157
164
  requirements:
158
- - - ! '>='
165
+ - - ">="
159
166
  - !ruby/object:Gem::Version
160
167
  version: '0'
161
- segments:
162
- - 0
163
- hash: -391399657668278307
164
168
  required_rubygems_version: !ruby/object:Gem::Requirement
165
- none: false
166
169
  requirements:
167
- - - ! '>='
170
+ - - ">="
168
171
  - !ruby/object:Gem::Version
169
172
  version: '0'
170
- segments:
171
- - 0
172
- hash: -391399657668278307
173
173
  requirements: []
174
- rubyforge_project:
175
- rubygems_version: 1.8.24
174
+ rubygems_version: 3.1.3
176
175
  signing_key:
177
- specification_version: 3
178
- summary: Host Validation Gem
176
+ specification_version: 4
177
+ summary: Validates Host, Domain and IP and test it with matchers in a simple way.
179
178
  test_files:
180
- - spec/fake_app/db/migrations/create_servers.rb
179
+ - gemfiles/Gemfile.rails3
180
+ - gemfiles/Gemfile.rails4
181
+ - gemfiles/Gemfile.rails5
181
182
  - spec/fake_app/server.rb
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
182
188
  - spec/spec_helper.rb
183
- - spec/validates_host.rb/domain_name_validator_spec.rb
184
- - spec/validates_host.rb/host_name_validator_spec.rb
185
- - spec/validates_host.rb/ip_validator_spec.rb
186
- - spec/validates_host.rb/remarkable/domain_name_matcher_spec.rb
187
- - spec/validates_host.rb/remarkable/host_name_matcher_spec.rb
188
- - spec/validates_host.rb/remarkable/ip_matcher_spec.rb
189
- - spec/validates_host.rb/shoulda-matchers/domain_name_matcher_spec.rb
190
- - spec/validates_host.rb/shoulda-matchers/host_name_matcher_spec.rb
191
- - spec/validates_host.rb/shoulda-matchers/ip_matcher_spec.rb
189
+ - spec/validates_host/domain_name_validator_spec.rb
190
+ - spec/validates_host/host_name_validator_spec.rb
191
+ - spec/validates_host/ip_validator_spec.rb
192
+ - spec/validates_host/subnet_validator_spec.rb
@@ -1,3 +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'
@@ -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_domain_name(*args, &block)
25
- HostNameMatcher.new(*args, &block).spec(self)
26
- end
27
- end
28
- end
29
- end
@@ -1,3 +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'
@@ -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,40 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe DomainNameValidator do
4
- context "when domain_name is invalid" do
5
- before :each do
6
- @server = Server.new(:domain_name => "http://")
7
- I18n.stub(:t).with(:"activerecord.errors.models.server.attributes.domain_name.invalid",
8
- :default => :"activerecord.errors.messages.invalid").and_return("is invalid")
9
- end
10
-
11
- it "should set object as invalid" do
12
- @server.valid?.should be_false
13
- end
14
-
15
- it "should set an error" do
16
- @server.valid?
17
- @server.errors[:domain_name].should == ['is invalid']
18
- end
19
- end
20
-
21
- context "when domain_name is valid" do
22
- before :each do
23
- @server = Server.new(:domain_name => "example.com")
24
- end
25
-
26
- it "should set object as valid" do
27
- @server.valid?.should be_true
28
- end
29
-
30
- it "should not set an error on attribute" do
31
- @server.valid?
32
- @server.errors[:domain_name].should be_blank
33
- end
34
- end
35
-
36
- it "should be valid with a nil value" do
37
- @server = Server.new(:domain_name => nil)
38
- @server.valid?.should be_true
39
- end
40
- end