Skip to content

Commit 488aafd

Browse files
committed
Fix RuboCop style offenses in pattern matching implementation
1 parent bd4d8d2 commit 488aafd

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

lib/rubygems/version.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,11 +336,11 @@ def segments # :nodoc:
336336
_segments.dup
337337
end
338338

339-
alias deconstruct segments
339+
alias_method :deconstruct, :segments
340340

341341
def deconstruct_keys(keys)
342342
major, minor, patch = segments
343-
{major:, minor:, patch:}
343+
{ major:, minor:, patch: }
344344
end
345345

346346
##

test/rubygems/test_gem_version.rb

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ def test_deconstruct
236236

237237
def test_deconstruct_keys
238238
version = v("3.2.1")
239-
assert_equal({major: 3, minor: 2, patch: 1}, version.deconstruct_keys(nil))
239+
assert_equal({ major: 3, minor: 2, patch: 1 }, version.deconstruct_keys(nil))
240240
end
241241

242242
def test_pattern_matching_array
@@ -251,10 +251,11 @@ def test_pattern_matching_array
251251
end
252252

253253
def test_pattern_matching_hash
254-
result = case v("3.2.1")
255-
in major: 3.., minor: 2.. then "matched"
256-
else "no match"
257-
end
254+
result =
255+
case v("3.2.1")
256+
in major: 3.., minor: 2.. then "matched"
257+
else "no match"
258+
end
258259
assert_equal "matched", result
259260
end
260261

0 commit comments

Comments
 (0)