Skip to content

Commit 1f2d6a0

Browse files
authored
Update ruby version to 3.4.2 (#18)
* Update ruby version to 3.4.2 * Update CI workflow to test non-EOL Ruby versions * Remove RUBYOPT environment variable * Bump required_ruby_version to >= 3.1.0 * Bump steep to ~> 1.10.0 * Fix typechecking errors * Drop support for 3.1 * Set TargetRubyVersion to 3.2 * Bump Rubocop dependencies * Resolve linting errors
1 parent 90cd3b2 commit 1f2d6a0

File tree

8 files changed

+179
-97
lines changed

8 files changed

+179
-97
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,7 @@ jobs:
1111
runs-on: ubuntu-latest
1212
strategy:
1313
matrix:
14-
ruby-version: ["2.7", "3.0"]
15-
16-
env:
17-
RUBYOPT: "-W:no-experimental"
14+
ruby-version: ["3.2", "3.3", "3.4"]
1815

1916
steps:
2017
- uses: actions/checkout@v2

.rubocop.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
AllCops:
2-
TargetRubyVersion: 2.7
2+
TargetRubyVersion: 3.2
33
NewCops: enable
4+
SuggestExtensions: false
45
Metrics/AbcSize:
56
Enabled: false
67
Metrics/BlockLength:
@@ -18,6 +19,6 @@ Metrics/MethodLength:
1819
Metrics/ParameterLists:
1920
Max: 7
2021
Metrics/PerceivedComplexity:
21-
Max: 15
22+
Max: 20
2223
Style/ConditionalAssignment:
2324
Enabled: false

.ruby-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.0.1
1+
3.4.2

Gemfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ gemspec
77
gem 'bundler', '~> 2.0'
88
gem 'rake', '~> 13.0'
99
gem 'rspec', '~> 3.0'
10-
gem 'rubocop', '~> 1.23.0'
11-
gem 'rubocop-rake', '~> 0.6.0'
12-
gem 'rubocop-rspec', '~> 2.6.0'
13-
gem 'steep', '~> 0.46.0'
10+
gem 'rubocop', '~> 1.74'
11+
gem 'rubocop-rake', '~> 0.7'
12+
gem 'rubocop-rspec', '~> 2.19'
13+
gem 'steep', '~> 1.10.0'
1414
gem 'yard', '~> 0.9.0'

Gemfile.lock

Lines changed: 128 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -6,93 +6,159 @@ PATH
66
GEM
77
remote: https://rubygems.org/
88
specs:
9-
activesupport (7.0.4.3)
10-
concurrent-ruby (~> 1.0, >= 1.0.2)
9+
activesupport (8.0.2)
10+
base64
11+
benchmark (>= 0.3)
12+
bigdecimal
13+
concurrent-ruby (~> 1.0, >= 1.3.1)
14+
connection_pool (>= 2.2.5)
15+
drb
1116
i18n (>= 1.6, < 2)
17+
logger (>= 1.4.2)
1218
minitest (>= 5.1)
13-
tzinfo (~> 2.0)
14-
ast (2.4.2)
15-
concurrent-ruby (1.2.2)
16-
diff-lcs (1.4.4)
17-
ffi (1.15.4)
18-
i18n (1.12.0)
19+
securerandom (>= 0.3)
20+
tzinfo (~> 2.0, >= 2.0.5)
21+
uri (>= 0.13.1)
22+
ast (2.4.3)
23+
base64 (0.2.0)
24+
benchmark (0.4.0)
25+
bigdecimal (3.1.9)
26+
concurrent-ruby (1.3.5)
27+
connection_pool (2.5.0)
28+
csv (3.3.3)
29+
diff-lcs (1.6.0)
30+
drb (2.2.1)
31+
ffi (1.17.1)
32+
ffi (1.17.1-aarch64-linux-gnu)
33+
ffi (1.17.1-aarch64-linux-musl)
34+
ffi (1.17.1-arm-linux-gnu)
35+
ffi (1.17.1-arm-linux-musl)
36+
ffi (1.17.1-arm64-darwin)
37+
ffi (1.17.1-x86-linux-gnu)
38+
ffi (1.17.1-x86-linux-musl)
39+
ffi (1.17.1-x86_64-darwin)
40+
ffi (1.17.1-x86_64-linux-gnu)
41+
ffi (1.17.1-x86_64-linux-musl)
42+
fileutils (1.7.3)
43+
i18n (1.14.7)
1944
concurrent-ruby (~> 1.0)
20-
language_server-protocol (3.16.0.3)
21-
listen (3.7.0)
45+
json (2.10.2)
46+
language_server-protocol (3.17.0.4)
47+
lint_roller (1.1.0)
48+
listen (3.9.0)
2249
rb-fsevent (~> 0.10, >= 0.10.3)
2350
rb-inotify (~> 0.9, >= 0.9.10)
24-
minitest (5.18.0)
25-
parallel (1.21.0)
26-
parser (3.0.3.0)
51+
logger (1.6.6)
52+
minitest (5.25.5)
53+
mutex_m (0.3.0)
54+
parallel (1.26.3)
55+
parser (3.3.7.2)
2756
ast (~> 2.4.1)
28-
rainbow (3.0.0)
29-
rake (13.0.6)
30-
rb-fsevent (0.11.0)
31-
rb-inotify (0.10.1)
57+
racc
58+
racc (1.8.1)
59+
rainbow (3.1.1)
60+
rake (13.2.1)
61+
rb-fsevent (0.11.2)
62+
rb-inotify (0.11.1)
3263
ffi (~> 1.0)
33-
rbs (1.7.1)
34-
regexp_parser (2.1.1)
35-
rexml (3.2.5)
36-
rspec (3.10.0)
37-
rspec-core (~> 3.10.0)
38-
rspec-expectations (~> 3.10.0)
39-
rspec-mocks (~> 3.10.0)
40-
rspec-core (3.10.1)
41-
rspec-support (~> 3.10.0)
42-
rspec-expectations (3.10.1)
64+
rbs (3.9.0)
65+
logger
66+
regexp_parser (2.10.0)
67+
rspec (3.13.0)
68+
rspec-core (~> 3.13.0)
69+
rspec-expectations (~> 3.13.0)
70+
rspec-mocks (~> 3.13.0)
71+
rspec-core (3.13.3)
72+
rspec-support (~> 3.13.0)
73+
rspec-expectations (3.13.3)
4374
diff-lcs (>= 1.2.0, < 2.0)
44-
rspec-support (~> 3.10.0)
45-
rspec-mocks (3.10.2)
75+
rspec-support (~> 3.13.0)
76+
rspec-mocks (3.13.2)
4677
diff-lcs (>= 1.2.0, < 2.0)
47-
rspec-support (~> 3.10.0)
48-
rspec-support (3.10.3)
49-
rubocop (1.23.0)
78+
rspec-support (~> 3.13.0)
79+
rspec-support (3.13.2)
80+
rubocop (1.74.0)
81+
json (~> 2.3)
82+
language_server-protocol (~> 3.17.0.2)
83+
lint_roller (~> 1.1.0)
5084
parallel (~> 1.10)
51-
parser (>= 3.0.0.0)
85+
parser (>= 3.3.0.2)
5286
rainbow (>= 2.2.2, < 4.0)
53-
regexp_parser (>= 1.8, < 3.0)
54-
rexml
55-
rubocop-ast (>= 1.12.0, < 2.0)
87+
regexp_parser (>= 2.9.3, < 3.0)
88+
rubocop-ast (>= 1.38.0, < 2.0)
5689
ruby-progressbar (~> 1.7)
57-
unicode-display_width (>= 1.4.0, < 3.0)
58-
rubocop-ast (1.13.0)
59-
parser (>= 3.0.1.1)
60-
rubocop-rake (0.6.0)
61-
rubocop (~> 1.0)
62-
rubocop-rspec (2.6.0)
63-
rubocop (~> 1.19)
64-
ruby-progressbar (1.11.0)
65-
steep (0.46.0)
90+
unicode-display_width (>= 2.4.0, < 4.0)
91+
rubocop-ast (1.41.0)
92+
parser (>= 3.3.7.2)
93+
rubocop-capybara (2.22.1)
94+
lint_roller (~> 1.1)
95+
rubocop (~> 1.72, >= 1.72.1)
96+
rubocop-factory_bot (2.27.1)
97+
lint_roller (~> 1.1)
98+
rubocop (~> 1.72, >= 1.72.1)
99+
rubocop-rake (0.7.1)
100+
lint_roller (~> 1.1)
101+
rubocop (>= 1.72.1)
102+
rubocop-rspec (2.31.0)
103+
rubocop (~> 1.40)
104+
rubocop-capybara (~> 2.17)
105+
rubocop-factory_bot (~> 2.22)
106+
rubocop-rspec_rails (~> 2.28)
107+
rubocop-rspec_rails (2.29.1)
108+
rubocop (~> 1.61)
109+
ruby-progressbar (1.13.0)
110+
securerandom (0.4.1)
111+
steep (1.10.0)
66112
activesupport (>= 5.1)
67-
language_server-protocol (>= 3.15, < 4.0)
113+
concurrent-ruby (>= 1.1.10)
114+
csv (>= 3.0.9)
115+
fileutils (>= 1.1.0)
116+
json (>= 2.1.0)
117+
language_server-protocol (>= 3.17.0.4, < 4.0)
68118
listen (~> 3.0)
69-
parallel (>= 1.0.0)
70-
parser (>= 3.0)
119+
logger (>= 1.3.0)
120+
mutex_m (>= 0.3.0)
121+
parser (>= 3.1)
71122
rainbow (>= 2.2.2, < 4.0)
72-
rbs (>= 1.2.0)
73-
terminal-table (>= 2, < 4)
74-
terminal-table (3.0.2)
75-
unicode-display_width (>= 1.1.1, < 3)
123+
rbs (~> 3.9)
124+
securerandom (>= 0.1)
125+
strscan (>= 1.0.0)
126+
terminal-table (>= 2, < 5)
127+
uri (>= 0.12.0)
128+
strscan (3.1.2)
129+
terminal-table (4.0.0)
130+
unicode-display_width (>= 1.1.1, < 4)
76131
tzinfo (2.0.6)
77132
concurrent-ruby (~> 1.0)
78-
unicode-display_width (2.1.0)
79-
yard (0.9.26)
133+
unicode-display_width (3.1.4)
134+
unicode-emoji (~> 4.0, >= 4.0.4)
135+
unicode-emoji (4.0.4)
136+
uri (1.0.3)
137+
yard (0.9.37)
80138

81139
PLATFORMS
82-
x86_64-darwin-19
83-
x86_64-darwin-20
84-
x86_64-linux
140+
aarch64-linux-gnu
141+
aarch64-linux-musl
142+
arm-linux-gnu
143+
arm-linux-musl
144+
arm64-darwin
145+
ruby
146+
x86-linux-gnu
147+
x86-linux-musl
148+
x86_64-darwin
149+
x86_64-linux-gnu
150+
x86_64-linux-musl
85151

86152
DEPENDENCIES
87153
bundler (~> 2.0)
88154
packageurl-ruby!
89155
rake (~> 13.0)
90156
rspec (~> 3.0)
91-
rubocop (~> 1.23.0)
92-
rubocop-rake (~> 0.6.0)
93-
rubocop-rspec (~> 2.6.0)
94-
steep (~> 0.46.0)
157+
rubocop (~> 1.74)
158+
rubocop-rake (~> 0.7)
159+
rubocop-rspec (~> 2.19)
160+
steep (~> 1.10.0)
95161
yard (~> 0.9.0)
96162

97163
BUNDLED WITH
98-
2.2.32
164+
2.6.6

lib/package_url.rb

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,14 @@ def initialize(type:, name:, namespace: nil, version: nil, qualifiers: nil, subp
7272
# @raise [InvalidPackageURL] If the string is not a valid package URL.
7373
# @return [PackageURL]
7474
def self.parse(string)
75-
components = {}
75+
components = {
76+
type: nil,
77+
namespace: nil,
78+
name: nil,
79+
version: nil,
80+
qualifiers: nil,
81+
subpath: nil
82+
}
7683

7784
# Split the purl string once from right on '#'
7885
# - The left side is the remainder
@@ -195,8 +202,16 @@ def self.parse(string)
195202
components[:namespace] = nil
196203
end
197204

198-
new(type: components[:type],
199-
name: components[:name],
205+
# Ensure type and name are not nil before creating the PackageURL instance
206+
raise InvalidPackageURL, 'missing package type' if components[:type].nil?
207+
raise InvalidPackageURL, 'missing package name' if components[:name].nil?
208+
209+
# Create a new PackageURL with validated components
210+
type = components[:type] || '' # This ensures type is never nil
211+
name = components[:name] || '' # This ensures name is never nil
212+
213+
new(type: type,
214+
name: name,
200215
namespace: components[:namespace],
201216
version: components[:version],
202217
qualifiers: components[:qualifiers],

packageurl-ruby.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
1717
DESCRIPTION
1818

1919
spec.homepage = 'https://github.com/package-url/packageurl-ruby'
20-
spec.required_ruby_version = Gem::Requirement.new('>= 2.7.0')
20+
spec.required_ruby_version = Gem::Requirement.new('>= 3.2.0')
2121

2222
spec.license = 'MIT'
2323
spec.metadata['homepage_uri'] = spec.homepage

sig/package_url.rbs

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
class PackageURL
22
VERSION: String
33

4+
class InvalidPackageURL < ArgumentError
5+
end
6+
47
def scheme: () -> String
58
attr_reader type: String
69
attr_reader namespace: String?
@@ -9,32 +12,32 @@ class PackageURL
912
attr_reader qualifiers: Hash[String, String]?
1013
attr_reader subpath: String?
1114

12-
def initialize: (type: String `type`,
13-
?namespace: String? namespace,
14-
name: String name,
15-
?version: String? version,
16-
?qualifiers: Hash[String, String]? qualifiers,
15+
def initialize: (type: String `type`,
16+
?namespace: String? namespace,
17+
name: String name,
18+
?version: String? version,
19+
?qualifiers: Hash[String, String]? qualifiers,
1720
?subpath: String? subpath) -> void
18-
19-
def self.parse: (String string) -> PackageURL?
20-
21-
def to_h: () -> { scheme: String,
22-
type: String,
23-
namespace: String?,
24-
name: String?,
25-
version: String?,
26-
qualifiers: Hash[String, String]?,
21+
22+
def self.parse: (String string) -> PackageURL
23+
24+
def to_h: () -> { scheme: String,
25+
type: String,
26+
namespace: String?,
27+
name: String?,
28+
version: String?,
29+
qualifiers: Hash[String, String]?,
2730
subpath: String? }
2831

2932
def to_s: () -> String
3033

3134
def deconstruct: () -> Array[String | Hash[String, String] | nil]
3235

33-
def deconstruct_keys: (Array[Symbol] keys) -> { scheme: String,
34-
type: String,
35-
namespace: String?,
36-
name: String?,
37-
version: String?,
38-
qualifiers: Hash[String, String]?,
36+
def deconstruct_keys: (Array[Symbol] keys) -> { scheme: String,
37+
type: String,
38+
namespace: String?,
39+
name: String?,
40+
version: String?,
41+
qualifiers: Hash[String, String]?,
3942
subpath: String? }
4043
end

0 commit comments

Comments
 (0)