mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* bin/irb, lib/irb.rb lib/irb/*: irb-0.9.6, extend inspect-mode
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23985 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
649237de8f
commit
c7fa0c727c
37 changed files with 92 additions and 49 deletions
|
@ -1,6 +1,6 @@
|
|||
#
|
||||
# irb/context.rb - irb context
|
||||
# $Release Version: 0.9.5$
|
||||
# $Release Version: 0.9.6$
|
||||
# $Revision$
|
||||
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
|
||||
#
|
||||
|
@ -9,6 +9,7 @@
|
|||
#
|
||||
#
|
||||
require "irb/workspace"
|
||||
require "irb/inspector"
|
||||
|
||||
module IRB
|
||||
class Context
|
||||
|
@ -34,8 +35,8 @@ module IRB
|
|||
@load_modules = IRB.conf[:LOAD_MODULES]
|
||||
|
||||
@use_readline = IRB.conf[:USE_READLINE]
|
||||
@inspect_mode = IRB.conf[:INSPECT_MODE]
|
||||
|
||||
self.inspect_mode = IRB.conf[:INSPECT_MODE]
|
||||
self.math_mode = IRB.conf[:MATH_MODE] if IRB.conf[:MATH_MODE]
|
||||
self.use_tracer = IRB.conf[:USE_TRACER] if IRB.conf[:USE_TRACER]
|
||||
self.use_loader = IRB.conf[:USE_LOADER] if IRB.conf[:USE_LOADER]
|
||||
|
@ -189,15 +190,49 @@ module IRB
|
|||
end
|
||||
|
||||
def inspect_mode=(opt)
|
||||
if opt
|
||||
|
||||
if i = INSPECTORS[opt]
|
||||
@inspect_mode = opt
|
||||
@inspect_method = i
|
||||
i.init
|
||||
else
|
||||
@inspect_mode = !@inspect_mode
|
||||
case opt
|
||||
when nil
|
||||
if INSPECTORS.keys_with_inspector(INSPECTORS[true]).include?(@inspect_mode)
|
||||
self.inspect_mode = false
|
||||
elsif INSPECTORS.keys_with_inspector(INSPECTORS[false]).include?(@inspect_mode)
|
||||
self.inspect_mode = true
|
||||
else
|
||||
puts "Can't switch inspect mode."
|
||||
return
|
||||
end
|
||||
when /^\s*\{.*\}\s*$/
|
||||
begin
|
||||
inspector = eval "proc#{opt}"
|
||||
rescue Exception
|
||||
puts "Can't switch inspect mode(#{opt})."
|
||||
return
|
||||
end
|
||||
self.inspect_mode = inspector
|
||||
when Proc
|
||||
self.inspect_mode = IRB::Inspector(opt)
|
||||
when Inspector
|
||||
prefix = "usr%d"
|
||||
i = 1
|
||||
while INSPECTORS[format(prefix, i)]; i += 1; end
|
||||
@inspect_mode = format(prefix, i)
|
||||
@inspect_method = opt
|
||||
INSPECTORS.def_inspector(format(prefix, i), @inspect_method)
|
||||
else
|
||||
puts "Can't switch inspect mode(#{opt})."
|
||||
return
|
||||
end
|
||||
end
|
||||
print "Switch to#{unless @inspect_mode; ' non';end} inspect mode.\n" if verbose?
|
||||
@inspect_mode
|
||||
end
|
||||
|
||||
|
||||
def use_readline=(opt)
|
||||
@use_readline = opt
|
||||
print "use readline module\n" if @use_readline
|
||||
|
@ -220,6 +255,10 @@ module IRB
|
|||
# @_ = @workspace.evaluate(line, irb_path, line_no)
|
||||
end
|
||||
|
||||
def inspect_last_value
|
||||
@inspect_method.inspect_value(@last_value)
|
||||
end
|
||||
|
||||
alias __exit__ exit
|
||||
def exit(ret = 0)
|
||||
IRB.irb_exit(@irb, ret)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue