gman 7.0.5 → 8.0.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 (65) hide show
  1. checksums.yaml +4 -4
  2. data/bin/gman +10 -15
  3. data/bin/gman_filter +1 -1
  4. data/config/domains.txt +497 -387
  5. data/config/vendor/academic.txt +0 -1
  6. data/config/vendor/dotgovs.csv +8688 -5786
  7. data/docs/README.md +3 -1
  8. data/lib/gman/domain_list.rb +1 -1
  9. data/lib/gman/identifier.rb +17 -14
  10. data/lib/gman/importer.rb +1 -1
  11. data/lib/gman/locality.rb +1 -1
  12. data/lib/gman/version.rb +1 -1
  13. data/lib/gman.rb +9 -8
  14. metadata +12 -216
  15. data/.github/CODEOWNERS +0 -3
  16. data/.github/ISSUE_TEMPLATE/bug_report.md +0 -28
  17. data/.github/ISSUE_TEMPLATE/feature_request.md +0 -21
  18. data/.github/config.yml +0 -23
  19. data/.github/funding.yml +0 -1
  20. data/.github/no-response.yml +0 -15
  21. data/.github/release-drafter.yml +0 -4
  22. data/.github/settings.yml +0 -33
  23. data/.github/stale.yml +0 -29
  24. data/.gitignore +0 -6
  25. data/.rspec +0 -2
  26. data/.rubocop.yml +0 -33
  27. data/.rubocop_todo.yml +0 -84
  28. data/.ruby-version +0 -1
  29. data/.travis.yml +0 -4
  30. data/Gemfile +0 -5
  31. data/docs/CODE_OF_CONDUCT.md +0 -46
  32. data/docs/CONTRIBUTING.md +0 -92
  33. data/docs/SECURITY.md +0 -3
  34. data/docs/_config.yml +0 -2
  35. data/gman.gemspec +0 -44
  36. data/script/add +0 -19
  37. data/script/alphabetize +0 -14
  38. data/script/bootstrap +0 -5
  39. data/script/cibuild +0 -8
  40. data/script/console +0 -3
  41. data/script/dedupe +0 -22
  42. data/script/profile +0 -21
  43. data/script/prune +0 -22
  44. data/script/reconcile-us +0 -72
  45. data/script/release +0 -38
  46. data/script/vendor +0 -13
  47. data/script/vendor-federal-de +0 -14
  48. data/script/vendor-gov-list +0 -17
  49. data/script/vendor-municipal-de +0 -23
  50. data/script/vendor-nl +0 -21
  51. data/script/vendor-public-suffix +0 -28
  52. data/script/vendor-se +0 -21
  53. data/script/vendor-swot +0 -43
  54. data/script/vendor-us +0 -38
  55. data/spec/fixtures/domains.txt +0 -4
  56. data/spec/fixtures/obama.txt +0 -5
  57. data/spec/gman/bin_spec.rb +0 -101
  58. data/spec/gman/country_code_spec.rb +0 -39
  59. data/spec/gman/domain_list_spec.rb +0 -110
  60. data/spec/gman/domains_spec.rb +0 -25
  61. data/spec/gman/identifier_spec.rb +0 -218
  62. data/spec/gman/importer_spec.rb +0 -236
  63. data/spec/gman/locality_spec.rb +0 -24
  64. data/spec/gman_spec.rb +0 -74
  65. data/spec/spec_helper.rb +0 -31
@@ -1,236 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe Gman::Importer do
4
- subject { described_class.new(domains) }
5
-
6
- let(:domains) { { 'test' => ['example.com'] } }
7
- let(:stdout) { StringIO.new }
8
- let(:logger) { Logger.new(@stdout) }
9
- let(:domain_list) { subject.domain_list }
10
-
11
- before do
12
- subject.instance_variable_set '@logger', logger
13
- end
14
-
15
- it 'inits the domain list' do
16
- expect(domain_list).to be_a(Gman::DomainList)
17
- expect(domain_list.count).to be(1)
18
- expect(domain_list.domains.first).to eql('example.com')
19
- end
20
-
21
- it 'inits the logger' do
22
- expect(subject.logger).to be_a(Logger)
23
- end
24
-
25
- it 'returns the current domain list' do
26
- expect(subject.current).to be_a(Gman::DomainList)
27
- end
28
-
29
- it 'returns the resolver' do
30
- expect(subject.resolver).to be_a(Resolv::DNS)
31
- end
32
-
33
- context 'domain rejection' do
34
- it 'returns false' do
35
- expect(subject.reject('example.com', 'reasons')).to be(false)
36
- end
37
-
38
- it 'returns the reason why asked' do
39
- with_env 'RECONCILING', 'true' do
40
- expect(subject.reject('example.com', 'reasons')).to eql('reasons')
41
- end
42
- end
43
- end
44
-
45
- context 'manipulating the domain list' do
46
- context 'normalizing domains' do
47
- let(:domains) { { 'test' => ['www.EXAMPLE.com/'] } }
48
-
49
- before { subject.send :normalize_domains! }
50
-
51
- it 'normalizes the domains' do
52
- expect(domain_list.domains.first).to eql('example.com')
53
- end
54
- end
55
-
56
- context 'removing invalid domains' do
57
- let(:domains) { { 'test' => ['foo.github.io', 'example.com'] } }
58
-
59
- before { subject.send :ensure_validity! }
60
-
61
- it 'removes invalid domains' do
62
- expect(domain_list.count).to be(1)
63
- end
64
- end
65
- end
66
-
67
- context 'with the current list stubbed' do
68
- let(:stubbed_list) { Gman::DomainList.new(path: stubbed_list_path) }
69
- let(:stubbed_file_contents) { File.read(stubbed_list_path) }
70
-
71
- before { subject.instance_variable_set '@current', stubbed_list }
72
-
73
- context 'writing' do
74
- before { @current = subject.current.to_s }
75
-
76
- before { subject.send :add_to_current }
77
-
78
- after { File.write(stubbed_list_path, @current) }
79
-
80
- context 'adding domains' do
81
- let(:domains) do
82
- { 'test' => ['example.com'], 'test2' => ['github.com'] }
83
- end
84
-
85
- it 'adds the domains' do
86
- expected = "// test\nexample.com\n\n// test2\ngithub.com"
87
- expect(stubbed_file_contents).to match(expected)
88
- end
89
- end
90
-
91
- context 'importing' do
92
- let(:domains) do
93
- {
94
- 'test' => ['www.example.com', 'foo.github.io'],
95
- 'test2' => ['github.com', 'www.github.com', 'whitehouse.gov']
96
- }
97
- end
98
-
99
- before { subject.import(skip_resolve: true) }
100
-
101
- it 'imports' do
102
- expected = "// test\nexample.com\nfoo.github.io"
103
- expect(stubbed_file_contents).to match(expected)
104
-
105
- expected = "// test2\ngithub.com\nwhitehouse.gov"
106
- expect(stubbed_file_contents).to match(expected)
107
- end
108
- end
109
- end
110
- end
111
-
112
- context 'domain validation' do
113
- let(:domain) { '' }
114
- let(:valid?) { subject.send(:ensure_valid, domain) }
115
-
116
- context 'a valid domain' do
117
- let(:domain) { 'whitehouse.gov' }
118
-
119
- it 'is valid' do
120
- expect(valid?).to be(true)
121
- end
122
- end
123
-
124
- {
125
- empty: '',
126
- blacklisted: 'egovlink.com',
127
- invalid: 'foo.invalid',
128
- academic: 'harvard.edu',
129
- "rejex'd": 'foo.github.io'
130
- }.each_key do |type|
131
- context "a #{type} domain" do
132
- it 'is invalid' do
133
- expect(valid?).to be(false)
134
- end
135
- end
136
- end
137
- end
138
-
139
- context 'duplicate domains' do
140
- let(:dupe?) { subject.send(:dupe?, domain) }
141
- let(:ensure_not_dupe) { subject.send(:ensure_not_dupe, domain) }
142
-
143
- context 'a unique domain' do
144
- let(:domain) { 'gman.com' }
145
-
146
- it 'is not a dupe' do
147
- expect(dupe?).to be_falsy
148
- expect(ensure_not_dupe).to be_truthy
149
- end
150
- end
151
-
152
- context 'a duplicate domain' do
153
- let(:domain) { 'gov' }
154
-
155
- it "knows it's a dupe" do
156
- expect(dupe?).to be_truthy
157
- expect(ensure_not_dupe).to be_falsy
158
- end
159
-
160
- context 'a subdomain' do
161
- let(:domain) { 'whitehouse.gov' }
162
-
163
- it "know when a domain's a subdomain of an existing domain" do
164
- expect(dupe?).to be_truthy
165
- expect(ensure_not_dupe).to be_falsy
166
- end
167
- end
168
- end
169
- end
170
-
171
- context 'domain resolution' do
172
- let(:resolves?) { subject.domain_resolves?(domain) }
173
- let(:ensure_resolves) { subject.send(:ensure_resolves, domain) }
174
-
175
- context 'a valid domain' do
176
- let(:domain) { 'github.com' }
177
-
178
- it 'resolves' do
179
- expect(resolves?).to be_truthy
180
- expect(ensure_resolves).to be_truthy
181
- end
182
- end
183
-
184
- context 'an invalid domain' do
185
- let(:domain) { 'foo.invalid' }
186
-
187
- it "doesn't resolve" do
188
- expect(resolves?).to be_falsy
189
- expect(ensure_resolves).to be_falsy
190
- end
191
- end
192
- end
193
-
194
- context 'regex checks' do
195
- let(:ensure_regex) { subject.send(:ensure_regex, domain) }
196
-
197
- context 'valid domains' do
198
- let(:domain) { 'example.com' }
199
-
200
- it 'passes' do
201
- expect(ensure_regex).to be_truthy
202
- end
203
- end
204
-
205
- [
206
- 'home.example.com', 'site.example.com', 'user.example.com',
207
- 'foo.weebly.com', 'foo.wordpress.com', 'foo.govoffice.com',
208
- 'foo.govoffice1.com', 'foo.homestead.com', 'foo.wix.com',
209
- 'foo.blogspot.com', 'foo.tripod.com', 'foo.squarespace.com',
210
- 'foo.github.io', 'ci.champaign.il.us'
211
- ].each do |domain|
212
- context "a #{domain} domain" do
213
- let(:domain) { domain }
214
-
215
- it 'rejects the domain' do
216
- expect(ensure_regex).to be_falsy
217
- end
218
- end
219
- end
220
- end
221
-
222
- context 'normalizing domains' do
223
- let(:normalized_domain) { subject.normalize_domain(domain) }
224
-
225
- [
226
- 'http://example.com', 'www.example.com', 'example.com/',
227
- 'example.com/foo', 'example.com/foo/', 'EXAMPLE.com'
228
- ].each do |domain|
229
- let(:domain) { domain }
230
-
231
- it 'normalizes the domain' do
232
- expect(normalized_domain).to eql('example.com')
233
- end
234
- end
235
- end
236
- end
@@ -1,24 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe Gman::Locality do
4
- context 'valid domains' do
5
- ['foo.state.il.us', 'ci.foo.il.us'].each do |domain|
6
- context "the #{domain} domain" do
7
- it 'is valid' do
8
- expect(described_class.valid?(domain)).to be(true)
9
- end
10
- end
11
- end
12
- end
13
-
14
- context 'invalid domains' do
15
- ['state.foo.il.us', 'foo.ci.il.us',
16
- 'k12.il.us', 'ci.foo.zx.us'].each do |domain|
17
- context "the #{domain} domain" do
18
- it 'is invalid' do
19
- expect(described_class.valid?(domain)).to be(false)
20
- end
21
- end
22
- end
23
- end
24
- end
data/spec/gman_spec.rb DELETED
@@ -1,74 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe Gman do
4
- context 'valid domains' do
5
- ['foo.gov', 'http://foo.mil', 'foo@bar.gc.ca', 'foo.gov.au',
6
- 'https://www.foo.gouv.fr', 'foo@ci.champaign.il.us',
7
- 'foo.bar.baz.gov.au', 'foo@bar.gov.uk', 'foo.gov',
8
- 'foo.fed.us', 'foo.state.il.us', 'state.il.us',
9
- 'foo@af.mil', 'foo.gov.in'].each do |domain|
10
- subject { described_class.new(domain) }
11
-
12
- it "knows #{domain.inspect} is valid government domain" do
13
- expect(described_class.valid?(domain)).to be(true)
14
- expect(subject.valid?).to be(true)
15
- end
16
- end
17
- end
18
-
19
- context 'invalid domains' do
20
- ['foo.bar.com', 'bar@foo.biz', 'http://www.foo.biz',
21
- 'foo.uk', 'gov', 'foo@k12.champaign.il.us', 'foo@kii.gov.by',
22
- 'foo', '', nil, ' ', 'foo.city.il.us', 'foo.ci.il.us',
23
- 'foo.zx.us', 'foo@mail.gov.ua', 'foo@gwu.edu'].each do |domain|
24
- subject { described_class.new(domain) }
25
-
26
- it "knows #{domain.inspect} is not a valid government domain" do
27
- expect(described_class.valid?(domain)).to be(false)
28
- expect(subject.valid?).to be(false)
29
- end
30
- end
31
- end
32
-
33
- context 'localities' do
34
- subject { described_class.new(domain) }
35
-
36
- context 'when given github.gov' do
37
- let(:domain) { 'github.gov' }
38
-
39
- it "knows it's not a locality" do
40
- expect(subject.locality?).to be(false)
41
- end
42
- end
43
-
44
- context 'when given foo.state.il.us' do
45
- let(:domain) { 'foo.state.il.us' }
46
-
47
- it "knows it's a locality" do
48
- expect(subject.locality?).to be(true)
49
- end
50
- end
51
- end
52
-
53
- context 'class methods' do
54
- it 'returns the domain list' do
55
- expect(described_class.list).to be_a(Gman::DomainList)
56
- end
57
-
58
- it 'returns the academic list' do
59
- expect(described_class.academic_list).to be_a(Gman::DomainList)
60
- end
61
-
62
- it 'returns the config path' do
63
- expect(Dir.exist?(described_class.config_path)).to be(true)
64
- end
65
-
66
- it 'returns the list path' do
67
- expect(File.exist?(described_class.list_path)).to be(true)
68
- end
69
-
70
- it 'returns the academic list path' do
71
- expect(File.exist?(described_class.academic_list_path)).to be(true)
72
- end
73
- end
74
- end
data/spec/spec_helper.rb DELETED
@@ -1,31 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'parallel'
4
- require 'open3'
5
-
6
- RSpec.configure do |config|
7
- config.example_status_persistence_file_path = 'spec/examples.txt'
8
- config.disable_monkey_patching!
9
- config.default_formatter = 'doc' if config.files_to_run.one?
10
- config.order = :random
11
- Kernel.srand config.seed
12
- end
13
-
14
- require_relative '../lib/gman'
15
- require_relative '../lib/gman/domain_list'
16
- require_relative '../lib/gman/importer'
17
-
18
- def fixture_path(fixture)
19
- File.expand_path "./fixtures/#{fixture}", File.dirname(__FILE__)
20
- end
21
-
22
- def stubbed_list_path
23
- File.expand_path './fixtures/domains.txt', File.dirname(__FILE__)
24
- end
25
-
26
- def with_env(key, value)
27
- old_env = ENV[key]
28
- ENV[key] = value
29
- yield
30
- ENV[key] = old_env
31
- end