diff options
author | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2023-02-01 18:24:21 +0900 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2023-02-01 16:44:55 +0000 |
commit | 375f527ded72cd20374144dd605e0177945b9fae (patch) | |
tree | 93aa81f55580b2a82de57e41b03e9c25fa3a8541 | |
parent | aa222b56faa31397ad19fa06b5cfb4cdd52b3148 (diff) | |
download | ruby-375f527ded72cd20374144dd605e0177945b9fae.tar.gz |
[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
-rw-r--r-- | lib/rubygems/deprecate.rb | 4 | ||||
-rw-r--r-- | test/rubygems/test_gem_command_manager.rb | 25 |
2 files changed, 27 insertions, 2 deletions
diff --git a/lib/rubygems/deprecate.rb b/lib/rubygems/deprecate.rb index 5fe0afb6b0..56505512c3 100644 --- a/lib/rubygems/deprecate.rb +++ b/lib/rubygems/deprecate.rb @@ -143,7 +143,7 @@ module Gem::Deprecate end # Deprecation method to deprecate Rubygems commands - def rubygems_deprecate_command + def rubygems_deprecate_command(version = Gem::Deprecate.next_rubygems_major_version) class_eval do define_method "deprecated?" do true @@ -151,7 +151,7 @@ module Gem::Deprecate define_method "deprecation_warning" do 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 diff --git a/test/rubygems/test_gem_command_manager.rb b/test/rubygems/test_gem_command_manager.rb index 6b34156187..8108dc0870 100644 --- a/test/rubygems/test_gem_command_manager.rb +++ b/test/rubygems/test_gem_command_manager.rb @@ -371,4 +371,29 @@ class TestGemCommandManager < Gem::TestCase ensure Gem::Commands.send(:remove_const, :FooCommand) 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 |