ruby-changes:7318
From: mame <ko1@a...>
Date: Mon, 25 Aug 2008 22:42:43 +0900 (JST)
Subject: [ruby-changes:7318] Ruby:r18837 (trunk): * lib/irb/extend-command.rb (def_extend_command): check number of
mame 2008-08-25 22:41:11 +0900 (Mon, 25 Aug 2008) New Revision: 18837 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=18837 Log: * lib/irb/extend-command.rb (def_extend_command): check number of arguments. [ruby-dev:35074] * lib/irb/ext/multi-irb.rb (search): check if a corresponding job is found. [ruby-dev:35074] Modified files: trunk/ChangeLog trunk/lib/irb/ext/multi-irb.rb trunk/lib/irb/extend-command.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 18836) +++ ChangeLog (revision 18837) @@ -1,3 +1,11 @@ +Mon Aug 25 22:39:57 2008 Yusuke Endoh <mame@t...> + + * lib/irb/extend-command.rb (def_extend_command): check number of + arguments. [ruby-dev:35074] + + * lib/irb/ext/multi-irb.rb (search): check if a corresponding job is + found. [ruby-dev:35074] + Mon Aug 25 22:29:13 2008 Yusuke Endoh <mame@t...> * test/ruby/test_io.rb (test_dup): fix typo. see [ruby-dev:35958] Index: lib/irb/ext/multi-irb.rb =================================================================== --- lib/irb/ext/multi-irb.rb (revision 18836) +++ lib/irb/ext/multi-irb.rb (revision 18837) @@ -69,7 +69,7 @@ end def search(key) - case key + job = case key when Integer @jobs[key] when Irb @@ -77,10 +77,10 @@ when Thread @jobs.assoc(key) else - assoc = @jobs.find{|k, v| v.context.main.equal?(key)} - IRB.fail NoSuchJob, key if assoc.nil? - assoc + @jobs.find{|k, v| v.context.main.equal?(key)} end + IRB.fail NoSuchJob, key if job.nil? + job end def delete(key) Index: lib/irb/extend-command.rb =================================================================== --- lib/irb/extend-command.rb (revision 18836) +++ lib/irb/extend-command.rb (revision 18837) @@ -125,9 +125,14 @@ eval %[ def #{cmd_name}(*opts, &b) require "#{load_file}" + arity = ExtendCommand::#{cmd_class}.instance_method(:execute).arity + args = (1..arity.abs).map {|i| "arg" + i.to_s } + args << "*opts" if arity < 0 + args << "&block" + args = args.join(", ") eval %[ - def #{cmd_name}(*opts, &b) - ExtendCommand::#{cmd_class}.execute(irb_context, *opts, &b) + def #{cmd_name}(\#{args}) + ExtendCommand::#{cmd_class}.execute(irb_context, \#{args}) end ] send :#{cmd_name}, *opts, &b -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/