summaryrefslogtreecommitdiff
path: root/lib/irb/extend-command.rb
diff options
context:
space:
mode:
authorhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-08-09 01:36:49 +0000
committerhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-08-09 01:36:49 +0000
commit8e5af8b628b2a52d203e43ad5a8b18375f801cde (patch)
tree457d72a0f7ac4ea97949ec5b317b359a7d776089 /lib/irb/extend-command.rb
parent45592f4b4c7e835881538e52172932c3e20d0c4d (diff)
* lib/cmath.rb: fixed indent.
* lib/drb/ssl.rb: ditto. * lib/irb/**/*.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47112 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/irb/extend-command.rb')
-rw-r--r--lib/irb/extend-command.rb232
1 files changed, 116 insertions, 116 deletions
diff --git a/lib/irb/extend-command.rb b/lib/irb/extend-command.rb
index 487c0bbeff..c10f9e63cf 100644
--- a/lib/irb/extend-command.rb
+++ b/lib/irb/extend-command.rb
@@ -46,71 +46,71 @@ module IRB # :nodoc:
@EXTEND_COMMANDS = [
[:irb_current_working_workspace, :CurrentWorkingWorkspace, "irb/cmd/chws",
- [:irb_print_working_workspace, OVERRIDE_ALL],
- [:irb_cwws, OVERRIDE_ALL],
- [:irb_pwws, OVERRIDE_ALL],
-# [:irb_cww, OVERRIDE_ALL],
-# [:irb_pww, OVERRIDE_ALL],
- [:cwws, NO_OVERRIDE],
- [:pwws, NO_OVERRIDE],
-# [:cww, NO_OVERRIDE],
-# [:pww, NO_OVERRIDE],
- [:irb_current_working_binding, OVERRIDE_ALL],
- [:irb_print_working_binding, OVERRIDE_ALL],
- [:irb_cwb, OVERRIDE_ALL],
- [:irb_pwb, OVERRIDE_ALL],
-# [:cwb, NO_OVERRIDE],
-# [:pwb, NO_OVERRIDE]
- ],
- [:irb_change_workspace, :ChangeWorkspace, "irb/cmd/chws",
- [:irb_chws, OVERRIDE_ALL],
-# [:irb_chw, OVERRIDE_ALL],
- [:irb_cws, OVERRIDE_ALL],
-# [:irb_cw, OVERRIDE_ALL],
- [:chws, NO_OVERRIDE],
-# [:chw, NO_OVERRIDE],
- [:cws, NO_OVERRIDE],
-# [:cw, NO_OVERRIDE],
- [:irb_change_binding, OVERRIDE_ALL],
- [:irb_cb, OVERRIDE_ALL],
- [:cb, NO_OVERRIDE]],
+ [:irb_print_working_workspace, OVERRIDE_ALL],
+ [:irb_cwws, OVERRIDE_ALL],
+ [:irb_pwws, OVERRIDE_ALL],
+ # [:irb_cww, OVERRIDE_ALL],
+ # [:irb_pww, OVERRIDE_ALL],
+ [:cwws, NO_OVERRIDE],
+ [:pwws, NO_OVERRIDE],
+ # [:cww, NO_OVERRIDE],
+ # [:pww, NO_OVERRIDE],
+ [:irb_current_working_binding, OVERRIDE_ALL],
+ [:irb_print_working_binding, OVERRIDE_ALL],
+ [:irb_cwb, OVERRIDE_ALL],
+ [:irb_pwb, OVERRIDE_ALL],
+ # [:cwb, NO_OVERRIDE],
+ # [:pwb, NO_OVERRIDE]
+ ],
+ [:irb_change_workspace, :ChangeWorkspace, "irb/cmd/chws",
+ [:irb_chws, OVERRIDE_ALL],
+ # [:irb_chw, OVERRIDE_ALL],
+ [:irb_cws, OVERRIDE_ALL],
+ # [:irb_cw, OVERRIDE_ALL],
+ [:chws, NO_OVERRIDE],
+ # [:chw, NO_OVERRIDE],
+ [:cws, NO_OVERRIDE],
+ # [:cw, NO_OVERRIDE],
+ [:irb_change_binding, OVERRIDE_ALL],
+ [:irb_cb, OVERRIDE_ALL],
+ [:cb, NO_OVERRIDE]],
- [:irb_workspaces, :Workspaces, "irb/cmd/pushws",
- [:workspaces, NO_OVERRIDE],
- [:irb_bindings, OVERRIDE_ALL],
- [:bindings, NO_OVERRIDE]],
- [:irb_push_workspace, :PushWorkspace, "irb/cmd/pushws",
- [:irb_pushws, OVERRIDE_ALL],
-# [:irb_pushw, OVERRIDE_ALL],
- [:pushws, NO_OVERRIDE],
-# [:pushw, NO_OVERRIDE],
- [:irb_push_binding, OVERRIDE_ALL],
- [:irb_pushb, OVERRIDE_ALL],
- [:pushb, NO_OVERRIDE]],
- [:irb_pop_workspace, :PopWorkspace, "irb/cmd/pushws",
- [:irb_popws, OVERRIDE_ALL],
-# [:irb_popw, OVERRIDE_ALL],
- [:popws, NO_OVERRIDE],
-# [:popw, NO_OVERRIDE],
- [:irb_pop_binding, OVERRIDE_ALL],
- [:irb_popb, OVERRIDE_ALL],
- [:popb, NO_OVERRIDE]],
+ [:irb_workspaces, :Workspaces, "irb/cmd/pushws",
+ [:workspaces, NO_OVERRIDE],
+ [:irb_bindings, OVERRIDE_ALL],
+ [:bindings, NO_OVERRIDE]],
+ [:irb_push_workspace, :PushWorkspace, "irb/cmd/pushws",
+ [:irb_pushws, OVERRIDE_ALL],
+ # [:irb_pushw, OVERRIDE_ALL],
+ [:pushws, NO_OVERRIDE],
+ # [:pushw, NO_OVERRIDE],
+ [:irb_push_binding, OVERRIDE_ALL],
+ [:irb_pushb, OVERRIDE_ALL],
+ [:pushb, NO_OVERRIDE]],
+ [:irb_pop_workspace, :PopWorkspace, "irb/cmd/pushws",
+ [:irb_popws, OVERRIDE_ALL],
+ # [:irb_popw, OVERRIDE_ALL],
+ [:popws, NO_OVERRIDE],
+ # [:popw, NO_OVERRIDE],
+ [:irb_pop_binding, OVERRIDE_ALL],
+ [:irb_popb, OVERRIDE_ALL],
+ [:popb, NO_OVERRIDE]],
- [:irb_load, :Load, "irb/cmd/load"],
- [:irb_require, :Require, "irb/cmd/load"],
- [:irb_source, :Source, "irb/cmd/load",
- [:source, NO_OVERRIDE]],
+ [:irb_load, :Load, "irb/cmd/load"],
+ [:irb_require, :Require, "irb/cmd/load"],
+ [:irb_source, :Source, "irb/cmd/load",
+ [:source, NO_OVERRIDE]],
- [:irb, :IrbCommand, "irb/cmd/subirb"],
- [:irb_jobs, :Jobs, "irb/cmd/subirb",
- [:jobs, NO_OVERRIDE]],
- [:irb_fg, :Foreground, "irb/cmd/subirb",
- [:fg, NO_OVERRIDE]],
- [:irb_kill, :Kill, "irb/cmd/subirb",
- [:kill, OVERRIDE_PRIVATE_ONLY]],
+ [:irb, :IrbCommand, "irb/cmd/subirb"],
+ [:irb_jobs, :Jobs, "irb/cmd/subirb",
+ [:jobs, NO_OVERRIDE]],
+ [:irb_fg, :Foreground, "irb/cmd/subirb",
+ [:fg, NO_OVERRIDE]],
+ [:irb_kill, :Kill, "irb/cmd/subirb",
+ [:kill, OVERRIDE_PRIVATE_ONLY]],
- [:irb_help, :Help, "irb/cmd/help",
- [:help, NO_OVERRIDE]],
+ [:irb_help, :Help, "irb/cmd/help",
+ [:help, NO_OVERRIDE]],
]
@@ -131,7 +131,7 @@ module IRB # :nodoc:
# +irb_help+:: IRB@Command+line+options
def self.install_extend_commands
for args in @EXTEND_COMMANDS
- def_extend_command(*args)
+ def_extend_command(*args)
end
end
@@ -144,39 +144,39 @@ module IRB # :nodoc:
def self.def_extend_command(cmd_name, cmd_class, load_file = nil, *aliases)
case cmd_class
when Symbol
- cmd_class = cmd_class.id2name
+ cmd_class = cmd_class.id2name
when String
when Class
- cmd_class = cmd_class.name
+ cmd_class = cmd_class.name
end
if load_file
- line = __LINE__; eval %[
- def #{cmd_name}(*opts, &b)
- require "#{load_file}"
- arity = ExtendCommand::#{cmd_class}.instance_method(:execute).arity
- args = (1..(arity < 0 ? ~arity : arity)).map {|i| "arg" + i.to_s }
- args << "*opts" if arity < 0
- args << "&block"
- args = args.join(", ")
- 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
+ line = __LINE__; eval %[
+ def #{cmd_name}(*opts, &b)
+ require "#{load_file}"
+ arity = ExtendCommand::#{cmd_class}.instance_method(:execute).arity
+ args = (1..(arity < 0 ? ~arity : arity)).map {|i| "arg" + i.to_s }
+ args << "*opts" if arity < 0
+ args << "&block"
+ args = args.join(", ")
+ 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
- line = __LINE__; eval %[
- def #{cmd_name}(*opts, &b)
- ExtendCommand::#{cmd_class}.execute(irb_context, *opts, &b)
- end
- ], nil, __FILE__, line
+ 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
- @ALIASES.push [ali, cmd_name, flag]
+ @ALIASES.push [ali, cmd_name, flag]
end
end
@@ -187,18 +187,18 @@ module IRB # :nodoc:
from = from.id2name unless from.kind_of?(String)
if override == OVERRIDE_ALL or
- (override == OVERRIDE_PRIVATE_ONLY) && !respond_to?(to) or
- (override == NO_OVERRIDE) && !respond_to?(to, true)
- target = self
- (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)
- end
- alias_method to, from
- }
+ (override == OVERRIDE_PRIVATE_ONLY) && !respond_to?(to) or
+ (override == NO_OVERRIDE) && !respond_to?(to, true)
+ target = self
+ (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)
+ end
+ alias_method to, from
+ }
else
- print "irb: warn: can't alias #{to} from #{from}.\n"
+ print "irb: warn: can't alias #{to} from #{from}.\n"
end
end
@@ -210,10 +210,10 @@ module IRB # :nodoc:
# using #install_alias_method.
def self.extend_object(obj)
unless (class << obj; ancestors; end).include?(EXCB)
- super
- for ali, com, flg in @ALIASES
- obj.install_alias_method(ali, com, flg)
- end
+ super
+ for ali, com, flg in @ALIASES
+ obj.install_alias_method(ali, com, flg)
+ end
end
end
@@ -241,7 +241,7 @@ module IRB # :nodoc:
# Context#save_history=:: +irb/ext/save-history.rb+
def self.install_extend_commands
for args in @EXTEND_COMMANDS
- def_extend_command(*args)
+ def_extend_command(*args)
end
end
@@ -252,13 +252,13 @@ module IRB # :nodoc:
def self.def_extend_command(cmd_name, load_file, *aliases)
line = __LINE__; Context.module_eval %[
def #{cmd_name}(*opts, &b)
- Context.module_eval {remove_method(:#{cmd_name})}
- require "#{load_file}"
- send :#{cmd_name}, *opts, &b
- end
- for ali in aliases
- alias_method ali, cmd_name
- end
+ Context.module_eval {remove_method(:#{cmd_name})}
+ require "#{load_file}"
+ send :#{cmd_name}, *opts, &b
+ end
+ for ali in aliases
+ alias_method ali, cmd_name
+ end
], __FILE__, line
end
@@ -277,9 +277,9 @@ module IRB # :nodoc:
module_eval %[
alias_method alias_name, base_method
def #{base_method}(*opts)
- send :#{extend_method}, *opts
- send :#{alias_name}, *opts
- end
+ send :#{extend_method}, *opts
+ send :#{alias_name}, *opts
+ end
]
end
@@ -293,9 +293,9 @@ module IRB # :nodoc:
module_eval %[
alias_method alias_name, base_method
def #{base_method}(*opts)
- send :#{alias_name}, *opts
- send :#{extend_method}, *opts
- end
+ send :#{alias_name}, *opts
+ send :#{extend_method}, *opts
+ end
]
end
@@ -313,7 +313,7 @@ module IRB # :nodoc:
return base_name if same_methods.empty?
no = same_methods.size
while !same_methods.include?(alias_name = base_name + no)
- no += 1
+ no += 1
end
alias_name
end