public_suffix 2.0.5 → 4.0.7

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 (50) hide show
  1. checksums.yaml +5 -5
  2. data/.github/FUNDING.yml +12 -0
  3. data/.github/dependabot.yml +8 -0
  4. data/.github/workflows/release.yml +16 -0
  5. data/.github/workflows/tests.yml +28 -0
  6. data/.gitignore +5 -8
  7. data/.rubocop.yml +19 -1
  8. data/{.rubocop_defaults.yml → .rubocop_opinionated.yml} +62 -34
  9. data/CHANGELOG.md +156 -54
  10. data/Gemfile +9 -5
  11. data/LICENSE.txt +1 -1
  12. data/README.md +44 -15
  13. data/Rakefile +9 -4
  14. data/SECURITY.md +104 -0
  15. data/bin/console +15 -0
  16. data/data/list.txt +3163 -973
  17. data/lib/public_suffix/domain.rb +4 -4
  18. data/lib/public_suffix/errors.rb +3 -1
  19. data/lib/public_suffix/list.rb +78 -117
  20. data/lib/public_suffix/rule.rb +54 -62
  21. data/lib/public_suffix/version.rb +8 -3
  22. data/lib/public_suffix.rb +38 -32
  23. data/public_suffix.gemspec +9 -5
  24. data/test/.empty +2 -0
  25. data/test/acceptance_test.rb +43 -31
  26. data/test/benchmarks/bm_find.rb +66 -0
  27. data/test/benchmarks/bm_find_all.rb +102 -0
  28. data/test/benchmarks/bm_names.rb +91 -0
  29. data/test/benchmarks/bm_select.rb +26 -0
  30. data/test/benchmarks/bm_select_incremental.rb +25 -0
  31. data/test/benchmarks/bm_valid.rb +101 -0
  32. data/test/profilers/domain_profiler.rb +12 -0
  33. data/test/profilers/find_profiler.rb +12 -0
  34. data/test/profilers/find_profiler_jp.rb +12 -0
  35. data/test/{initialization_profiler.rb → profilers/initialization_profiler.rb} +1 -1
  36. data/test/profilers/list_profsize.rb +11 -0
  37. data/test/profilers/object_binsize.rb +57 -0
  38. data/test/psl_test.rb +7 -4
  39. data/test/test_helper.rb +3 -14
  40. data/test/unit/domain_test.rb +17 -15
  41. data/test/unit/errors_test.rb +2 -0
  42. data/test/unit/list_test.rb +54 -72
  43. data/test/unit/public_suffix_test.rb +24 -22
  44. data/test/unit/rule_test.rb +77 -79
  45. metadata +32 -70
  46. data/.ruby-gemset +0 -1
  47. data/.travis.yml +0 -23
  48. data/test/benchmark_helper.rb +0 -4
  49. data/test/execution_profiler.rb +0 -14
  50. data/test/performance_benchmark.rb +0 -38
@@ -0,0 +1,101 @@
1
+ require 'benchmark'
2
+ require_relative "../../lib/public_suffix"
3
+
4
+ NAME_SHORT = "example.de"
5
+ NAME_MEDIUM = "www.subdomain.example.de"
6
+ NAME_LONG = "one.two.three.four.five.example.de"
7
+ NAME_WILD = "one.two.three.four.five.example.bd"
8
+ NAME_EXCP = "one.two.three.four.five.www.ck"
9
+
10
+ IAAA = "www.example.ac"
11
+ IZZZ = "www.example.zone"
12
+
13
+ PAAA = "one.two.three.four.five.example.beep.pl"
14
+ PZZZ = "one.two.three.four.five.example.now.sh"
15
+
16
+ JP = "www.yokoshibahikari.chiba.jp"
17
+ IT = "www.example.it"
18
+ COM = "www.example.com"
19
+
20
+ TIMES = (ARGV.first || 50_000).to_i
21
+
22
+ # Initialize
23
+ PublicSuffix.valid?("example.com")
24
+
25
+ Benchmark.bmbm(25) do |x|
26
+ x.report("NAME_SHORT") do
27
+ TIMES.times { PublicSuffix.valid?(NAME_SHORT) == true }
28
+ end
29
+ x.report("NAME_SHORT (noprivate)") do
30
+ TIMES.times { PublicSuffix.valid?(NAME_SHORT, ignore_private: true) == true }
31
+ end
32
+ x.report("NAME_MEDIUM") do
33
+ TIMES.times { PublicSuffix.valid?(NAME_MEDIUM) == true }
34
+ end
35
+ x.report("NAME_MEDIUM (noprivate)") do
36
+ TIMES.times { PublicSuffix.valid?(NAME_MEDIUM, ignore_private: true) == true }
37
+ end
38
+ x.report("NAME_LONG") do
39
+ TIMES.times { PublicSuffix.valid?(NAME_LONG) == true }
40
+ end
41
+ x.report("NAME_LONG (noprivate)") do
42
+ TIMES.times { PublicSuffix.valid?(NAME_LONG, ignore_private: true) == true }
43
+ end
44
+ x.report("NAME_WILD") do
45
+ TIMES.times { PublicSuffix.valid?(NAME_WILD) == true }
46
+ end
47
+ x.report("NAME_WILD (noprivate)") do
48
+ TIMES.times { PublicSuffix.valid?(NAME_WILD, ignore_private: true) == true }
49
+ end
50
+ x.report("NAME_EXCP") do
51
+ TIMES.times { PublicSuffix.valid?(NAME_EXCP) == true }
52
+ end
53
+ x.report("NAME_EXCP (noprivate)") do
54
+ TIMES.times { PublicSuffix.valid?(NAME_EXCP, ignore_private: true) == true }
55
+ end
56
+
57
+ x.report("IAAA") do
58
+ TIMES.times { PublicSuffix.valid?(IAAA) == true }
59
+ end
60
+ x.report("IAAA (noprivate)") do
61
+ TIMES.times { PublicSuffix.valid?(IAAA, ignore_private: true) == true }
62
+ end
63
+ x.report("IZZZ") do
64
+ TIMES.times { PublicSuffix.valid?(IZZZ) == true }
65
+ end
66
+ x.report("IZZZ (noprivate)") do
67
+ TIMES.times { PublicSuffix.valid?(IZZZ, ignore_private: true) == true }
68
+ end
69
+
70
+ x.report("PAAA") do
71
+ TIMES.times { PublicSuffix.valid?(PAAA) == true }
72
+ end
73
+ x.report("PAAA (noprivate)") do
74
+ TIMES.times { PublicSuffix.valid?(PAAA, ignore_private: true) == true }
75
+ end
76
+ x.report("PZZZ") do
77
+ TIMES.times { PublicSuffix.valid?(PZZZ) == true }
78
+ end
79
+ x.report("PZZZ (noprivate)") do
80
+ TIMES.times { PublicSuffix.valid?(PZZZ, ignore_private: true) == true }
81
+ end
82
+
83
+ x.report("JP") do
84
+ TIMES.times { PublicSuffix.valid?(JP) == true }
85
+ end
86
+ x.report("JP (noprivate)") do
87
+ TIMES.times { PublicSuffix.valid?(JP, ignore_private: true) == true }
88
+ end
89
+ x.report("IT") do
90
+ TIMES.times { PublicSuffix.valid?(IT) == true }
91
+ end
92
+ x.report("IT (noprivate)") do
93
+ TIMES.times { PublicSuffix.valid?(IT, ignore_private: true) == true }
94
+ end
95
+ x.report("COM") do
96
+ TIMES.times { PublicSuffix.valid?(COM) == true }
97
+ end
98
+ x.report("COM (noprivate)") do
99
+ TIMES.times { PublicSuffix.valid?(COM, ignore_private: true) == true }
100
+ end
101
+ end
@@ -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
data/test/psl_test.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "test_helper"
2
4
  require "public_suffix"
3
5
 
@@ -5,14 +7,15 @@ require "public_suffix"
5
7
  # the definitions satisfies the test suite.
6
8
  class PslTest < Minitest::Test
7
9
 
8
- ROOT = File.expand_path("../../", __FILE__)
10
+ ROOT = File.expand_path("..", __dir__)
9
11
 
10
- # rubocop:disable Lint/Eval
12
+ # rubocop:disable Security/Eval
11
13
  def self.tests
12
14
  File.readlines(File.join(ROOT, "test/tests.txt")).map do |line|
13
15
  line = line.strip
14
16
  next if line.empty?
15
17
  next if line.start_with?("//")
18
+
16
19
  input, output = line.split(", ")
17
20
 
18
21
  # handle the case of eval("null"), it must be eval("nil")
@@ -24,7 +27,7 @@ class PslTest < Minitest::Test
24
27
  [input, output]
25
28
  end
26
29
  end
27
- # rubocop:enable
30
+ # rubocop:enable Security/Eval
28
31
 
29
32
 
30
33
  def test_valid
@@ -35,7 +38,7 @@ class PslTest < Minitest::Test
35
38
  failures = []
36
39
  self.class.tests.each do |input, output|
37
40
  # Punycode domains are not supported ATM
38
- next if input =~ /xn\-\-/
41
+ next if input =~ /xn--/
39
42
 
40
43
  domain = PublicSuffix.domain(input) rescue nil
41
44
  failures << [input, output, domain] if output != domain
data/test/test_helper.rb CHANGED
@@ -1,21 +1,10 @@
1
- if ENV["COVERALL"]
2
- require "coveralls"
3
- Coveralls.wear!
4
- end
1
+ # frozen_string_literal: true
5
2
 
6
3
  require "minitest/autorun"
7
4
  require "minitest/reporters"
8
- require "mocha/setup"
5
+ require "mocha/minitest"
9
6
 
10
7
  Minitest::Reporters.use! Minitest::Reporters::DefaultReporter.new(color: true)
11
8
 
12
- $LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
9
+ $LOAD_PATH.unshift File.expand_path("../lib", __dir__)
13
10
  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
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "test_helper"
2
4
 
3
5
  class PublicSuffix::DomainTest < Minitest::Test
@@ -23,23 +25,23 @@ class PublicSuffix::DomainTest < Minitest::Test
23
25
 
24
26
  def test_initialize_with_tld
25
27
  domain = @klass.new("com")
26
- assert_equal "com", domain.tld
27
- assert_equal nil, domain.sld
28
- assert_equal nil, domain.trd
28
+ assert_equal "com", domain.tld
29
+ assert_nil domain.sld
30
+ assert_nil domain.trd
29
31
  end
30
32
 
31
33
  def test_initialize_with_tld_and_sld
32
34
  domain = @klass.new("com", "google")
33
- assert_equal "com", domain.tld
34
- assert_equal "google", domain.sld
35
- assert_equal nil, domain.trd
35
+ assert_equal "com", domain.tld
36
+ assert_equal "google", domain.sld
37
+ assert_nil domain.trd
36
38
  end
37
39
 
38
40
  def test_initialize_with_tld_and_sld_and_trd
39
41
  domain = @klass.new("com", "google", "www")
40
- assert_equal "com", domain.tld
41
- assert_equal "google", domain.sld
42
- assert_equal "www", domain.trd
42
+ assert_equal "com", domain.tld
43
+ assert_equal "google", domain.sld
44
+ assert_equal "www", domain.trd
43
45
  end
44
46
 
45
47
 
@@ -76,8 +78,8 @@ class PublicSuffix::DomainTest < Minitest::Test
76
78
  end
77
79
 
78
80
  def test_domain
79
- assert_equal nil, @klass.new("com").domain
80
- assert_equal nil, @klass.new("tldnotlisted").domain
81
+ assert_nil @klass.new("com").domain
82
+ assert_nil @klass.new("tldnotlisted").domain
81
83
  assert_equal "google.com", @klass.new("com", "google").domain
82
84
  assert_equal "google.tldnotlisted", @klass.new("tldnotlisted", "google").domain
83
85
  assert_equal "google.com", @klass.new("com", "google", "www").domain
@@ -85,10 +87,10 @@ class PublicSuffix::DomainTest < Minitest::Test
85
87
  end
86
88
 
87
89
  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
90
+ assert_nil @klass.new("com").subdomain
91
+ assert_nil @klass.new("tldnotlisted").subdomain
92
+ assert_nil @klass.new("com", "google").subdomain
93
+ assert_nil @klass.new("tldnotlisted", "google").subdomain
92
94
  assert_equal "www.google.com", @klass.new("com", "google", "www").subdomain
93
95
  assert_equal "www.google.tldnotlisted", @klass.new("tldnotlisted", "google", "www").subdomain
94
96
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "test_helper"
2
4
 
3
5
  class ErrorsTest < Minitest::Test
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "test_helper"
2
4
 
3
5
  class PublicSuffix::ListTest < Minitest::Test
@@ -7,7 +9,7 @@ class PublicSuffix::ListTest < Minitest::Test
7
9
  end
8
10
 
9
11
  def teardown
10
- PublicSuffix::List.clear
12
+ PublicSuffix::List.default = nil
11
13
  end
12
14
 
13
15
 
@@ -16,10 +18,6 @@ class PublicSuffix::ListTest < Minitest::Test
16
18
  assert_equal 0, @list.size
17
19
  end
18
20
 
19
- def test_initialize_indexes
20
- assert_equal({}, @list.indexes)
21
- end
22
-
23
21
 
24
22
  def test_equality_with_self
25
23
  list = PublicSuffix::List.new
@@ -31,9 +29,34 @@ class PublicSuffix::ListTest < Minitest::Test
31
29
  assert_equal PublicSuffix::List.new.add(rule), PublicSuffix::List.new.add(rule)
32
30
  end
33
31
 
32
+ def test_each_without_block
33
+ list = PublicSuffix::List.parse(<<LIST)
34
+ alpha
35
+ beta
36
+ LIST
37
+
38
+ assert_kind_of Enumerator, list.each
39
+ assert_equal 2, list.each.count
40
+ assert_equal PublicSuffix::Rule.factory("alpha"), list.each.first
41
+ end
42
+
43
+ def test_each_with_block
44
+ list = PublicSuffix::List.parse(<<LIST)
45
+ alpha
46
+ beta
47
+ LIST
48
+
49
+ entries = []
50
+ list.each { |r| entries << r }
51
+
52
+ assert_equal 2, entries.count
53
+ assert_equal PublicSuffix::Rule.factory("alpha"), entries.first
54
+ end
55
+
56
+
34
57
  def test_add
35
- assert_equal @list, @list.add(PublicSuffix::Rule.factory(""))
36
- assert_equal @list, @list << PublicSuffix::Rule.factory("")
58
+ assert_equal @list, @list.add(PublicSuffix::Rule.factory("foo"))
59
+ assert_equal @list, @list << PublicSuffix::Rule.factory("bar")
37
60
  assert_equal 2, @list.size
38
61
  end
39
62
 
@@ -47,13 +70,6 @@ class PublicSuffix::ListTest < Minitest::Test
47
70
  assert_equal PublicSuffix::Rule.factory("net"), @list.find("google.net")
48
71
  end
49
72
 
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
73
  def test_empty?
58
74
  assert @list.empty?
59
75
  @list.add(PublicSuffix::Rule.factory(""))
@@ -76,7 +92,7 @@ class PublicSuffix::ListTest < Minitest::Test
76
92
 
77
93
 
78
94
  def test_find
79
- list = PublicSuffix::List.parse(<<EOS)
95
+ list = PublicSuffix::List.parse(<<LIST)
80
96
  // This Source Code Form is subject to the terms of the Mozilla Public
81
97
  // License, v. 2.0. If a copy of the MPL was not distributed with this
82
98
  // file, You can obtain one at https://mozilla.org/MPL/2.0/.
@@ -102,7 +118,7 @@ io
102
118
  blogspot.com
103
119
 
104
120
  // ===END PRIVATE DOMAINS===
105
- EOS
121
+ LIST
106
122
 
107
123
  # match IANA
108
124
  assert_equal PublicSuffix::Rule.factory("com"), list.find("example.com")
@@ -129,13 +145,13 @@ EOS
129
145
 
130
146
 
131
147
  def test_select
132
- assert_equal 2, list.select("british-library.uk").size
148
+ assert_equal 2, list.send(:select, "british-library.uk").size
133
149
  end
134
150
 
135
151
  def test_select_name_blank
136
- assert_equal [], list.select(nil)
137
- assert_equal [], list.select("")
138
- assert_equal [], list.select(" ")
152
+ assert_equal [], list.send(:select, nil)
153
+ assert_equal [], list.send(:select, "")
154
+ assert_equal [], list.send(:select, " ")
139
155
  end
140
156
 
141
157
  def test_select_ignore_private
@@ -143,43 +159,36 @@ EOS
143
159
  list.add r1 = PublicSuffix::Rule.factory("io")
144
160
  list.add r2 = PublicSuffix::Rule.factory("example.io", private: true)
145
161
 
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]
162
+ assert_equal list.send(:select, "foo.io"), [r1]
163
+ assert_equal list.send(:select, "example.io"), [r1, r2]
164
+ assert_equal list.send(:select, "foo.example.io"), [r1, r2]
149
165
 
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]
166
+ assert_equal list.send(:select, "foo.io", ignore_private: false), [r1]
167
+ assert_equal list.send(:select, "example.io", ignore_private: false), [r1, r2]
168
+ assert_equal list.send(:select, "foo.example.io", ignore_private: false), [r1, r2]
153
169
 
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]
170
+ assert_equal list.send(:select, "foo.io", ignore_private: true), [r1]
171
+ assert_equal list.send(:select, "example.io", ignore_private: true), [r1]
172
+ assert_equal list.send(:select, "foo.example.io", ignore_private: true), [r1]
157
173
  end
158
174
 
159
175
 
160
176
  def test_self_default_getter
161
177
  PublicSuffix::List.default = nil
162
- assert_nil PublicSuffix::List.class_eval { @default }
178
+ assert_nil(PublicSuffix::List.class_eval { @default })
163
179
  PublicSuffix::List.default
164
- assert_not_equal nil, PublicSuffix::List.class_eval { @default }
180
+ refute_nil(PublicSuffix::List.class_eval { @default })
165
181
  end
166
182
 
167
183
  def test_self_default_setter
168
184
  PublicSuffix::List.default
169
- assert_not_equal nil, PublicSuffix::List.class_eval { @default }
185
+ refute_nil(PublicSuffix::List.class_eval { @default })
170
186
  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 }
187
+ assert_nil(PublicSuffix::List.class_eval { @default })
179
188
  end
180
189
 
181
190
  def test_self_parse
182
- list = PublicSuffix::List.parse(<<EOS)
191
+ list = PublicSuffix::List.parse(<<LIST)
183
192
  // This Source Code Form is subject to the terms of the Mozilla Public
184
193
  // License, v. 2.0. If a copy of the MPL was not distributed with this
185
194
  // file, You can obtain one at https://mozilla.org/MPL/2.0/.
@@ -200,51 +209,24 @@ com
200
209
  blogspot.com
201
210
 
202
211
  // ===END PRIVATE DOMAINS===
203
- EOS
212
+ LIST
204
213
 
205
214
  assert_instance_of PublicSuffix::List, list
206
215
  assert_equal 4, list.size
207
216
 
208
217
  rules = %w( com *.uk !british-library.uk blogspot.com ).map { |name| PublicSuffix::Rule.factory(name) }
209
- assert_equal rules, list.to_a
218
+ assert_equal rules, list.each.to_a
210
219
 
211
220
  # private domains
212
221
  assert_equal false, list.find("com").private
213
222
  assert_equal true, list.find("blogspot.com").private
214
223
  end
215
224
 
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
225
 
244
226
  private
245
227
 
246
228
  def list
247
- @_list ||= PublicSuffix::List.parse(<<EOS)
229
+ @_list ||= PublicSuffix::List.parse(<<LIST)
248
230
  // com : http://en.wikipedia.org/wiki/.com
249
231
  com
250
232
 
@@ -253,7 +235,7 @@ com
253
235
  *.sch.uk
254
236
  !bl.uk
255
237
  !british-library.uk
256
- EOS
238
+ LIST
257
239
  end
258
240
 
259
241
  end