зеркало из https://github.com/github/ruby.git
[rubygems/rubygems] Introduce to specify deprecated version for rubygems_deprecate_command.
We sometimes to remove minor command without bumping major version. This feature helps this deprecation process. https://github.com/rubygems/rubygems/commit/41301cd2a8
This commit is contained in:
Родитель
aa222b56fa
Коммит
375f527ded
|
@ -143,7 +143,7 @@ module Gem::Deprecate
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deprecation method to deprecate Rubygems commands
|
# Deprecation method to deprecate Rubygems commands
|
||||||
def rubygems_deprecate_command
|
def rubygems_deprecate_command(version = Gem::Deprecate.next_rubygems_major_version)
|
||||||
class_eval do
|
class_eval do
|
||||||
define_method "deprecated?" do
|
define_method "deprecated?" do
|
||||||
true
|
true
|
||||||
|
@ -151,7 +151,7 @@ module Gem::Deprecate
|
||||||
|
|
||||||
define_method "deprecation_warning" do
|
define_method "deprecation_warning" do
|
||||||
msg = [ "#{self.command} command is deprecated",
|
msg = [ "#{self.command} command is deprecated",
|
||||||
". It will be removed in Rubygems #{Gem::Deprecate.next_rubygems_major_version}.\n",
|
". It will be removed in Rubygems #{version}.\n",
|
||||||
]
|
]
|
||||||
|
|
||||||
alert_warning "#{msg.join}" unless Gem::Deprecate.skip
|
alert_warning "#{msg.join}" unless Gem::Deprecate.skip
|
||||||
|
|
|
@ -371,4 +371,29 @@ class TestGemCommandManager < Gem::TestCase
|
||||||
ensure
|
ensure
|
||||||
Gem::Commands.send(:remove_const, :FooCommand)
|
Gem::Commands.send(:remove_const, :FooCommand)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_deprecated_command_with_version
|
||||||
|
require "rubygems/command"
|
||||||
|
foo_command = Class.new(Gem::Command) do
|
||||||
|
extend Gem::Deprecate
|
||||||
|
|
||||||
|
rubygems_deprecate_command("9.9.9")
|
||||||
|
|
||||||
|
def execute
|
||||||
|
say "pew pew!"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
Gem::Commands.send(:const_set, :FooCommand, foo_command)
|
||||||
|
@command_manager.register_command(:foo, foo_command.new("foo"))
|
||||||
|
|
||||||
|
use_ui @ui do
|
||||||
|
@command_manager.process_args(%w[foo])
|
||||||
|
end
|
||||||
|
|
||||||
|
assert_equal "pew pew!\n", @ui.output
|
||||||
|
assert_match(/WARNING: foo command is deprecated. It will be removed in Rubygems 9.9.9/, @ui.error)
|
||||||
|
ensure
|
||||||
|
Gem::Commands.send(:remove_const, :FooCommand)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Загрузка…
Ссылка в новой задаче