public_suffix 1.5.3 → 2.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.
@@ -1,4 +1,4 @@
1
- require 'test_helper'
1
+ require "test_helper"
2
2
 
3
3
  class PublicSuffix::RuleTest < Minitest::Unit::TestCase
4
4
 
@@ -23,6 +23,14 @@ class PublicSuffix::RuleTest < Minitest::Unit::TestCase
23
23
  assert_instance_of PublicSuffix::Rule::Wildcard, rule
24
24
  end
25
25
 
26
+
27
+ def test_default_returns_default_wildcard
28
+ default = PublicSuffix::Rule.default
29
+ assert_equal PublicSuffix::Rule::Wildcard.new("*"), default
30
+ assert_equal %w( example tldnotlisted ), default.decompose("example.tldnotlisted")
31
+ assert_equal %w( www.example tldnotlisted ), default.decompose("www.example.tldnotlisted")
32
+ end
33
+
26
34
  end
27
35
 
28
36
 
@@ -39,40 +47,64 @@ class PublicSuffix::RuleBaseTest < Minitest::Unit::TestCase
39
47
  def test_initialize
40
48
  rule = @klass.new("verona.it")
41
49
  assert_instance_of @klass, rule
42
-
43
- assert_equal :base, rule.type
44
- assert_equal "verona.it", rule.name
45
50
  assert_equal "verona.it", rule.value
46
- assert_equal %w(verona it).reverse, rule.labels
47
51
  end
48
52
 
53
+
49
54
  def test_equality_with_self
50
55
  rule = PublicSuffix::Rule::Base.new("foo")
51
56
  assert_equal rule, rule
52
57
  end
53
58
 
59
+ # rubocop:disable Style/SingleLineMethods
54
60
  def test_equality_with_internals
55
61
  assert_equal @klass.new("foo"), @klass.new("foo")
56
62
  assert_not_equal @klass.new("foo"), @klass.new("bar")
63
+ assert_not_equal @klass.new("foo"), PublicSuffix::Rule::Test.new("foo")
57
64
  assert_not_equal @klass.new("foo"), PublicSuffix::Rule::Test.new("bar")
58
65
  assert_not_equal @klass.new("foo"), Class.new { def name; foo; end }.new
59
66
  end
60
-
67
+ # rubocop:enable Style/SingleLineMethods
61
68
 
62
69
  def test_match
63
- assert @klass.new("uk").match?("example.uk")
64
- assert !@klass.new("gk").match?("example.uk")
65
- assert !@klass.new("example").match?("example.uk")
66
-
67
- assert @klass.new("uk").match?("example.co.uk")
68
- assert !@klass.new("gk").match?("example.co.uk")
69
- assert !@klass.new("co").match?("example.co.uk")
70
-
71
- assert @klass.new("co.uk").match?("example.co.uk")
72
- assert !@klass.new("uk.co").match?("example.co.uk")
73
- assert !@klass.new("go.uk").match?("example.co.uk")
70
+ [
71
+ # standard match
72
+ [PublicSuffix::Rule.factory("uk"), "uk", true],
73
+ [PublicSuffix::Rule.factory("uk"), "example.uk", true],
74
+ [PublicSuffix::Rule.factory("uk"), "example.co.uk", true],
75
+ [PublicSuffix::Rule.factory("co.uk"), "example.co.uk", true],
76
+
77
+ # FIXME
78
+ # [PublicSuffix::Rule.factory("*.com"), "com", false],
79
+ [PublicSuffix::Rule.factory("*.com"), "example.com", true],
80
+ [PublicSuffix::Rule.factory("*.com"), "foo.example.com", true],
81
+ [PublicSuffix::Rule.factory("!example.com"), "com", false],
82
+ [PublicSuffix::Rule.factory("!example.com"), "example.com", true],
83
+ [PublicSuffix::Rule.factory("!example.com"), "foo.example.com", true],
84
+
85
+ # TLD mismatch
86
+ [PublicSuffix::Rule.factory("gk"), "example.uk", false],
87
+ [PublicSuffix::Rule.factory("gk"), "example.co.uk", false],
88
+ [PublicSuffix::Rule.factory("co.uk"), "uk", false],
89
+
90
+ # general mismatch
91
+ [PublicSuffix::Rule.factory("uk.co"), "example.co.uk", false],
92
+ [PublicSuffix::Rule.factory("go.uk"), "example.co.uk", false],
93
+ [PublicSuffix::Rule.factory("co.uk"), "uk", false],
94
+
95
+ # partial matches/mismatches
96
+ [PublicSuffix::Rule.factory("co"), "example.co.uk", false],
97
+ [PublicSuffix::Rule.factory("example"), "example.uk", false],
98
+ [PublicSuffix::Rule.factory("le.it"), "example.it", false],
99
+ [PublicSuffix::Rule.factory("le.it"), "le.it", true],
100
+ [PublicSuffix::Rule.factory("le.it"), "foo.le.it", true],
101
+
102
+ ].each do |rule, input, expected|
103
+ assert_equal expected, rule.match?(input)
104
+ end
74
105
  end
75
106
 
107
+
76
108
  def test_length
77
109
  assert_raises(NotImplementedError) { @klass.new("com").length }
78
110
  end
@@ -98,43 +130,8 @@ class PublicSuffix::RuleNormalTest < Minitest::Unit::TestCase
98
130
  def test_initialize
99
131
  rule = @klass.new("verona.it")
100
132
  assert_instance_of @klass, rule
101
- assert_equal :normal, rule.type
102
- assert_equal "verona.it", rule.name
103
133
  assert_equal "verona.it", rule.value
104
- assert_equal %w(verona it).reverse, rule.labels
105
- end
106
-
107
-
108
- def test_match
109
- assert @klass.new("uk").match?("example.uk")
110
- assert !@klass.new("gk").match?("example.uk")
111
- assert !@klass.new("example").match?("example.uk")
112
-
113
- assert @klass.new("uk").match?("example.co.uk")
114
- assert !@klass.new("gk").match?("example.co.uk")
115
- assert !@klass.new("co").match?("example.co.uk")
116
-
117
- assert @klass.new("co.uk").match?("example.co.uk")
118
- assert !@klass.new("uk.co").match?("example.co.uk")
119
- assert !@klass.new("go.uk").match?("example.co.uk")
120
- end
121
-
122
- def test_match_with_fully_qualified_domain_name
123
- assert @klass.new("com").match?("com.")
124
- assert @klass.new("com").match?("example.com.")
125
- assert @klass.new("com").match?("www.example.com.")
126
- end
127
-
128
- def test_allow
129
- assert !@klass.new("com").allow?("com")
130
- assert @klass.new("com").allow?("example.com")
131
- assert @klass.new("com").allow?("www.example.com")
132
- end
133
-
134
- def test_allow_with_fully_qualified_domain_name
135
- assert !@klass.new("com").allow?("com.")
136
- assert @klass.new("com").allow?("example.com.")
137
- assert @klass.new("com").allow?("www.example.com.")
134
+ assert_equal "verona.it", rule.rule
138
135
  end
139
136
 
140
137
 
@@ -156,12 +153,6 @@ class PublicSuffix::RuleNormalTest < Minitest::Unit::TestCase
156
153
  assert_equal %w( foo.example com ), @klass.new("com").decompose("foo.example.com")
157
154
  end
158
155
 
159
- def test_decompose_with_fully_qualified_domain_name
160
- assert_equal [nil, nil], @klass.new("com").decompose("com.")
161
- assert_equal %w( example com ), @klass.new("com").decompose("example.com.")
162
- assert_equal %w( foo.example com ), @klass.new("com").decompose("foo.example.com.")
163
- end
164
-
165
156
  end
166
157
 
167
158
 
@@ -175,39 +166,8 @@ class PublicSuffix::RuleExceptionTest < Minitest::Unit::TestCase
175
166
  def test_initialize
176
167
  rule = @klass.new("!british-library.uk")
177
168
  assert_instance_of @klass, rule
178
- assert_equal :exception, rule.type
179
- assert_equal "!british-library.uk", rule.name
180
169
  assert_equal "british-library.uk", rule.value
181
- assert_equal %w(british-library uk).reverse, rule.labels
182
- end
183
-
184
-
185
- def test_match
186
- assert @klass.new("!uk").match?("example.co.uk")
187
- assert !@klass.new("!gk").match?("example.co.uk")
188
- assert @klass.new("!co.uk").match?("example.co.uk")
189
- assert !@klass.new("!go.uk").match?("example.co.uk")
190
- assert @klass.new("!british-library.uk").match?("british-library.uk")
191
- assert !@klass.new("!british-library.uk").match?("example.co.uk")
192
- end
193
-
194
- def test_match_with_fully_qualified_domain_name
195
- assert @klass.new("!uk").match?("uk.")
196
- assert @klass.new("!uk").match?("co.uk.")
197
- assert @klass.new("!uk").match?("example.co.uk.")
198
- assert @klass.new("!uk").match?("www.example.co.uk.")
199
- end
200
-
201
- def test_allow
202
- assert !@klass.new("!british-library.uk").allow?("uk")
203
- assert @klass.new("!british-library.uk").allow?("british-library.uk")
204
- assert @klass.new("!british-library.uk").allow?("www.british-library.uk")
205
- end
206
-
207
- def test_allow_with_fully_qualified_domain_name
208
- assert !@klass.new("!british-library.uk").allow?("uk.")
209
- assert @klass.new("!british-library.uk").allow?("british-library.uk.")
210
- assert @klass.new("!british-library.uk").allow?("www.british-library.uk.")
170
+ assert_equal "!british-library.uk", rule.rule
211
171
  end
212
172
 
213
173
 
@@ -227,12 +187,6 @@ class PublicSuffix::RuleExceptionTest < Minitest::Unit::TestCase
227
187
  assert_equal %w( foo.british-library uk ), @klass.new("!british-library.uk").decompose("foo.british-library.uk")
228
188
  end
229
189
 
230
- def test_decompose_with_fully_qualified_domain_name
231
- assert_equal [nil, nil], @klass.new("!british-library.uk").decompose("uk.")
232
- assert_equal %w( british-library uk ), @klass.new("!british-library.uk").decompose("british-library.uk.")
233
- assert_equal %w( foo.british-library uk ), @klass.new("!british-library.uk").decompose("foo.british-library.uk.")
234
- end
235
-
236
190
  end
237
191
 
238
192
 
@@ -246,39 +200,8 @@ class PublicSuffix::RuleWildcardTest < Minitest::Unit::TestCase
246
200
  def test_initialize
247
201
  rule = @klass.new("*.aichi.jp")
248
202
  assert_instance_of @klass, rule
249
- assert_equal :wildcard, rule.type
250
- assert_equal "*.aichi.jp", rule.name
251
203
  assert_equal "aichi.jp", rule.value
252
- assert_equal %w(aichi jp).reverse, rule.labels
253
- end
254
-
255
-
256
- def test_match
257
- assert @klass.new("*.uk").match?("example.uk")
258
- assert @klass.new("*.uk").match?("example.co.uk")
259
- assert @klass.new("*.co.uk").match?("example.co.uk")
260
- assert !@klass.new("*.go.uk").match?("example.co.uk")
261
- end
262
-
263
- def test_match_with_fully_qualified_domain_name
264
- assert @klass.new("*.uk").match?("uk.")
265
- assert @klass.new("*.uk").match?("co.uk.")
266
- assert @klass.new("*.uk").match?("example.co.uk.")
267
- assert @klass.new("*.uk").match?("www.example.co.uk.")
268
- end
269
-
270
- def test_allow
271
- assert !@klass.new("*.uk").allow?("uk")
272
- assert !@klass.new("*.uk").allow?("co.uk")
273
- assert @klass.new("*.uk").allow?("example.co.uk")
274
- assert @klass.new("*.uk").allow?("www.example.co.uk")
275
- end
276
-
277
- def test_allow_with_fully_qualified_domain_name
278
- assert !@klass.new("*.uk").allow?("uk.")
279
- assert !@klass.new("*.uk").allow?("co.uk.")
280
- assert @klass.new("*.uk").allow?("example.co.uk.")
281
- assert @klass.new("*.uk").allow?("www.example.co.uk.")
204
+ assert_equal "*.aichi.jp", rule.rule
282
205
  end
283
206
 
284
207
 
@@ -298,10 +221,4 @@ class PublicSuffix::RuleWildcardTest < Minitest::Unit::TestCase
298
221
  assert_equal %w( foo.google co.uk ), @klass.new("*.uk").decompose("foo.google.co.uk")
299
222
  end
300
223
 
301
- def test_decompose_with_fully_qualified_domain_name
302
- assert_equal [nil, nil], @klass.new("*.do").decompose("nic.do.")
303
- assert_equal %w( google co.uk ), @klass.new("*.uk").decompose("google.co.uk.")
304
- assert_equal %w( foo.google co.uk ), @klass.new("*.uk").decompose("foo.google.co.uk.")
305
- end
306
-
307
224
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: public_suffix
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.3
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Simone Carletti
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-14 00:00:00.000000000 Z
11
+ date: 2016-05-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -59,17 +59,19 @@ executables: []
59
59
  extensions: []
60
60
  extra_rdoc_files: []
61
61
  files:
62
- - ".gemtest"
63
62
  - ".gitignore"
63
+ - ".rubocop.yml"
64
+ - ".rubocop_defaults.yml"
64
65
  - ".ruby-gemset"
65
66
  - ".travis.yml"
66
67
  - ".yardopts"
68
+ - 2.0-Upgrade.md
67
69
  - CHANGELOG.md
68
70
  - Gemfile
69
71
  - LICENSE.txt
70
72
  - README.md
71
73
  - Rakefile
72
- - data/definitions.txt
74
+ - data/list.txt
73
75
  - lib/public_suffix.rb
74
76
  - lib/public_suffix/domain.rb
75
77
  - lib/public_suffix/errors.rb
@@ -78,13 +80,19 @@ files:
78
80
  - lib/public_suffix/version.rb
79
81
  - public_suffix.gemspec
80
82
  - test/acceptance_test.rb
83
+ - test/benchmark_helper.rb
84
+ - test/execution_profiler.rb
85
+ - test/initialization_profiler.rb
86
+ - test/performance_benchmark.rb
87
+ - test/psl_test.rb
81
88
  - test/test_helper.rb
89
+ - test/tests.txt
82
90
  - test/unit/domain_test.rb
83
91
  - test/unit/errors_test.rb
84
92
  - test/unit/list_test.rb
85
93
  - test/unit/public_suffix_test.rb
86
94
  - test/unit/rule_test.rb
87
- homepage: http://simonecarletti.com/code/publicsuffix
95
+ homepage: https://simonecarletti.com/code/publicsuffix-ruby
88
96
  licenses:
89
97
  - MIT
90
98
  metadata: {}
@@ -104,13 +112,19 @@ required_rubygems_version: !ruby/object:Gem::Requirement
104
112
  version: '0'
105
113
  requirements: []
106
114
  rubyforge_project:
107
- rubygems_version: 2.4.7
115
+ rubygems_version: 2.5.1
108
116
  signing_key:
109
117
  specification_version: 4
110
118
  summary: Domain name parser based on the Public Suffix List.
111
119
  test_files:
112
120
  - test/acceptance_test.rb
121
+ - test/benchmark_helper.rb
122
+ - test/execution_profiler.rb
123
+ - test/initialization_profiler.rb
124
+ - test/performance_benchmark.rb
125
+ - test/psl_test.rb
113
126
  - test/test_helper.rb
127
+ - test/tests.txt
114
128
  - test/unit/domain_test.rb
115
129
  - test/unit/errors_test.rb
116
130
  - test/unit/list_test.rb
data/.gemtest DELETED
File without changes