public_suffix 2.0.5 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,12 @@
1
+ $LOAD_PATH.unshift File.expand_path("../../lib", __dir__)
2
+
3
+ require "memory_profiler"
4
+ require "public_suffix"
5
+
6
+ PublicSuffix::List.default
7
+
8
+ report = MemoryProfiler.report do
9
+ PublicSuffix.domain("www.example.com")
10
+ end
11
+
12
+ report.pretty_print
@@ -0,0 +1,12 @@
1
+ $LOAD_PATH.unshift File.expand_path("../../lib", __dir__)
2
+
3
+ require "memory_profiler"
4
+ require "public_suffix"
5
+
6
+ PublicSuffix::List.default
7
+
8
+ report = MemoryProfiler.report do
9
+ PublicSuffix::List.default.find("www.example.com")
10
+ end
11
+
12
+ report.pretty_print
@@ -0,0 +1,12 @@
1
+ $LOAD_PATH.unshift File.expand_path("../../lib", __dir__)
2
+
3
+ require "memory_profiler"
4
+ require "public_suffix"
5
+
6
+ PublicSuffix::List.default
7
+
8
+ report = MemoryProfiler.report do
9
+ PublicSuffix::List.default.find("a.b.ide.kyoto.jp")
10
+ end
11
+
12
+ report.pretty_print
@@ -1,4 +1,4 @@
1
- $LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
1
+ $LOAD_PATH.unshift File.expand_path("../../lib", __dir__)
2
2
 
3
3
  require "memory_profiler"
4
4
  require "public_suffix"
@@ -0,0 +1,11 @@
1
+ $LOAD_PATH.unshift File.expand_path("../../lib", __dir__)
2
+
3
+ require_relative "object_binsize"
4
+ require "public_suffix"
5
+
6
+ list = PublicSuffix::List.default
7
+ puts "#{list.size} rules:"
8
+
9
+ prof = ObjectBinsize.new
10
+ prof.report(PublicSuffix::List.default, label: "PublicSuffix::List size")
11
+ prof.report(PublicSuffix::List.default.instance_variable_get(:@rules), label: "Size of rules")
@@ -0,0 +1,57 @@
1
+ require 'tempfile'
2
+
3
+ # A very simple memory profiles that checks the full size of a variable
4
+ # by serializing into a binary file.
5
+ #
6
+ # Yes, I know this is very rough, but there are cases where ObjectSpace.memsize_of
7
+ # doesn't cooperate, and this is one of the possible workarounds.
8
+ #
9
+ # For certain cases, it works (TM).
10
+ class ObjectBinsize
11
+
12
+ def measure(var, label: nil)
13
+ dump(var, label: label)
14
+ end
15
+
16
+ def report(var, label: nil, padding: 10)
17
+ file = measure(var, label: label)
18
+
19
+ size = format_integer(file.size)
20
+ name = label || File.basename(file.path)
21
+ printf("%#{padding}s %s\n", size, name)
22
+ end
23
+
24
+ private
25
+
26
+ def dump(var, **args)
27
+ file = Tempfile.new(args[:label].to_s)
28
+ file.write(Marshal.dump(var))
29
+ file
30
+ ensure
31
+ file.close
32
+ end
33
+
34
+ def format_integer(int)
35
+ int.to_s.reverse.gsub(/...(?=.)/, '\&,').reverse
36
+ end
37
+
38
+ end
39
+
40
+ if __FILE__ == $0
41
+ prof = ObjectBinsize.new
42
+
43
+ prof.report(nil, label: "nil")
44
+ prof.report(false, label: "false")
45
+ prof.report(true, label: "true")
46
+ prof.report(0, label: "integer")
47
+ prof.report("", label: "empty string")
48
+ prof.report({}, label: "empty hash")
49
+ prof.report({}, label: "empty array")
50
+
51
+ prof.report({ foo: "1" }, label: "hash 1 item (symbol)")
52
+ prof.report({ foo: "1", bar: 2 }, label: "hash 2 items (symbol)")
53
+ prof.report({ "foo" => "1" }, label: "hash 1 item (string)")
54
+ prof.report({ "foo" => "1", "bar" => 2 }, label: "hash 2 items (string)")
55
+
56
+ prof.report("big string" * 200, label: "big string * 200")
57
+ end
@@ -7,7 +7,7 @@ class PslTest < Minitest::Test
7
7
 
8
8
  ROOT = File.expand_path("../../", __FILE__)
9
9
 
10
- # rubocop:disable Lint/Eval
10
+ # rubocop:disable Security/Eval
11
11
  def self.tests
12
12
  File.readlines(File.join(ROOT, "test/tests.txt")).map do |line|
13
13
  line = line.strip
@@ -11,11 +11,3 @@ Minitest::Reporters.use! Minitest::Reporters::DefaultReporter.new(color: true)
11
11
 
12
12
  $LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
13
13
  require "public_suffix"
14
-
15
- Minitest::Test.class_eval do
16
- unless method_exists?(:assert_not_equal)
17
- def assert_not_equal(exp, act, msg = nil)
18
- assert_operator(exp, :!=, act, msg)
19
- end
20
- end
21
- end
@@ -23,23 +23,23 @@ class PublicSuffix::DomainTest < Minitest::Test
23
23
 
24
24
  def test_initialize_with_tld
25
25
  domain = @klass.new("com")
26
- assert_equal "com", domain.tld
27
- assert_equal nil, domain.sld
28
- assert_equal nil, domain.trd
26
+ assert_equal "com", domain.tld
27
+ assert_nil domain.sld
28
+ assert_nil domain.trd
29
29
  end
30
30
 
31
31
  def test_initialize_with_tld_and_sld
32
32
  domain = @klass.new("com", "google")
33
- assert_equal "com", domain.tld
34
- assert_equal "google", domain.sld
35
- assert_equal nil, domain.trd
33
+ assert_equal "com", domain.tld
34
+ assert_equal "google", domain.sld
35
+ assert_nil domain.trd
36
36
  end
37
37
 
38
38
  def test_initialize_with_tld_and_sld_and_trd
39
39
  domain = @klass.new("com", "google", "www")
40
- assert_equal "com", domain.tld
41
- assert_equal "google", domain.sld
42
- assert_equal "www", domain.trd
40
+ assert_equal "com", domain.tld
41
+ assert_equal "google", domain.sld
42
+ assert_equal "www", domain.trd
43
43
  end
44
44
 
45
45
 
@@ -76,8 +76,8 @@ class PublicSuffix::DomainTest < Minitest::Test
76
76
  end
77
77
 
78
78
  def test_domain
79
- assert_equal nil, @klass.new("com").domain
80
- assert_equal nil, @klass.new("tldnotlisted").domain
79
+ assert_nil @klass.new("com").domain
80
+ assert_nil @klass.new("tldnotlisted").domain
81
81
  assert_equal "google.com", @klass.new("com", "google").domain
82
82
  assert_equal "google.tldnotlisted", @klass.new("tldnotlisted", "google").domain
83
83
  assert_equal "google.com", @klass.new("com", "google", "www").domain
@@ -85,10 +85,10 @@ class PublicSuffix::DomainTest < Minitest::Test
85
85
  end
86
86
 
87
87
  def test_subdomain
88
- assert_equal nil, @klass.new("com").subdomain
89
- assert_equal nil, @klass.new("tldnotlisted").subdomain
90
- assert_equal nil, @klass.new("com", "google").subdomain
91
- assert_equal nil, @klass.new("tldnotlisted", "google").subdomain
88
+ assert_nil @klass.new("com").subdomain
89
+ assert_nil @klass.new("tldnotlisted").subdomain
90
+ assert_nil @klass.new("com", "google").subdomain
91
+ assert_nil @klass.new("tldnotlisted", "google").subdomain
92
92
  assert_equal "www.google.com", @klass.new("com", "google", "www").subdomain
93
93
  assert_equal "www.google.tldnotlisted", @klass.new("tldnotlisted", "google", "www").subdomain
94
94
  end
@@ -7,7 +7,7 @@ class PublicSuffix::ListTest < Minitest::Test
7
7
  end
8
8
 
9
9
  def teardown
10
- PublicSuffix::List.clear
10
+ PublicSuffix::List.default = nil
11
11
  end
12
12
 
13
13
 
@@ -16,10 +16,6 @@ class PublicSuffix::ListTest < Minitest::Test
16
16
  assert_equal 0, @list.size
17
17
  end
18
18
 
19
- def test_initialize_indexes
20
- assert_equal({}, @list.indexes)
21
- end
22
-
23
19
 
24
20
  def test_equality_with_self
25
21
  list = PublicSuffix::List.new
@@ -31,9 +27,34 @@ class PublicSuffix::ListTest < Minitest::Test
31
27
  assert_equal PublicSuffix::List.new.add(rule), PublicSuffix::List.new.add(rule)
32
28
  end
33
29
 
30
+ def test_each_without_block
31
+ list = PublicSuffix::List.parse(<<EOS)
32
+ alpha
33
+ beta
34
+ EOS
35
+
36
+ assert_kind_of Enumerator, list.each
37
+ assert_equal 2, list.each.count
38
+ assert_equal PublicSuffix::Rule.factory("alpha"), list.each.first
39
+ end
40
+
41
+ def test_each_with_block
42
+ list = PublicSuffix::List.parse(<<EOS)
43
+ alpha
44
+ beta
45
+ EOS
46
+
47
+ entries = []
48
+ list.each { |r| entries << r }
49
+
50
+ assert_equal 2, entries.count
51
+ assert_equal PublicSuffix::Rule.factory("alpha"), entries.first
52
+ end
53
+
54
+
34
55
  def test_add
35
- assert_equal @list, @list.add(PublicSuffix::Rule.factory(""))
36
- assert_equal @list, @list << PublicSuffix::Rule.factory("")
56
+ assert_equal @list, @list.add(PublicSuffix::Rule.factory("foo"))
57
+ assert_equal @list, @list << PublicSuffix::Rule.factory("bar")
37
58
  assert_equal 2, @list.size
38
59
  end
39
60
 
@@ -47,13 +68,6 @@ class PublicSuffix::ListTest < Minitest::Test
47
68
  assert_equal PublicSuffix::Rule.factory("net"), @list.find("google.net")
48
69
  end
49
70
 
50
- def test_add_should_not_duplicate_indices
51
- @list = PublicSuffix::List.parse("com")
52
- @list.add(PublicSuffix::Rule.factory("net"))
53
-
54
- assert_equal @list.indexes["com"], [0]
55
- end
56
-
57
71
  def test_empty?
58
72
  assert @list.empty?
59
73
  @list.add(PublicSuffix::Rule.factory(""))
@@ -129,13 +143,13 @@ EOS
129
143
 
130
144
 
131
145
  def test_select
132
- assert_equal 2, list.select("british-library.uk").size
146
+ assert_equal 2, list.send(:select, "british-library.uk").size
133
147
  end
134
148
 
135
149
  def test_select_name_blank
136
- assert_equal [], list.select(nil)
137
- assert_equal [], list.select("")
138
- assert_equal [], list.select(" ")
150
+ assert_equal [], list.send(:select, nil)
151
+ assert_equal [], list.send(:select, "")
152
+ assert_equal [], list.send(:select, " ")
139
153
  end
140
154
 
141
155
  def test_select_ignore_private
@@ -143,39 +157,32 @@ EOS
143
157
  list.add r1 = PublicSuffix::Rule.factory("io")
144
158
  list.add r2 = PublicSuffix::Rule.factory("example.io", private: true)
145
159
 
146
- assert_equal list.select("foo.io"), [r1]
147
- assert_equal list.select("example.io"), [r1, r2]
148
- assert_equal list.select("foo.example.io"), [r1, r2]
160
+ assert_equal list.send(:select, "foo.io"), [r1]
161
+ assert_equal list.send(:select, "example.io"), [r1, r2]
162
+ assert_equal list.send(:select, "foo.example.io"), [r1, r2]
149
163
 
150
- assert_equal list.select("foo.io", ignore_private: false), [r1]
151
- assert_equal list.select("example.io", ignore_private: false), [r1, r2]
152
- assert_equal list.select("foo.example.io", ignore_private: false), [r1, r2]
164
+ assert_equal list.send(:select, "foo.io", ignore_private: false), [r1]
165
+ assert_equal list.send(:select, "example.io", ignore_private: false), [r1, r2]
166
+ assert_equal list.send(:select, "foo.example.io", ignore_private: false), [r1, r2]
153
167
 
154
- assert_equal list.select("foo.io", ignore_private: true), [r1]
155
- assert_equal list.select("example.io", ignore_private: true), [r1]
156
- assert_equal list.select("foo.example.io", ignore_private: true), [r1]
168
+ assert_equal list.send(:select, "foo.io", ignore_private: true), [r1]
169
+ assert_equal list.send(:select, "example.io", ignore_private: true), [r1]
170
+ assert_equal list.send(:select, "foo.example.io", ignore_private: true), [r1]
157
171
  end
158
172
 
159
173
 
160
174
  def test_self_default_getter
161
175
  PublicSuffix::List.default = nil
162
- assert_nil PublicSuffix::List.class_eval { @default }
176
+ assert_nil(PublicSuffix::List.class_eval { @default })
163
177
  PublicSuffix::List.default
164
- assert_not_equal nil, PublicSuffix::List.class_eval { @default }
178
+ refute_nil(PublicSuffix::List.class_eval { @default })
165
179
  end
166
180
 
167
181
  def test_self_default_setter
168
182
  PublicSuffix::List.default
169
- assert_not_equal nil, PublicSuffix::List.class_eval { @default }
183
+ refute_nil(PublicSuffix::List.class_eval { @default })
170
184
  PublicSuffix::List.default = nil
171
- assert_equal nil, PublicSuffix::List.class_eval { @default }
172
- end
173
-
174
- def test_self_clear
175
- PublicSuffix::List.default
176
- assert_not_equal nil, PublicSuffix::List.class_eval { @default }
177
- PublicSuffix::List.clear
178
- assert_equal nil, PublicSuffix::List.class_eval { @default }
185
+ assert_nil(PublicSuffix::List.class_eval { @default })
179
186
  end
180
187
 
181
188
  def test_self_parse
@@ -206,40 +213,13 @@ EOS
206
213
  assert_equal 4, list.size
207
214
 
208
215
  rules = %w( com *.uk !british-library.uk blogspot.com ).map { |name| PublicSuffix::Rule.factory(name) }
209
- assert_equal rules, list.to_a
216
+ assert_equal rules, list.each.to_a
210
217
 
211
218
  # private domains
212
219
  assert_equal false, list.find("com").private
213
220
  assert_equal true, list.find("blogspot.com").private
214
221
  end
215
222
 
216
- def test_self_parse_indexes
217
- list = PublicSuffix::List.parse(<<EOS)
218
- // This Source Code Form is subject to the terms of the Mozilla Public
219
- // License, v. 2.0. If a copy of the MPL was not distributed with this
220
- // file, You can obtain one at https://mozilla.org/MPL/2.0/.
221
-
222
- // ===BEGIN ICANN DOMAINS===
223
-
224
- // com
225
- com
226
-
227
- // uk
228
- *.uk
229
- !british-library.uk
230
-
231
- // ===END ICANN DOMAINS===
232
- // ===BEGIN PRIVATE DOMAINS===
233
-
234
- // Google, Inc.
235
- blogspot.com
236
-
237
- // ===END PRIVATE DOMAINS===
238
- EOS
239
-
240
- assert_equal({ "com" => [0, 3], "uk" => [1, 2] }, list.indexes)
241
- end
242
-
243
223
 
244
224
  private
245
225
 
@@ -13,7 +13,7 @@ class PublicSuffixTest < Minitest::Test
13
13
  domain = PublicSuffix.parse("www.example.blogspot.com")
14
14
  assert_equal "com", domain.tld
15
15
  ensure
16
- PublicSuffix::List.clear
16
+ PublicSuffix::List.default = nil
17
17
  end
18
18
 
19
19
 
@@ -22,13 +22,13 @@ class PublicSuffixTest < Minitest::Test
22
22
  assert_instance_of PublicSuffix::Domain, domain
23
23
  assert_equal "com", domain.tld
24
24
  assert_equal "example", domain.sld
25
- assert_equal nil, domain.trd
25
+ assert_nil domain.trd
26
26
 
27
27
  domain = PublicSuffix.parse("example.co.uk")
28
28
  assert_instance_of PublicSuffix::Domain, domain
29
29
  assert_equal "co.uk", domain.tld
30
30
  assert_equal "example", domain.sld
31
- assert_equal nil, domain.trd
31
+ assert_nil domain.trd
32
32
  end
33
33
 
34
34
  def test_self_parse_a_domain_with_tld_and_sld_and_trd
@@ -83,7 +83,7 @@ class PublicSuffixTest < Minitest::Test
83
83
  assert_instance_of PublicSuffix::Domain, domain
84
84
  assert_equal "tldnotlisted", domain.tld
85
85
  assert_equal "example", domain.sld
86
- assert_equal nil, domain.trd
86
+ assert_nil domain.trd
87
87
  end
88
88
 
89
89
  def test_self_parse_with_unallowed_domain
@@ -169,7 +169,7 @@ class PublicSuffixTest < Minitest::Test
169
169
  ].each do |input, _|
170
170
  error = PublicSuffix.normalize(input)
171
171
  assert_instance_of PublicSuffix::DomainInvalid, error
172
- assert_match /scheme/, error.message
172
+ assert_match(/scheme/, error.message)
173
173
  end
174
174
  end
175
175
 
@@ -26,7 +26,7 @@ class PublicSuffix::RuleTest < Minitest::Test
26
26
 
27
27
  def test_default_returns_default_wildcard
28
28
  default = PublicSuffix::Rule.default
29
- assert_equal PublicSuffix::Rule::Wildcard.new("*"), default
29
+ assert_equal PublicSuffix::Rule::Wildcard.build("*"), default
30
30
  assert_equal %w( example tldnotlisted ), default.decompose("example.tldnotlisted")
31
31
  assert_equal %w( www.example tldnotlisted ), default.decompose("www.example.tldnotlisted")
32
32
  end
@@ -45,24 +45,24 @@ class PublicSuffix::RuleBaseTest < Minitest::Test
45
45
 
46
46
 
47
47
  def test_initialize
48
- rule = @klass.new("verona.it")
49
- assert_instance_of @klass, rule
50
- assert_equal "verona.it", rule.value
48
+ rule = @klass.new(value: "verona.it")
49
+ assert_instance_of @klass, rule
50
+ assert_equal "verona.it", rule.value
51
51
  end
52
52
 
53
53
 
54
54
  def test_equality_with_self
55
- rule = PublicSuffix::Rule::Base.new("foo")
55
+ rule = PublicSuffix::Rule::Base.new(value: "foo")
56
56
  assert_equal rule, rule
57
57
  end
58
58
 
59
59
  # rubocop:disable Style/SingleLineMethods
60
60
  def test_equality_with_internals
61
- assert_equal @klass.new("foo"), @klass.new("foo")
62
- assert_not_equal @klass.new("foo"), @klass.new("bar")
63
- assert_not_equal @klass.new("foo"), PublicSuffix::Rule::Test.new("foo")
64
- assert_not_equal @klass.new("foo"), PublicSuffix::Rule::Test.new("bar")
65
- assert_not_equal @klass.new("foo"), Class.new { def name; foo; end }.new
61
+ assert_equal @klass.new(value: "foo"), @klass.new(value: "foo")
62
+ refute_equal @klass.new(value: "foo"), @klass.new(value: "bar")
63
+ refute_equal @klass.new(value: "foo"), PublicSuffix::Rule::Test.new(value: "foo")
64
+ refute_equal @klass.new(value: "foo"), PublicSuffix::Rule::Test.new(value: "bar")
65
+ refute_equal @klass.new(value: "foo"), Class.new { def name; foo; end }.new
66
66
  end
67
67
  # rubocop:enable Style/SingleLineMethods
68
68
 
@@ -105,16 +105,12 @@ class PublicSuffix::RuleBaseTest < Minitest::Test
105
105
  end
106
106
 
107
107
 
108
- def test_length
109
- assert_raises(NotImplementedError) { @klass.new("com").length }
110
- end
111
-
112
108
  def test_parts
113
- assert_raises(NotImplementedError) { @klass.new("com").parts }
109
+ assert_raises(NotImplementedError) { @klass.new(value: "com").parts }
114
110
  end
115
111
 
116
112
  def test_decompose
117
- assert_raises(NotImplementedError) { @klass.new("com").decompose("google.com") }
113
+ assert_raises(NotImplementedError) { @klass.new(value: "com").decompose("google.com") }
118
114
  end
119
115
 
120
116
  end
@@ -127,8 +123,8 @@ class PublicSuffix::RuleNormalTest < Minitest::Test
127
123
  end
128
124
 
129
125
 
130
- def test_initialize
131
- rule = @klass.new("verona.it")
126
+ def test_build
127
+ rule = @klass.build("verona.it")
132
128
  assert_instance_of @klass, rule
133
129
  assert_equal "verona.it", rule.value
134
130
  assert_equal "verona.it", rule.rule
@@ -136,21 +132,21 @@ class PublicSuffix::RuleNormalTest < Minitest::Test
136
132
 
137
133
 
138
134
  def test_length
139
- assert_equal 1, @klass.new("com").length
140
- assert_equal 2, @klass.new("co.com").length
141
- assert_equal 3, @klass.new("mx.co.com").length
135
+ assert_equal 1, @klass.build("com").length
136
+ assert_equal 2, @klass.build("co.com").length
137
+ assert_equal 3, @klass.build("mx.co.com").length
142
138
  end
143
139
 
144
140
  def test_parts
145
- assert_equal %w(com), @klass.new("com").parts
146
- assert_equal %w(co com), @klass.new("co.com").parts
147
- assert_equal %w(mx co com), @klass.new("mx.co.com").parts
141
+ assert_equal %w(com), @klass.build("com").parts
142
+ assert_equal %w(co com), @klass.build("co.com").parts
143
+ assert_equal %w(mx co com), @klass.build("mx.co.com").parts
148
144
  end
149
145
 
150
146
  def test_decompose
151
- assert_equal [nil, nil], @klass.new("com").decompose("com")
152
- assert_equal %w( example com ), @klass.new("com").decompose("example.com")
153
- assert_equal %w( foo.example com ), @klass.new("com").decompose("foo.example.com")
147
+ assert_equal [nil, nil], @klass.build("com").decompose("com")
148
+ assert_equal %w( example com ), @klass.build("com").decompose("example.com")
149
+ assert_equal %w( foo.example com ), @klass.build("com").decompose("foo.example.com")
154
150
  end
155
151
 
156
152
  end
@@ -164,27 +160,27 @@ class PublicSuffix::RuleExceptionTest < Minitest::Test
164
160
 
165
161
 
166
162
  def test_initialize
167
- rule = @klass.new("!british-library.uk")
168
- assert_instance_of @klass, rule
169
- assert_equal "british-library.uk", rule.value
170
- assert_equal "!british-library.uk", rule.rule
163
+ rule = @klass.build("!british-library.uk")
164
+ assert_instance_of @klass, rule
165
+ assert_equal "british-library.uk", rule.value
166
+ assert_equal "!british-library.uk", rule.rule
171
167
  end
172
168
 
173
169
 
174
170
  def test_length
175
- assert_equal 1, @klass.new("!british-library.uk").length
176
- assert_equal 2, @klass.new("!foo.british-library.uk").length
171
+ assert_equal 2, @klass.build("!british-library.uk").length
172
+ assert_equal 3, @klass.build("!foo.british-library.uk").length
177
173
  end
178
174
 
179
175
  def test_parts
180
- assert_equal %w( uk ), @klass.new("!british-library.uk").parts
181
- assert_equal %w( tokyo jp ), @klass.new("!metro.tokyo.jp").parts
176
+ assert_equal %w( uk ), @klass.build("!british-library.uk").parts
177
+ assert_equal %w( tokyo jp ), @klass.build("!metro.tokyo.jp").parts
182
178
  end
183
179
 
184
180
  def test_decompose
185
- assert_equal [nil, nil], @klass.new("!british-library.uk").decompose("uk")
186
- assert_equal %w( british-library uk ), @klass.new("!british-library.uk").decompose("british-library.uk")
187
- assert_equal %w( foo.british-library uk ), @klass.new("!british-library.uk").decompose("foo.british-library.uk")
181
+ assert_equal [nil, nil], @klass.build("!british-library.uk").decompose("uk")
182
+ assert_equal %w( british-library uk ), @klass.build("!british-library.uk").decompose("british-library.uk")
183
+ assert_equal %w( foo.british-library uk ), @klass.build("!british-library.uk").decompose("foo.british-library.uk")
188
184
  end
189
185
 
190
186
  end
@@ -198,27 +194,27 @@ class PublicSuffix::RuleWildcardTest < Minitest::Test
198
194
 
199
195
 
200
196
  def test_initialize
201
- rule = @klass.new("*.aichi.jp")
202
- assert_instance_of @klass, rule
203
- assert_equal "aichi.jp", rule.value
204
- assert_equal "*.aichi.jp", rule.rule
197
+ rule = @klass.build("*.aichi.jp")
198
+ assert_instance_of @klass, rule
199
+ assert_equal "aichi.jp", rule.value
200
+ assert_equal "*.aichi.jp", rule.rule
205
201
  end
206
202
 
207
203
 
208
204
  def test_length
209
- assert_equal 2, @klass.new("*.uk").length
210
- assert_equal 3, @klass.new("*.co.uk").length
205
+ assert_equal 2, @klass.build("*.uk").length
206
+ assert_equal 3, @klass.build("*.co.uk").length
211
207
  end
212
208
 
213
209
  def test_parts
214
- assert_equal %w( uk ), @klass.new("*.uk").parts
215
- assert_equal %w( co uk ), @klass.new("*.co.uk").parts
210
+ assert_equal %w( uk ), @klass.build("*.uk").parts
211
+ assert_equal %w( co uk ), @klass.build("*.co.uk").parts
216
212
  end
217
213
 
218
214
  def test_decompose
219
- assert_equal [nil, nil], @klass.new("*.do").decompose("nic.do")
220
- assert_equal %w( google co.uk ), @klass.new("*.uk").decompose("google.co.uk")
221
- assert_equal %w( foo.google co.uk ), @klass.new("*.uk").decompose("foo.google.co.uk")
215
+ assert_equal [nil, nil], @klass.build("*.do").decompose("nic.do")
216
+ assert_equal %w( google co.uk ), @klass.build("*.uk").decompose("google.co.uk")
217
+ assert_equal %w( foo.google co.uk ), @klass.build("*.uk").decompose("foo.google.co.uk")
222
218
  end
223
219
 
224
220
  end