Skip to content

Commit 024b4b5

Browse files
committed
Undeprecate Gem::Version#<=> against strings
This pattern is extremely common across the ecosystem, I don't think it's reasonable to deprecate it. I understand the performance argument, but perhaps the dependency resolution algorithm can use another method that is private API and only works with two `Version` instance.
1 parent 81bc4f6 commit 024b4b5

File tree

2 files changed

+1
-8
lines changed

2 files changed

+1
-8
lines changed

lib/rubygems/version.rb

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -344,9 +344,6 @@ def approximate_recommendation
344344

345345
def <=>(other)
346346
if String === other
347-
unless Gem::Deprecate.skip
348-
warn "comparing version objects with strings is deprecated and will be removed", uplevel: 1
349-
end
350347
return unless self.class.correct?(other)
351348
return self <=> self.class.new(other)
352349
end

test/rubygems/test_gem_version.rb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,11 +160,7 @@ def test_spaceship
160160
[-1, "1.9.3.1"],
161161
[nil, "whatever"],
162162
].each do |cmp, string_ver|
163-
actual_stdout, actual_stderr = capture_output do
164-
assert_equal(cmp, v("1.9.3") <=> string_ver)
165-
end
166-
assert_empty actual_stdout
167-
assert_match(/comparing version objects with strings is deprecated and will be removed/, actual_stderr)
163+
assert_equal(cmp, v("1.9.3") <=> string_ver)
168164
end
169165
end
170166

0 commit comments

Comments
 (0)