mirror of
https://github.com/ruby/ruby.git
synced 2026-01-27 04:24:23 +00:00
[ruby/rubygems] 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. https://github.com/ruby/rubygems/commit/024b4b547a
This commit is contained in:
parent
6e2906f60d
commit
2289961b48
@ -344,9 +344,6 @@ class Gem::Version
|
||||
|
||||
def <=>(other)
|
||||
if String === other
|
||||
unless Gem::Deprecate.skip
|
||||
warn "comparing version objects with strings is deprecated and will be removed", uplevel: 1
|
||||
end
|
||||
return unless self.class.correct?(other)
|
||||
return self <=> self.class.new(other)
|
||||
end
|
||||
|
||||
@ -160,11 +160,7 @@ class TestGemVersion < Gem::TestCase
|
||||
[-1, "1.9.3.1"],
|
||||
[nil, "whatever"],
|
||||
].each do |cmp, string_ver|
|
||||
actual_stdout, actual_stderr = capture_output do
|
||||
assert_equal(cmp, v("1.9.3") <=> string_ver)
|
||||
end
|
||||
assert_empty actual_stdout
|
||||
assert_match(/comparing version objects with strings is deprecated and will be removed/, actual_stderr)
|
||||
assert_equal(cmp, v("1.9.3") <=> string_ver)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user