[Bug:1.9] RubyGems $B$N(B CommandManager $B$,(B singleton $B$K$J$C$F$$$J$$(B

okkez e$B$G$9!#e(B

lib/rubygems/command_manager.rb e$B$GDj5A$5$l$F$$$ke(B
Gem::CommandManager e$B%/%i%9$G$9$,!"%=!<%9%3!<%I$rFI$s$G$_$?8B$j$G$Oe(B
singleton e$B$K$7$?$+$C$?$N$8$c$J$$$+$H;W$&$N$G$9$,$$$+$,$G$7$g$&$+!)e(B

e$B85$N%3!<%I$@$He(B Gem::CommandManager.instance
e$B$GKh2s?7$7$$%$%s%9%?%s%9e(B
e$B$,@8@.$5$l$^$9!#e(B
e$B=$@5$K$"$o$;$F%F%9%H$b=$@5$7$F$_$^$7$?!#e(B

e$B$h$m$7$/$*4j$$$7$^$9!#e(B

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,

e$B%A%1%C%He(B #499 e$B$,99?7$5$l$^$7$?!#e(B (by okkez _)

e$B$3$l$J$s$G$9$,!"<h$j2<$2$5$;$F$$$?$@$-$^$9!#e(B

class A
def self.instance
@a ||= new # e$B$3$3$Ge(B @a e$B$Oe(B Class
e$B%/%i%9$N%$%s%9%?%s%9e(B A e$B$N%$%s%9%?%s%9JQ?te(B
end
end
A.instance # => #<A:0xb7ce833c>
A.instance # => #<A:0xb7ce833c>
A.instance_variables # => [“@a”]

e$B$H$$$&Iw$K$J$C$F$$$k$N$G;d$N4V0c$$$G$9$M!#e(B

e$B8B$j$J$/AH$9~$$K6a$$%i%$%V%i%jFb$GI8=`E:IU%i%$%V%i%j$r;HMQ$9$k$H$$$&$N$b6Z$,0-$9$.$^$9$7$M!#e(B

e$B$?$@!"%=!<%9%3!<%I$K%3%a%s%H$OI,MWL5$$$G$7$g$&$+!)e(B

e$B;d$N$h$&$JAF9z$b$N$,FI$_4V0c$($J$$$?$a$K!#!#!#e(B

e$B3X$Y$P3X$V$[$ICN$i$J$$$3$H$,=P$F$/$k$J$!!#e(B

e$B$h$m$7$/$*4j$$$7$^$9!#e(B


http://redmine.ruby-lang.org/issues/show/499