validates_host 0.3.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +5 -4
  3. data/.rubocop.yml +57 -0
  4. data/.ruby-gemset +1 -0
  5. data/.travis.yml +45 -4
  6. data/Gemfile +3 -1
  7. data/README.md +15 -9
  8. data/Rakefile +9 -4
  9. data/gemfiles/Gemfile.rails3 +6 -0
  10. data/gemfiles/Gemfile.rails4 +5 -0
  11. data/gemfiles/Gemfile.rails5 +5 -0
  12. data/gemfiles/Gemfile.rails6 +5 -0
  13. data/lib/validates_host.rb +14 -5
  14. data/lib/validates_host/domain_name.rb +15 -0
  15. data/lib/validates_host/domain_name_validator.rb +10 -17
  16. data/lib/validates_host/host_name.rb +15 -0
  17. data/lib/validates_host/host_name_validator.rb +10 -17
  18. data/lib/validates_host/ip.rb +17 -0
  19. data/lib/validates_host/ip_validator.rb +10 -17
  20. data/lib/validates_host/{shoulda-matchers/domain_name_matcher.rb → require_a_valid_domain_name_matcher.rb} +9 -11
  21. data/lib/validates_host/{shoulda-matchers/host_name_matcher.rb → require_a_valid_host_name_matcher.rb} +9 -11
  22. data/lib/validates_host/{shoulda-matchers/ip_matcher.rb → require_a_valid_ip_matcher.rb} +9 -11
  23. data/lib/validates_host/{shoulda-matchers/subnet_matcher.rb → require_a_valid_subnet_matcher.rb} +9 -11
  24. data/lib/validates_host/subnet.rb +15 -0
  25. data/lib/validates_host/subnet_validator.rb +10 -17
  26. data/lib/validates_host/version.rb +3 -1
  27. data/spec/fake_app/server.rb +19 -5
  28. data/spec/fake_app/subnet.rb +11 -3
  29. data/spec/shoulda/matchers/active_model/require_a_valid_domain_name_matcher_spec.rb +23 -0
  30. data/spec/shoulda/matchers/active_model/require_a_valid_host_name_matcher_spec.rb +23 -0
  31. data/spec/shoulda/matchers/active_model/require_a_valid_ip_matcher_spec.rb +23 -0
  32. data/spec/shoulda/matchers/active_model/require_a_valid_subnet_matcher_spec.rb +23 -0
  33. data/spec/spec_helper.rb +11 -8
  34. data/spec/validates_host/domain_name_validator_spec.rb +23 -22
  35. data/spec/validates_host/host_name_validator_spec.rb +23 -22
  36. data/spec/validates_host/ip_validator_spec.rb +38 -22
  37. data/spec/validates_host/subnet_validator_spec.rb +23 -22
  38. data/validates_host.gemspec +23 -19
  39. metadata +84 -95
  40. data/lib/validates_host/remarkable.rb +0 -4
  41. data/lib/validates_host/remarkable/domain_name_matcher.rb +0 -29
  42. data/lib/validates_host/remarkable/host_name_matcher.rb +0 -29
  43. data/lib/validates_host/remarkable/ip_matcher.rb +0 -29
  44. data/lib/validates_host/remarkable/subnet_matcher.rb +0 -29
  45. data/lib/validates_host/shoulda-matchers.rb +0 -4
  46. data/spec/fake_app/db/migrations/create_servers.rb +0 -13
  47. data/spec/fake_app/db/migrations/create_subnets.rb +0 -12
  48. data/spec/validates_host/remarkable/domain_name_matcher_spec.rb +0 -20
  49. data/spec/validates_host/remarkable/host_name_matcher_spec.rb +0 -20
  50. data/spec/validates_host/remarkable/ip_matcher_spec.rb +0 -20
  51. data/spec/validates_host/remarkable/subnet_matcher_spec.rb +0 -20
  52. data/spec/validates_host/shoulda-matchers/domain_name_matcher_spec.rb +0 -20
  53. data/spec/validates_host/shoulda-matchers/host_name_matcher_spec.rb +0 -20
  54. data/spec/validates_host/shoulda-matchers/ip_matcher_spec.rb +0 -20
  55. data/spec/validates_host/shoulda-matchers/subnet_matcher_spec.rb +0 -20
@@ -1,40 +1,56 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe IpValidator do
4
- context "when ip is invalid" do
5
- before :each do
6
- @server = Server.new(:ip => "127.0.0")
7
- I18n.stub(:t).with(:"activerecord.errors.models.server.attributes.ip.invalid",
8
- :default => :"activerecord.errors.messages.invalid").and_return("is invalid")
6
+ let(:server) { Server.new }
7
+
8
+ context 'when ip is invalid' do
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?
9
27
  end
10
28
 
11
- it "should set object as invalid" do
12
- @server.valid?.should be_false
29
+ it 'sets object as valid' do
30
+ expect(server).to be_valid
13
31
  end
14
32
 
15
- it "should set an error" do
16
- @server.valid?
17
- @server.errors[:ip].should == ['is invalid']
33
+ it 'does not set an error on attribute' do
34
+ expect(server.errors[:ip]).to be_blank
18
35
  end
19
36
  end
20
37
 
21
- context "when ip is valid" do
22
- before :each do
23
- @server = Server.new(:ip => "10.10.10.1")
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?
24
42
  end
25
43
 
26
- it "should set object as valid" do
27
- @server.valid?.should be_true
44
+ it 'sets object as valid' do
45
+ expect(server).to be_valid
28
46
  end
29
47
 
30
- it "should not set an error on attribute" do
31
- @server.valid?
32
- @server.errors[:ip].should be_blank
48
+ it 'does not set an error on attribute' do
49
+ expect(server.errors[:ip]).to be_blank
33
50
  end
34
51
  end
35
52
 
36
- it "should be valid with a nil value" do
37
- @server = Server.new(:ip => nil)
38
- @server.valid?.should be_true
53
+ it 'is valid with a nil value' do
54
+ expect(server).to be_valid
39
55
  end
40
- end
56
+ end
@@ -1,40 +1,41 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe SubnetValidator do
4
- context "when subnet is invalid" do
5
- before :each do
6
- @subnet = Subnet.new(:value => "127.0.0")
7
- I18n.stub(:t).with(:"activerecord.errors.models.subnet.attributes.value.invalid",
8
- :default => :"activerecord.errors.messages.invalid").and_return("is invalid")
6
+ let(:subnet) { Subnet.new }
7
+
8
+ context 'when subnet is invalid' do
9
+ before do
10
+ subnet.value = '127.0.0'
11
+ subnet.valid?
9
12
  end
10
13
 
11
- it "should set object as invalid" do
12
- @subnet.valid?.should be_false
14
+ it 'sets object as invalid' do
15
+ expect(subnet).not_to be_valid
13
16
  end
14
17
 
15
- it "should set an error" do
16
- @subnet.valid?
17
- @subnet.errors[:value].should == ['is invalid']
18
+ it 'sets an error' do
19
+ expect(subnet.errors[:value]).to eq(['is invalid'])
18
20
  end
19
21
  end
20
22
 
21
- context "when subnet is valid" do
22
- before :each do
23
- @subnet = Subnet.new(:value => "10.10.10.1/28")
23
+ context 'when subnet is valid' do
24
+ before do
25
+ subnet.value = '10.10.10.1/28'
26
+ subnet.valid?
24
27
  end
25
28
 
26
- it "should set object as valid" do
27
- @subnet.valid?.should be_true
29
+ it 'sets object as valid' do
30
+ expect(subnet).to be_valid
28
31
  end
29
32
 
30
- it "should not set an error on attribute" do
31
- @subnet.valid?
32
- @subnet.errors[:value].should be_blank
33
+ it 'does not set an error on attribute' do
34
+ expect(subnet.errors[:value]).to be_blank
33
35
  end
34
36
  end
35
37
 
36
- it "should be valid with a nil value" do
37
- @subnet = Subnet.new(:value => nil)
38
- @subnet.valid?.should be_true
38
+ it 'is valid with a nil value' do
39
+ expect(subnet).to be_valid
39
40
  end
40
- end
41
+ end
@@ -1,24 +1,28 @@
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
+ gem.required_ruby_version = '>= 2.0.0'
17
+
18
+ gem.license = 'MIT'
10
19
 
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
20
+ gem.add_development_dependency 'coveralls'
21
+ gem.add_development_dependency 'rake'
22
+ gem.add_development_dependency 'rspec'
23
+ gem.add_development_dependency 'rubocop', '< 0.50'
24
+ gem.add_development_dependency 'rubocop-rspec'
25
+ gem.add_development_dependency 'shoulda-matchers'
17
26
 
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"
27
+ gem.add_dependency 'activemodel', '>= 3.0.0'
24
28
  end
metadata CHANGED
@@ -1,205 +1,194 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: validates_host
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
5
- prerelease:
4
+ version: 1.3.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Paulo Henrique Lopes Ribeiro
9
- autorequire:
8
+ autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-08-06 00:00:00.000000000 Z
11
+ date: 2021-04-26 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.50'
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.50'
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
119
- - .travis.yml
117
+ - ".gitignore"
118
+ - ".rspec"
119
+ - ".rubocop.yml"
120
+ - ".ruby-gemset"
121
+ - ".travis.yml"
120
122
  - Gemfile
121
123
  - LICENSE
122
124
  - README.md
123
125
  - Rakefile
126
+ - gemfiles/Gemfile.rails3
127
+ - gemfiles/Gemfile.rails4
128
+ - gemfiles/Gemfile.rails5
129
+ - gemfiles/Gemfile.rails6
124
130
  - lib/validates_host.rb
131
+ - lib/validates_host/domain_name.rb
125
132
  - lib/validates_host/domain_name_validator.rb
133
+ - lib/validates_host/host_name.rb
126
134
  - lib/validates_host/host_name_validator.rb
135
+ - lib/validates_host/ip.rb
127
136
  - lib/validates_host/ip_validator.rb
128
- - lib/validates_host/remarkable.rb
129
- - lib/validates_host/remarkable/domain_name_matcher.rb
130
- - lib/validates_host/remarkable/host_name_matcher.rb
131
- - lib/validates_host/remarkable/ip_matcher.rb
132
- - lib/validates_host/remarkable/subnet_matcher.rb
133
- - lib/validates_host/shoulda-matchers.rb
134
- - lib/validates_host/shoulda-matchers/domain_name_matcher.rb
135
- - lib/validates_host/shoulda-matchers/host_name_matcher.rb
136
- - lib/validates_host/shoulda-matchers/ip_matcher.rb
137
- - lib/validates_host/shoulda-matchers/subnet_matcher.rb
137
+ - lib/validates_host/require_a_valid_domain_name_matcher.rb
138
+ - lib/validates_host/require_a_valid_host_name_matcher.rb
139
+ - lib/validates_host/require_a_valid_ip_matcher.rb
140
+ - lib/validates_host/require_a_valid_subnet_matcher.rb
141
+ - lib/validates_host/subnet.rb
138
142
  - lib/validates_host/subnet_validator.rb
139
143
  - lib/validates_host/version.rb
140
- - spec/fake_app/db/migrations/create_servers.rb
141
- - spec/fake_app/db/migrations/create_subnets.rb
142
144
  - spec/fake_app/server.rb
143
145
  - spec/fake_app/subnet.rb
146
+ - spec/shoulda/matchers/active_model/require_a_valid_domain_name_matcher_spec.rb
147
+ - spec/shoulda/matchers/active_model/require_a_valid_host_name_matcher_spec.rb
148
+ - spec/shoulda/matchers/active_model/require_a_valid_ip_matcher_spec.rb
149
+ - spec/shoulda/matchers/active_model/require_a_valid_subnet_matcher_spec.rb
144
150
  - spec/spec_helper.rb
145
151
  - spec/validates_host/domain_name_validator_spec.rb
146
152
  - spec/validates_host/host_name_validator_spec.rb
147
153
  - spec/validates_host/ip_validator_spec.rb
148
- - spec/validates_host/remarkable/domain_name_matcher_spec.rb
149
- - spec/validates_host/remarkable/host_name_matcher_spec.rb
150
- - spec/validates_host/remarkable/ip_matcher_spec.rb
151
- - spec/validates_host/remarkable/subnet_matcher_spec.rb
152
- - spec/validates_host/shoulda-matchers/domain_name_matcher_spec.rb
153
- - spec/validates_host/shoulda-matchers/host_name_matcher_spec.rb
154
- - spec/validates_host/shoulda-matchers/ip_matcher_spec.rb
155
- - spec/validates_host/shoulda-matchers/subnet_matcher_spec.rb
156
154
  - spec/validates_host/subnet_validator_spec.rb
157
155
  - validates_host.gemspec
158
- homepage: ''
159
- licenses: []
160
- post_install_message:
156
+ homepage:
157
+ licenses:
158
+ - MIT
159
+ metadata: {}
160
+ post_install_message:
161
161
  rdoc_options: []
162
162
  require_paths:
163
163
  - lib
164
164
  required_ruby_version: !ruby/object:Gem::Requirement
165
- none: false
166
165
  requirements:
167
- - - ! '>='
166
+ - - ">="
168
167
  - !ruby/object:Gem::Version
169
- version: '0'
170
- segments:
171
- - 0
172
- hash: 873921845933518174
168
+ version: 2.0.0
173
169
  required_rubygems_version: !ruby/object:Gem::Requirement
174
- none: false
175
170
  requirements:
176
- - - ! '>='
171
+ - - ">="
177
172
  - !ruby/object:Gem::Version
178
173
  version: '0'
179
- segments:
180
- - 0
181
- hash: 873921845933518174
182
174
  requirements: []
183
- rubyforge_project:
184
- rubygems_version: 1.8.24
185
- signing_key:
186
- specification_version: 3
187
- summary: Host Validation Gem
175
+ rubygems_version: 3.1.4
176
+ signing_key:
177
+ specification_version: 4
178
+ summary: Validates Host, Domain and IP and test it with matchers in a simple way.
188
179
  test_files:
189
- - spec/fake_app/db/migrations/create_servers.rb
190
- - spec/fake_app/db/migrations/create_subnets.rb
180
+ - gemfiles/Gemfile.rails3
181
+ - gemfiles/Gemfile.rails4
182
+ - gemfiles/Gemfile.rails5
183
+ - gemfiles/Gemfile.rails6
191
184
  - spec/fake_app/server.rb
192
185
  - spec/fake_app/subnet.rb
186
+ - spec/shoulda/matchers/active_model/require_a_valid_domain_name_matcher_spec.rb
187
+ - spec/shoulda/matchers/active_model/require_a_valid_host_name_matcher_spec.rb
188
+ - spec/shoulda/matchers/active_model/require_a_valid_ip_matcher_spec.rb
189
+ - spec/shoulda/matchers/active_model/require_a_valid_subnet_matcher_spec.rb
193
190
  - spec/spec_helper.rb
194
191
  - spec/validates_host/domain_name_validator_spec.rb
195
192
  - spec/validates_host/host_name_validator_spec.rb
196
193
  - spec/validates_host/ip_validator_spec.rb
197
- - spec/validates_host/remarkable/domain_name_matcher_spec.rb
198
- - spec/validates_host/remarkable/host_name_matcher_spec.rb
199
- - spec/validates_host/remarkable/ip_matcher_spec.rb
200
- - spec/validates_host/remarkable/subnet_matcher_spec.rb
201
- - spec/validates_host/shoulda-matchers/domain_name_matcher_spec.rb
202
- - spec/validates_host/shoulda-matchers/host_name_matcher_spec.rb
203
- - spec/validates_host/shoulda-matchers/ip_matcher_spec.rb
204
- - spec/validates_host/shoulda-matchers/subnet_matcher_spec.rb
205
194
  - spec/validates_host/subnet_validator_spec.rb