diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-12-05 01:18:28 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-12-05 01:18:28 +0000 |
commit | b271ca8c62f7f8a81c9b1d05dbf710b9ca0828a4 (patch) | |
tree | f2673e5c52caf2e254267345a8fb4a3ddf790a22 /lib/irb | |
parent | 8237d170eec6daedbf8651bc44709612369cee6e (diff) | |
download | ruby-b271ca8c62f7f8a81c9b1d05dbf710b9ca0828a4.tar.gz |
* lib/irb/extend-command.rb (def_extend_command): fixed argument
number for negative arity.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25998 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/irb')
-rw-r--r-- | lib/irb/extend-command.rb | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/lib/irb/extend-command.rb b/lib/irb/extend-command.rb index 7bc033cee1..190c49ae78 100644 --- a/lib/irb/extend-command.rb +++ b/lib/irb/extend-command.rb @@ -122,28 +122,28 @@ module IRB end if load_file - eval %[ + line = __LINE__; 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 = (1..(arity < 0 ? ~arity : arity)).map {|i| "arg" + i.to_s } args << "*opts" if arity < 0 args << "&block" args = args.join(", ") - eval %[ + line = __LINE__; eval %[ def #{cmd_name}(\#{args}) ExtendCommand::#{cmd_class}.execute(irb_context, \#{args}) end - ] + ], nil, __FILE__, line send :#{cmd_name}, *opts, &b end - ] + ], nil, __FILE__, line else - eval %[ + line = __LINE__; eval %[ def #{cmd_name}(*opts, &b) ExtendCommand::#{cmd_class}.execute(irb_context, *opts, &b) end - ] + ], nil, __FILE__, line end for ali, flag in aliases @@ -160,7 +160,7 @@ module IRB (override == OVERRIDE_PRIVATE_ONLY) && !respond_to?(to) or (override == NO_OVERRIDE) && !respond_to?(to, true) target = self - (class<<self;self;end).instance_eval{ + (class << self; self; end).instance_eval{ if target.respond_to?(to, true) && !target.respond_to?(EXCB.irb_original_method_name(to), true) alias_method(EXCB.irb_original_method_name(to), to) @@ -177,7 +177,7 @@ module IRB end def self.extend_object(obj) - unless (class<<obj;ancestors;end).include?(EXCB) + unless (class << obj; ancestors; end).include?(EXCB) super for ali, com, flg in @ALIASES obj.install_alias_method(ali, com, flg) @@ -207,7 +207,7 @@ module IRB end def self.def_extend_command(cmd_name, load_file, *aliases) - Context.module_eval %[ + line = __LINE__; Context.module_eval %[ def #{cmd_name}(*opts, &b) Context.module_eval {remove_method(:#{cmd_name})} require "#{load_file}" @@ -216,7 +216,7 @@ module IRB for ali in aliases alias_method ali, cmd_name end - ] + ], __FILE__, line end CE.install_extend_commands |