Skip to content

Commit 4f20006

Browse files
committed
Bump Ruby min to 3.2 and update CI
* Update GitHub Actions matrix ruby-version to ["3.2", "3.3", "3.4"] * Run RuboCop and upload Codecov only when matrix.ruby-version == '3.4' * Set AllCops TargetRubyVersion to 3.2 and disable SuggestExtensions * Add AllCops Exclude patterns for vendor/**, spec/fixtures/**, and bin/** * Enable Style/StringLiterals and enforce single_quotes * Enable Style/FrozenStringLiteralComment and enforce always * Add Layout/LineLength with Max 120 and allow long comment lines * Exclude spec/**/* and **/*.gemspec from Metrics/BlockLength * Lower Metrics/MethodLength Max to 15 and exclude spec/**/* * Disable Style/AsciiComments * Add frozen_string_literal magic comment to Gemfile and add rubocop-rake dependency * Replace gemspec description with a multiline heredoc description * Bump gemspec required_ruby_version to '>= 3.2.0' * Define SCHEME_PATTERN in Normalizer without calling .freeze * Define IPV4_REGEX and IPV6_REGEX in Validators without calling .freeze * Reformat multiple spec expectations to use multiline parentheses for eq(...) comparisons
1 parent e0ba9d4 commit 4f20006

File tree

8 files changed

+55
-24
lines changed

8 files changed

+55
-24
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
strategy:
1717
fail-fast: false
1818
matrix:
19-
ruby-version: ["3.0", "3.1", "3.2", "3.3"]
19+
ruby-version: ["3.2", "3.3", "3.4"]
2020

2121
steps:
2222
- uses: actions/checkout@v4
@@ -32,11 +32,11 @@ jobs:
3232

3333
- name: Run RuboCop
3434
run: bundle exec rubocop
35-
if: matrix.ruby-version == '3.3'
35+
if: matrix.ruby-version == '3.4'
3636

3737
- name: Upload coverage to Codecov
3838
uses: codecov/codecov-action@v4
39-
if: matrix.ruby-version == '3.3'
39+
if: matrix.ruby-version == '3.4'
4040
with:
4141
token: ${{ secrets.CODECOV_TOKEN }}
4242
fail_ci_if_error: false

.rubocop.yml

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,40 @@
11
AllCops:
2+
# Should match your gemspec's required_ruby_version minimum
3+
TargetRubyVersion: 3.2
24
NewCops: enable
3-
TargetRubyVersion: 3.0.0
5+
SuggestExtensions: false
46
Exclude:
5-
- "bin/**/*"
7+
- "vendor/**/*"
8+
- "spec/fixtures/**/*"
69
- "tmp/**/*"
10+
- "bin/**/*"
11+
12+
# Customize your style preferences here
13+
Style/StringLiterals:
14+
Enabled: true
15+
EnforcedStyle: single_quotes
16+
17+
Style/FrozenStringLiteralComment:
18+
Enabled: true
19+
EnforcedStyle: always
720

8-
require:
9-
- rubocop-performance
10-
- rubocop-rspec
21+
Layout/LineLength:
22+
Max: 120
23+
AllowedPatterns: ['\A#'] # Allow long comment lines
1124

1225
Metrics/BlockLength:
1326
Exclude:
14-
- "spec/**/*.rb"
27+
- "spec/**/*"
28+
- "**/*.gemspec"
1529

1630
Metrics/MethodLength:
17-
Max: 25
31+
Max: 15
32+
Exclude:
33+
- "spec/**/*"
1834

35+
# Disable some overly strict cops for gems
1936
Style/Documentation:
2037
Enabled: false
38+
39+
Style/AsciiComments:
40+
Enabled: false

Gemfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
source 'https://rubygems.org'
24

35
gemspec
@@ -7,5 +9,6 @@ group :development, :test do
79
gem 'rspec', '~> 3.12'
810
gem 'rubocop', '~> 1.50', require: false
911
gem 'rubocop-performance', '~> 1.18', require: false
12+
gem 'rubocop-rake', '~> 0.7.1'
1013
gem 'rubocop-rspec', '~> 2.20', require: false
1114
end

Gemfile.lock

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ GEM
3535
diff-lcs (>= 1.2.0, < 2.0)
3636
rspec-support (~> 3.13.0)
3737
rspec-support (3.13.6)
38-
rubocop (1.81.6)
38+
rubocop (1.81.7)
3939
json (~> 2.3)
4040
language_server-protocol (~> 3.17.0.2)
4141
lint_roller (~> 1.1.0)
@@ -59,6 +59,9 @@ GEM
5959
lint_roller (~> 1.1)
6060
rubocop (>= 1.75.0, < 2.0)
6161
rubocop-ast (>= 1.47.1, < 2.0)
62+
rubocop-rake (0.7.1)
63+
lint_roller (~> 1.1)
64+
rubocop (>= 1.72.1)
6265
rubocop-rspec (2.31.0)
6366
rubocop (~> 1.40)
6467
rubocop-capybara (~> 2.17)
@@ -81,6 +84,7 @@ DEPENDENCIES
8184
rspec (~> 3.12)
8285
rubocop (~> 1.50)
8386
rubocop-performance (~> 1.18)
87+
rubocop-rake (~> 0.7.1)
8488
rubocop-rspec (~> 2.20)
8589

8690
BUNDLED WITH

domain_extractor.gemspec

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@ Gem::Specification.new do |spec|
2020
.rubocop.yml
2121
]
2222

23-
spec.description = 'DomainExtractor is a high-performance url parser and domain parser for Ruby. It delivers precise domain extraction, query parameter parsing, url normalization, and multi-part tld parsing via public_suffix for web scraping and analytics workflows.'
23+
spec.description = <<~DESC.strip
24+
DomainExtractor is a high-performance url parser and domain parser for Ruby. It delivers precise
25+
domain extraction, query parameter parsing, url normalization, and multi-part tld parsing via
26+
public_suffix for web scraping and analytics workflows.
27+
DESC
2428
spec.email = 'dev@opensite.ai'
2529
spec.homepage = 'https://github.com/opensite-ai/domain_extractor'
2630
spec.license = 'MIT'
@@ -37,7 +41,7 @@ Gem::Specification.new do |spec|
3741

3842
spec.add_dependency 'public_suffix', '~> 6.0'
3943

40-
spec.required_ruby_version = '>= 3.0.10'
44+
spec.required_ruby_version = '>= 3.2.0'
4145
spec.require_paths = ['lib']
4246
spec.extra_rdoc_files = ['README.md', 'LICENSE.txt', 'CHANGELOG.md']
4347
spec.rdoc_options = [

lib/domain_extractor/normalizer.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module DomainExtractor
44
# Normalizer ensures URLs include a scheme and removes extraneous whitespace
55
# before passing them into the URI parser.
66
module Normalizer
7-
SCHEME_PATTERN = %r{\A[A-Za-z][A-Za-z0-9+\-.]*://}.freeze
7+
SCHEME_PATTERN = %r{\A[A-Za-z][A-Za-z0-9+\-.]*://}
88

99
module_function
1010

lib/domain_extractor/validators.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ module DomainExtractor
44
# Validators hosts fast checks for excluding unsupported hostnames (e.g. IP addresses).
55
module Validators
66
IPV4_SEGMENT = '(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)'
7-
IPV4_REGEX = /\A#{IPV4_SEGMENT}(?:\.#{IPV4_SEGMENT}){3}\z/.freeze
8-
IPV6_REGEX = /\A\[?[0-9a-fA-F:]+\]?\z/.freeze
7+
IPV4_REGEX = /\A#{IPV4_SEGMENT}(?:\.#{IPV4_SEGMENT}){3}\z/
8+
IPV6_REGEX = /\A\[?[0-9a-fA-F:]+\]?\z/
99

1010
module_function
1111

spec/domain_extractor_spec.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,11 @@
8787
it 'extracts multiple query parameters' do
8888
result = described_class.parse('https://example.com/page?foo=bar&baz=qux&id=123')
8989

90-
expect(result[:query_params]).to eq({
90+
expect(result[:query_params]).to eq(
9191
'foo' => 'bar',
9292
'baz' => 'qux',
9393
'id' => '123'
94-
})
94+
)
9595
end
9696

9797
it 'handles URLs with path and multiple query parameters' do
@@ -100,10 +100,10 @@
100100
expect(result[:subdomain]).to eq('api')
101101
expect(result[:root_domain]).to eq('example.com')
102102
expect(result[:path]).to eq('/v1/users')
103-
expect(result[:query_params]).to eq({
103+
expect(result[:query_params]).to eq(
104104
'page' => '2',
105105
'limit' => '10'
106-
})
106+
)
107107
end
108108

109109
it 'handles URLs with empty query string' do
@@ -178,11 +178,11 @@
178178
it 'converts multiple parameters to hash' do
179179
result = described_class.parse_query_params('foo=bar&baz=qux&id=123')
180180

181-
expect(result).to eq({
181+
expect(result).to eq(
182182
'foo' => 'bar',
183183
'baz' => 'qux',
184184
'id' => '123'
185-
})
185+
)
186186
end
187187

188188
it 'returns empty hash for nil query' do
@@ -212,11 +212,11 @@
212212
it 'handles mixed parameters with and without values' do
213213
result = described_class.parse_query_params('foo=bar&flag&baz=qux')
214214

215-
expect(result).to eq({
215+
expect(result).to eq(
216216
'foo' => 'bar',
217217
'flag' => nil,
218218
'baz' => 'qux'
219-
})
219+
)
220220
end
221221

222222
it 'ignores blank keys' do

0 commit comments

Comments
 (0)