From: okkez Date: 2008-08-26T17:26:22+09:00 Subject: [ruby-dev:35979] [Bug:1.9] RubyGems の CommandManager が singleton になっていない okkez です。 lib/rubygems/command_manager.rb で定義されている Gem::CommandManager クラスですが、ソースコードを読んでみた限りでは singleton にしたかったのじゃないかと思うのですがいかがでしょうか? 元のコードだと Gem::CommandManager.instance で毎回新しいインスタンス が生成されます。 修正にあわせてテストも修正してみました。 よろしくお願いします。 Index: lib/rubygems/command_manager.rb =================================================================== --- lib/rubygems/command_manager.rb (revision 18866) +++ lib/rubygems/command_manager.rb (working copy) @@ -4,6 +4,7 @@ # See LICENSE.txt for permissions. #++ +require 'singleton' require 'timeout' require 'rubygems/command' require 'rubygems/user_interaction' @@ -15,12 +16,8 @@ # sub-commands supported by the gem command. class CommandManager include UserInteraction + include Singleton - # Return the authoritative instance of the command manager. - def self.instance - @command_manager ||= CommandManager.new - end - # Register all the subcommands supported by the gem command. def initialize @commands = {} Index: test/rubygems/test_gem_command_manager.rb =================================================================== --- test/rubygems/test_gem_command_manager.rb (revision 18866) +++ test/rubygems/test_gem_command_manager.rb (working copy) @@ -25,7 +25,7 @@ def setup super - @command_manager = Gem::CommandManager.new + @command_manager = Gem::CommandManager.instance end def test_run_interrupt Index: test/rubygems/functional.rb =================================================================== --- test/rubygems/functional.rb (revision 18866) +++ test/rubygems/functional.rb (working copy) @@ -47,7 +47,7 @@ end def test_all_command_helps - mgr = Gem::CommandManager.new + mgr = Gem::CommandManager.instance mgr.command_names.each do |cmdname| gem_nossl "help #{cmdname}" assert_match(/Usage: gem #{cmdname}/, @out, -- okkez okkez000@gmail.com