public_suffix 4.0.7 → 5.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,7 +4,7 @@
4
4
  #
5
5
  # Domain name parser based on the Public Suffix List.
6
6
  #
7
- # Copyright (c) 2009-2022 Simone Carletti <weppos@weppos.net>
7
+ # Copyright (c) 2009-2023 Simone Carletti <weppos@weppos.net>
8
8
 
9
9
  module PublicSuffix
10
10
 
@@ -4,7 +4,7 @@
4
4
  #
5
5
  # Domain name parser based on the Public Suffix List.
6
6
  #
7
- # Copyright (c) 2009-2022 Simone Carletti <weppos@weppos.net>
7
+ # Copyright (c) 2009-2023 Simone Carletti <weppos@weppos.net>
8
8
 
9
9
  module PublicSuffix
10
10
 
@@ -4,7 +4,7 @@
4
4
  #
5
5
  # Domain name parser based on the Public Suffix List.
6
6
  #
7
- # Copyright (c) 2009-2022 Simone Carletti <weppos@weppos.net>
7
+ # Copyright (c) 2009-2023 Simone Carletti <weppos@weppos.net>
8
8
 
9
9
  module PublicSuffix
10
10
 
@@ -87,7 +87,7 @@ module PublicSuffix
87
87
  section = 2
88
88
 
89
89
  # skip comments
90
- when line.start_with?(comment_token)
90
+ when line.start_with?(comment_token) # rubocop:disable Lint/DuplicateBranch
91
91
  next
92
92
 
93
93
  else
@@ -4,7 +4,7 @@
4
4
  #
5
5
  # Domain name parser based on the Public Suffix List.
6
6
  #
7
- # Copyright (c) 2009-2022 Simone Carletti <weppos@weppos.net>
7
+ # Copyright (c) 2009-2023 Simone Carletti <weppos@weppos.net>
8
8
 
9
9
  module PublicSuffix
10
10
 
@@ -125,7 +125,7 @@ module PublicSuffix
125
125
  # @param private [Boolean]
126
126
  def initialize(value:, length: nil, private: false)
127
127
  @value = value.to_s
128
- @length = length || @value.count(DOT) + 1
128
+ @length = length || (@value.count(DOT) + 1)
129
129
  @private = private
130
130
  end
131
131
 
@@ -161,7 +161,7 @@ module PublicSuffix
161
161
  # @param name [String] the domain name to check
162
162
  # @return [Boolean]
163
163
  def match?(name)
164
- # Note: it works because of the assumption there are no
164
+ # NOTE: it works because of the assumption there are no
165
165
  # rules like foo.*.com. If the assumption is incorrect,
166
166
  # we need to properly walk the input and skip parts according
167
167
  # to wildcard component.
@@ -221,7 +221,7 @@ module PublicSuffix
221
221
  # @param content [String] the content of the rule
222
222
  # @param private [Boolean]
223
223
  def self.build(content, private: false)
224
- new(value: content.to_s[2..-1], private: private)
224
+ new(value: content.to_s[2..], private: private)
225
225
  end
226
226
 
227
227
  # Initializes a new rule.
@@ -269,7 +269,7 @@ module PublicSuffix
269
269
  # @param content [#to_s] the content of the rule
270
270
  # @param private [Boolean]
271
271
  def self.build(content, private: false)
272
- new(value: content.to_s[1..-1], private: private)
272
+ new(value: content.to_s[1..], private: private)
273
273
  end
274
274
 
275
275
  # Gets the original rule definition.
@@ -299,7 +299,7 @@ module PublicSuffix
299
299
  #
300
300
  # @return [Array<String>]
301
301
  def parts
302
- @value.split(DOT)[1..-1]
302
+ @value.split(DOT)[1..]
303
303
  end
304
304
 
305
305
  end
@@ -1,15 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- #
4
3
  # = Public Suffix
5
4
  #
6
5
  # Domain name parser based on the Public Suffix List.
7
6
  #
8
- # Copyright (c) 2009-2022 Simone Carletti <weppos@weppos.net>
7
+ # Copyright (c) 2009-2023 Simone Carletti <weppos@weppos.net>
9
8
 
10
9
  module PublicSuffix
11
10
 
12
- # @return [String] The current library version.
13
- VERSION = "4.0.7"
11
+ # @return [String] the current library version
12
+ VERSION = "5.0.3"
14
13
 
15
14
  end
data/lib/public_suffix.rb CHANGED
@@ -4,7 +4,7 @@
4
4
  #
5
5
  # Domain name parser based on the Public Suffix List.
6
6
  #
7
- # Copyright (c) 2009-2022 Simone Carletti <weppos@weppos.net>
7
+ # Copyright (c) 2009-2023 Simone Carletti <weppos@weppos.net>
8
8
 
9
9
  require_relative "public_suffix/domain"
10
10
  require_relative "public_suffix/version"
@@ -169,7 +169,7 @@ module PublicSuffix
169
169
 
170
170
  return DomainInvalid.new("Name is blank") if name.empty?
171
171
  return DomainInvalid.new("Name starts with a dot") if name.start_with?(DOT)
172
- return DomainInvalid.new("%s is not expected to contain a scheme" % name) if name.include?("://")
172
+ return DomainInvalid.new(format("%s is not expected to contain a scheme", name)) if name.include?("://")
173
173
 
174
174
  name
175
175
  end
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
20
20
  "source_code_uri" => "https://github.com/weppos/publicsuffix-ruby/tree/v#{s.version}",
21
21
  }
22
22
 
23
- s.required_ruby_version = ">= 2.3"
23
+ s.required_ruby_version = ">= 2.6"
24
24
 
25
25
  s.require_paths = ["lib"]
26
26
  s.files = `git ls-files`.split("\n")
@@ -64,7 +64,7 @@ class AcceptanceTest < Minitest::Test
64
64
  def test_rejected
65
65
  REJECTED_CASES.each do |name, expected|
66
66
  assert_equal expected, PublicSuffix.valid?(name),
67
- "Expected %s to be %s" % [name.inspect, expected.inspect]
67
+ format("Expected %s to be %s", name.inspect, expected.inspect)
68
68
  assert !valid_domain?(name),
69
69
  "#{name} expected to be invalid"
70
70
  end
@@ -72,9 +72,9 @@ class AcceptanceTest < Minitest::Test
72
72
 
73
73
 
74
74
  CASE_CASES = [
75
- ["Www.google.com", %w( www google com )],
76
- ["www.Google.com", %w( www google com )],
77
- ["www.google.Com", %w( www google com )],
75
+ ["Www.google.com", %w[www google com]],
76
+ ["www.Google.com", %w[www google com]],
77
+ ["www.google.Com", %w[www google com]],
78
78
  ].freeze
79
79
 
80
80
  def test_ignore_case
data/test/psl_test.rb CHANGED
@@ -45,7 +45,7 @@ class PslTest < Minitest::Test
45
45
  end
46
46
 
47
47
  message = "The following #{failures.size} tests fail:\n"
48
- failures.each { |i, o, d| message += "Expected %s to be %s, got %s\n" % [i.inspect, o.inspect, d.inspect] }
48
+ failures.each { |i, o, d| message += format("Expected %s to be %s, got %s\n", i.inspect, o.inspect, d.inspect) }
49
49
  assert_equal 0, failures.size, message
50
50
  end
51
51
 
@@ -10,15 +10,15 @@ class PublicSuffix::DomainTest < Minitest::Test
10
10
 
11
11
  # Tokenizes given input into labels.
12
12
  def test_self_name_to_labels
13
- assert_equal %w( someone spaces live com ),
13
+ assert_equal %w[someone spaces live com],
14
14
  PublicSuffix::Domain.name_to_labels("someone.spaces.live.com")
15
- assert_equal %w( leontina23samiko wiki zoho com ),
15
+ assert_equal %w[leontina23samiko wiki zoho com],
16
16
  PublicSuffix::Domain.name_to_labels("leontina23samiko.wiki.zoho.com")
17
17
  end
18
18
 
19
19
  # Converts input into String.
20
20
  def test_self_name_to_labels_converts_input_to_string
21
- assert_equal %w( someone spaces live com ),
21
+ assert_equal %w[someone spaces live com],
22
22
  PublicSuffix::Domain.name_to_labels(:"someone.spaces.live.com")
23
23
  end
24
24
 
@@ -214,7 +214,7 @@ LIST
214
214
  assert_instance_of PublicSuffix::List, list
215
215
  assert_equal 4, list.size
216
216
 
217
- rules = %w( com *.uk !british-library.uk blogspot.com ).map { |name| PublicSuffix::Rule.factory(name) }
217
+ rules = %w[com *.uk !british-library.uk blogspot.com].map { |name| PublicSuffix::Rule.factory(name) }
218
218
  assert_equal rules, list.each.to_a
219
219
 
220
220
  # private domains
@@ -29,8 +29,8 @@ class PublicSuffix::RuleTest < Minitest::Test
29
29
  def test_default_returns_default_wildcard
30
30
  default = PublicSuffix::Rule.default
31
31
  assert_equal PublicSuffix::Rule::Wildcard.build("*"), default
32
- assert_equal %w( example tldnotlisted ), default.decompose("example.tldnotlisted")
33
- assert_equal %w( www.example tldnotlisted ), default.decompose("www.example.tldnotlisted")
32
+ assert_equal %w[example tldnotlisted], default.decompose("example.tldnotlisted")
33
+ assert_equal %w[www.example tldnotlisted], default.decompose("www.example.tldnotlisted")
34
34
  end
35
35
 
36
36
  end
@@ -140,15 +140,15 @@ class PublicSuffix::RuleNormalTest < Minitest::Test
140
140
  end
141
141
 
142
142
  def test_parts
143
- assert_equal %w(com), @klass.build("com").parts
144
- assert_equal %w(co com), @klass.build("co.com").parts
145
- assert_equal %w(mx co com), @klass.build("mx.co.com").parts
143
+ assert_equal %w[com], @klass.build("com").parts
144
+ assert_equal %w[co com], @klass.build("co.com").parts
145
+ assert_equal %w[mx co com], @klass.build("mx.co.com").parts
146
146
  end
147
147
 
148
148
  def test_decompose
149
149
  assert_equal [nil, nil], @klass.build("com").decompose("com")
150
- assert_equal %w( example com ), @klass.build("com").decompose("example.com")
151
- assert_equal %w( foo.example com ), @klass.build("com").decompose("foo.example.com")
150
+ assert_equal %w[example com], @klass.build("com").decompose("example.com")
151
+ assert_equal %w[foo.example com], @klass.build("com").decompose("foo.example.com")
152
152
  end
153
153
 
154
154
  end
@@ -175,14 +175,14 @@ class PublicSuffix::RuleExceptionTest < Minitest::Test
175
175
  end
176
176
 
177
177
  def test_parts
178
- assert_equal %w( uk ), @klass.build("!british-library.uk").parts
179
- assert_equal %w( tokyo jp ), @klass.build("!metro.tokyo.jp").parts
178
+ assert_equal %w[uk], @klass.build("!british-library.uk").parts
179
+ assert_equal %w[tokyo jp], @klass.build("!metro.tokyo.jp").parts
180
180
  end
181
181
 
182
182
  def test_decompose
183
183
  assert_equal [nil, nil], @klass.build("!british-library.uk").decompose("uk")
184
- assert_equal %w( british-library uk ), @klass.build("!british-library.uk").decompose("british-library.uk")
185
- assert_equal %w( foo.british-library uk ), @klass.build("!british-library.uk").decompose("foo.british-library.uk")
184
+ assert_equal %w[british-library uk], @klass.build("!british-library.uk").decompose("british-library.uk")
185
+ assert_equal %w[foo.british-library uk], @klass.build("!british-library.uk").decompose("foo.british-library.uk")
186
186
  end
187
187
 
188
188
  end
@@ -209,14 +209,14 @@ class PublicSuffix::RuleWildcardTest < Minitest::Test
209
209
  end
210
210
 
211
211
  def test_parts
212
- assert_equal %w( uk ), @klass.build("*.uk").parts
213
- assert_equal %w( co uk ), @klass.build("*.co.uk").parts
212
+ assert_equal %w[uk], @klass.build("*.uk").parts
213
+ assert_equal %w[co uk], @klass.build("*.co.uk").parts
214
214
  end
215
215
 
216
216
  def test_decompose
217
217
  assert_equal [nil, nil], @klass.build("*.do").decompose("nic.do")
218
- assert_equal %w( google co.uk ), @klass.build("*.uk").decompose("google.co.uk")
219
- assert_equal %w( foo.google co.uk ), @klass.build("*.uk").decompose("foo.google.co.uk")
218
+ assert_equal %w[google co.uk], @klass.build("*.uk").decompose("google.co.uk")
219
+ assert_equal %w[foo.google co.uk], @klass.build("*.uk").decompose("foo.google.co.uk")
220
220
  end
221
221
 
222
222
  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: 4.0.7
4
+ version: 5.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Simone Carletti
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-04-12 00:00:00.000000000 Z
11
+ date: 2023-07-11 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: PublicSuffix can parse and decompose a domain name into top level domain,
14
14
  domain and subdomains.
@@ -21,6 +21,7 @@ extra_rdoc_files:
21
21
  files:
22
22
  - ".github/FUNDING.yml"
23
23
  - ".github/dependabot.yml"
24
+ - ".github/workflows/psl-update.yml"
24
25
  - ".github/workflows/release.yml"
25
26
  - ".github/workflows/tests.yml"
26
27
  - ".gitignore"
@@ -71,10 +72,10 @@ licenses:
71
72
  metadata:
72
73
  bug_tracker_uri: https://github.com/weppos/publicsuffix-ruby/issues
73
74
  changelog_uri: https://github.com/weppos/publicsuffix-ruby/blob/master/CHANGELOG.md
74
- documentation_uri: https://rubydoc.info/gems/public_suffix/4.0.7
75
+ documentation_uri: https://rubydoc.info/gems/public_suffix/5.0.3
75
76
  homepage_uri: https://simonecarletti.com/code/publicsuffix-ruby
76
- source_code_uri: https://github.com/weppos/publicsuffix-ruby/tree/v4.0.7
77
- post_install_message:
77
+ source_code_uri: https://github.com/weppos/publicsuffix-ruby/tree/v5.0.3
78
+ post_install_message:
78
79
  rdoc_options: []
79
80
  require_paths:
80
81
  - lib
@@ -82,15 +83,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
82
83
  requirements:
83
84
  - - ">="
84
85
  - !ruby/object:Gem::Version
85
- version: '2.3'
86
+ version: '2.6'
86
87
  required_rubygems_version: !ruby/object:Gem::Requirement
87
88
  requirements:
88
89
  - - ">="
89
90
  - !ruby/object:Gem::Version
90
91
  version: '0'
91
92
  requirements: []
92
- rubygems_version: 3.3.7
93
- signing_key:
93
+ rubygems_version: 3.4.10
94
+ signing_key:
94
95
  specification_version: 4
95
96
  summary: Domain name parser based on the Public Suffix List.
96
97
  test_files: []