1
0
Fork 0
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:
keiju 2009-07-07 11:36:20 +00:00
parent 649237de8f
commit c7fa0c727c
37 changed files with 92 additions and 49 deletions

View file

@ -1,3 +1,7 @@
Tue Jul 7 20:23:27 2009 Keiju Ishitsuka <keiju@ruby-lang.org>
* bin/irb, lib/irb.rb lib/irb/*: irb-0.9.6, extend inspect-mode
Tue Jul 7 17:00:38 2009 Nobuyoshi Nakada <nobu@ruby-lang.org> Tue Jul 7 17:00:38 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
* gc.c (rb_gc_call_finalizer_at_exit): deal with typed struct like * gc.c (rb_gc_call_finalizer_at_exit): deal with typed struct like

View file

@ -1,7 +1,7 @@
#!/usr/bin/env ruby #!/usr/bin/env ruby
# #
# irb.rb - interactive ruby # irb.rb - interactive ruby
# $Release Version: 0.9.5 $ # $Release Version: 0.9.6 $
# $Revision$ # $Revision$
# by Keiju ISHITSUKA(keiju@ruby-lang.org) # by Keiju ISHITSUKA(keiju@ruby-lang.org)
# #

View file

@ -1,6 +1,6 @@
# #
# irb.rb - irb main module # irb.rb - irb main module
# $Release Version: 0.9.5 $ # $Release Version: 0.9.6 $
# $Revision$ # $Revision$
# by Keiju ISHITSUKA(keiju@ruby-lang.org) # by Keiju ISHITSUKA(keiju@ruby-lang.org)
# #
@ -298,11 +298,7 @@ module IRB
end end
def output_value def output_value
if @context.inspect? printf @context.return_format, @context.inspect_last_value
printf @context.return_format, @context.last_value.inspect
else
printf @context.return_format, @context.last_value
end
end end
def inspect def inspect

View file

@ -1,6 +1,6 @@
# #
# change-ws.rb - # change-ws.rb -
# $Release Version: 0.9.5$ # $Release Version: 0.9.6$
# $Revision$ # $Revision$
# by Keiju ISHITSUKA(keiju@ruby-lang.org) # by Keiju ISHITSUKA(keiju@ruby-lang.org)
# #

View file

@ -1,6 +1,6 @@
# #
# fork.rb - # fork.rb -
# $Release Version: 0.9.5 $ # $Release Version: 0.9.6 $
# $Revision$ # $Revision$
# by Keiju ISHITSUKA(keiju@ruby-lang.org) # by Keiju ISHITSUKA(keiju@ruby-lang.org)
# #

View file

@ -1,6 +1,6 @@
# #
# help.rb - helper using ri # help.rb - helper using ri
# $Release Version: 0.9.5$ # $Release Version: 0.9.6$
# $Revision$ # $Revision$
# #
# -- # --

View file

@ -1,6 +1,6 @@
# #
# load.rb - # load.rb -
# $Release Version: 0.9.5$ # $Release Version: 0.9.6$
# $Revision$ # $Revision$
# by Keiju ISHITSUKA(keiju@ruby-lang.org) # by Keiju ISHITSUKA(keiju@ruby-lang.org)
# #

View file

@ -1,6 +1,6 @@
# #
# nop.rb - # nop.rb -
# $Release Version: 0.9.5$ # $Release Version: 0.9.6$
# $Revision$ # $Revision$
# by Keiju ISHITSUKA(keiju@ruby-lang.org) # by Keiju ISHITSUKA(keiju@ruby-lang.org)
# #

View file

@ -1,6 +1,6 @@
# #
# change-ws.rb - # change-ws.rb -
# $Release Version: 0.9.5$ # $Release Version: 0.9.6$
# $Revision$ # $Revision$
# by Keiju ISHITSUKA(keiju@ruby-lang.org) # by Keiju ISHITSUKA(keiju@ruby-lang.org)
# #

View file

@ -1,5 +1,5 @@
# multi.rb - # multi.rb -
# $Release Version: 0.9.5$ # $Release Version: 0.9.6$
# $Revision$ # $Revision$
# by Keiju ISHITSUKA(keiju@ruby-lang.org) # by Keiju ISHITSUKA(keiju@ruby-lang.org)
# #

View file

@ -1,6 +1,6 @@
# #
# irb/context.rb - irb context # irb/context.rb - irb context
# $Release Version: 0.9.5$ # $Release Version: 0.9.6$
# $Revision$ # $Revision$
# by Keiju ISHITSUKA(keiju@ruby-lang.org) # by Keiju ISHITSUKA(keiju@ruby-lang.org)
# #
@ -9,6 +9,7 @@
# #
# #
require "irb/workspace" require "irb/workspace"
require "irb/inspector"
module IRB module IRB
class Context class Context
@ -34,8 +35,8 @@ module IRB
@load_modules = IRB.conf[:LOAD_MODULES] @load_modules = IRB.conf[:LOAD_MODULES]
@use_readline = IRB.conf[:USE_READLINE] @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.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_tracer = IRB.conf[:USE_TRACER] if IRB.conf[:USE_TRACER]
self.use_loader = IRB.conf[:USE_LOADER] if IRB.conf[:USE_LOADER] self.use_loader = IRB.conf[:USE_LOADER] if IRB.conf[:USE_LOADER]
@ -189,15 +190,49 @@ module IRB
end end
def inspect_mode=(opt) def inspect_mode=(opt)
if opt
if i = INSPECTORS[opt]
@inspect_mode = opt @inspect_mode = opt
@inspect_method = i
i.init
else 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 end
print "Switch to#{unless @inspect_mode; ' non';end} inspect mode.\n" if verbose? print "Switch to#{unless @inspect_mode; ' non';end} inspect mode.\n" if verbose?
@inspect_mode @inspect_mode
end end
def use_readline=(opt) def use_readline=(opt)
@use_readline = opt @use_readline = opt
print "use readline module\n" if @use_readline print "use readline module\n" if @use_readline
@ -220,6 +255,10 @@ module IRB
# @_ = @workspace.evaluate(line, irb_path, line_no) # @_ = @workspace.evaluate(line, irb_path, line_no)
end end
def inspect_last_value
@inspect_method.inspect_value(@last_value)
end
alias __exit__ exit alias __exit__ exit
def exit(ret = 0) def exit(ret = 0)
IRB.irb_exit(@irb, ret) IRB.irb_exit(@irb, ret)

View file

@ -1,6 +1,6 @@
# #
# irb/ext/cb.rb - # irb/ext/cb.rb -
# $Release Version: 0.9.5$ # $Release Version: 0.9.6$
# $Revision$ # $Revision$
# by Keiju ISHITSUKA(keiju@ruby-lang.org) # by Keiju ISHITSUKA(keiju@ruby-lang.org)
# #

View file

@ -1,6 +1,6 @@
# #
# history.rb - # history.rb -
# $Release Version: 0.9.5$ # $Release Version: 0.9.6$
# $Revision$ # $Revision$
# by Keiju ISHITSUKA(keiju@ruby-lang.org) # by Keiju ISHITSUKA(keiju@ruby-lang.org)
# #

View file

@ -1,6 +1,6 @@
# #
# loader.rb - # loader.rb -
# $Release Version: 0.9.5$ # $Release Version: 0.9.6$
# $Revision$ # $Revision$
# by Keiju ISHITSUKA(keiju@ruby-lang.org) # by Keiju ISHITSUKA(keiju@ruby-lang.org)
# #

View file

@ -1,6 +1,6 @@
# #
# math-mode.rb - # math-mode.rb -
# $Release Version: 0.9.5$ # $Release Version: 0.9.6$
# $Revision$ # $Revision$
# by Keiju ISHITSUKA(keiju@ruby-lang.org) # by Keiju ISHITSUKA(keiju@ruby-lang.org)
# #

View file

@ -1,6 +1,6 @@
# #
# irb/multi-irb.rb - multiple irb module # irb/multi-irb.rb - multiple irb module
# $Release Version: 0.9.5$ # $Release Version: 0.9.6$
# $Revision$ # $Revision$
# by Keiju ISHITSUKA(keiju@ruby-lang.org) # by Keiju ISHITSUKA(keiju@ruby-lang.org)
# #

View file

@ -1,5 +1,5 @@
# save-history.rb - # save-history.rb -
# $Release Version: 0.9.5$ # $Release Version: 0.9.6$
# $Revision$ # $Revision$
# by Keiju ISHITSUKA(keiju@ruby-lang.org) # by Keiju ISHITSUKA(keiju@ruby-lang.org)
# #

View file

@ -1,6 +1,6 @@
# #
# irb/lib/tracer.rb - # irb/lib/tracer.rb -
# $Release Version: 0.9.5$ # $Release Version: 0.9.6$
# $Revision$ # $Revision$
# by Keiju ISHITSUKA(keiju@ruby-lang.org) # by Keiju ISHITSUKA(keiju@ruby-lang.org)
# #

View file

@ -1,6 +1,6 @@
# #
# use-loader.rb - # use-loader.rb -
# $Release Version: 0.9.5$ # $Release Version: 0.9.6$
# $Revision$ # $Revision$
# by Keiju ISHITSUKA(keiju@ruby-lang.org) # by Keiju ISHITSUKA(keiju@ruby-lang.org)
# #

View file

@ -1,6 +1,6 @@
# #
# push-ws.rb - # push-ws.rb -
# $Release Version: 0.9.5$ # $Release Version: 0.9.6$
# $Revision$ # $Revision$
# by Keiju ISHITSUKA(keiju@ruby-lang.org) # by Keiju ISHITSUKA(keiju@ruby-lang.org)
# #

View file

@ -1,6 +1,6 @@
# #
# irb/extend-command.rb - irb extend command # irb/extend-command.rb - irb extend command
# $Release Version: 0.9.5$ # $Release Version: 0.9.6$
# $Revision$ # $Revision$
# by Keiju ISHITSUKA(keiju@ruby-lang.org) # by Keiju ISHITSUKA(keiju@ruby-lang.org)
# #

View file

@ -1,6 +1,6 @@
# #
# irb/help.rb - print usage module # irb/help.rb - print usage module
# $Release Version: 0.9.5$ # $Release Version: 0.9.6$
# $Revision$ # $Revision$
# by Keiju ISHITSUKA(keiju@ishitsuka.com) # by Keiju ISHITSUKA(keiju@ishitsuka.com)
# #

View file

@ -1,6 +1,6 @@
# #
# irb/init.rb - irb initialize module # irb/init.rb - irb initialize module
# $Release Version: 0.9.5$ # $Release Version: 0.9.6$
# $Revision$ # $Revision$
# by Keiju ISHITSUKA(keiju@ruby-lang.org) # by Keiju ISHITSUKA(keiju@ruby-lang.org)
# #
@ -44,7 +44,7 @@ module IRB
@CONF[:MATH_MODE] = false @CONF[:MATH_MODE] = false
@CONF[:USE_READLINE] = false unless defined?(ReadlineInputMethod) @CONF[:USE_READLINE] = false unless defined?(ReadlineInputMethod)
@CONF[:INSPECT_MODE] = nil @CONF[:INSPECT_MODE] = true
@CONF[:USE_TRACER] = false @CONF[:USE_TRACER] = false
@CONF[:USE_LOADER] = false @CONF[:USE_LOADER] = false
@CONF[:IGNORE_SIGINT] = true @CONF[:IGNORE_SIGINT] = true
@ -145,7 +145,11 @@ module IRB
opt = $1 || ARGV.shift opt = $1 || ARGV.shift
set_encoding(*opt.split(':', 2)) set_encoding(*opt.split(':', 2))
when "--inspect" when "--inspect"
@CONF[:INSPECT_MODE] = true if /^-/ !~ ARGV.first
@CONF[:INSPECT_MODE] = ARGV.shift
else
@CONF[:INSPECT_MODE] = true
end
when "--noinspect" when "--noinspect"
@CONF[:INSPECT_MODE] = false @CONF[:INSPECT_MODE] = false
when "--readline" when "--readline"

View file

@ -1,6 +1,6 @@
# #
# irb/input-method.rb - input methods used irb # irb/input-method.rb - input methods used irb
# $Release Version: 0.9.5$ # $Release Version: 0.9.6$
# $Revision$ # $Revision$
# by Keiju ISHITSUKA(keiju@ruby-lang.org) # by Keiju ISHITSUKA(keiju@ruby-lang.org)
# #

View file

@ -1,6 +1,6 @@
# #
# irb/lc/error.rb - # irb/lc/error.rb -
# $Release Version: 0.9.5$ # $Release Version: 0.9.6$
# $Revision$ # $Revision$
# by Keiju ISHITSUKA(keiju@ruby-lang.org) # by Keiju ISHITSUKA(keiju@ruby-lang.org)
# #

View file

@ -1,7 +1,7 @@
# -*- coding: US-ASCII -*- # -*- coding: US-ASCII -*-
# #
# irb/lc/help-message.rb - # irb/lc/help-message.rb -
# $Release Version: 0.9.5$ # $Release Version: 0.9.6$
# $Revision$ # $Revision$
# by Keiju ISHITSUKA(keiju@ruby-lang.org) # by Keiju ISHITSUKA(keiju@ruby-lang.org)
# #

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# irb/lc/ja/error.rb - # irb/lc/ja/error.rb -
# $Release Version: 0.9.5$ # $Release Version: 0.9.6$
# $Revision$ # $Revision$
# by Keiju ISHITSUKA(keiju@ruby-lang.org) # by Keiju ISHITSUKA(keiju@ruby-lang.org)
# #

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# irb/lc/ja/help-message.rb - # irb/lc/ja/help-message.rb -
# $Release Version: 0.9.5$ # $Release Version: 0.9.6$
# $Revision$ # $Revision$
# by Keiju ISHITSUKA(keiju@ruby-lang.org) # by Keiju ISHITSUKA(keiju@ruby-lang.org)
# #

View file

@ -1,6 +1,6 @@
# #
# irb/locale.rb - internationalization module # irb/locale.rb - internationalization module
# $Release Version: 0.9.5$ # $Release Version: 0.9.6$
# $Revision$ # $Revision$
# by Keiju ISHITSUKA(keiju@ruby-lang.org) # by Keiju ISHITSUKA(keiju@ruby-lang.org)
# #
@ -141,7 +141,7 @@ module IRB
dir = File.dirname(file) dir = File.dirname(file)
dir = "" if dir == "." dir = "" if dir == "."
base = File.basename(file) base = File.basename(file)
if dir[0] == ?/ #/ if dir =~ /^\//
return lc_path = search_file(dir, base) return lc_path = search_file(dir, base)
else else
for path in $: for path in $:

View file

@ -1,6 +1,6 @@
# #
# notifier.rb - output methods used by irb # notifier.rb - output methods used by irb
# $Release Version: 0.9.5$ # $Release Version: 0.9.6$
# $Revision$ # $Revision$
# by Keiju ISHITSUKA(keiju@ruby-lang.org) # by Keiju ISHITSUKA(keiju@ruby-lang.org)
# #

View file

@ -1,6 +1,6 @@
# #
# output-method.rb - optput methods used by irb # output-method.rb - optput methods used by irb
# $Release Version: 0.9.5$ # $Release Version: 0.9.6$
# $Revision$ # $Revision$
# by Keiju ISHITSUKA(keiju@ruby-lang.org) # by Keiju ISHITSUKA(keiju@ruby-lang.org)
# #

View file

@ -1,6 +1,6 @@
# #
# irb/ruby-lex.rb - ruby lexcal analyzer # irb/ruby-lex.rb - ruby lexcal analyzer
# $Release Version: 0.9.5$ # $Release Version: 0.9.6$
# $Revision$ # $Revision$
# by Keiju ISHITSUKA(keiju@ruby-lang.org) # by Keiju ISHITSUKA(keiju@ruby-lang.org)
# #

View file

@ -1,6 +1,6 @@
# #
# irb/ruby-token.rb - ruby tokens # irb/ruby-token.rb - ruby tokens
# $Release Version: 0.9.5$ # $Release Version: 0.9.6$
# $Revision$ # $Revision$
# by Keiju ISHITSUKA(keiju@ruby-lang.org) # by Keiju ISHITSUKA(keiju@ruby-lang.org)
# #

View file

@ -1,6 +1,6 @@
# #
# irb/slex.rb - simple lex analyzer # irb/slex.rb - simple lex analyzer
# $Release Version: 0.9.5$ # $Release Version: 0.9.6$
# $Revision$ # $Revision$
# by Keiju ISHITSUKA(keiju@ruby-lang.org) # by Keiju ISHITSUKA(keiju@ruby-lang.org)
# #

View file

@ -1,6 +1,6 @@
# #
# irb/version.rb - irb version definition file # irb/version.rb - irb version definition file
# $Release Version: 0.9.5$ # $Release Version: 0.9.6$
# $Revision$ # $Revision$
# by Keiju ISHITSUKA(keiju@ishitsuka.com) # by Keiju ISHITSUKA(keiju@ishitsuka.com)
# #
@ -10,6 +10,6 @@
# #
module IRB module IRB
@RELEASE_VERSION = "0.9.5" @RELEASE_VERSION = "0.9.6"
@LAST_UPDATE_DATE = "05/04/13" @LAST_UPDATE_DATE = "09/06/30"
end end

View file

@ -1,6 +1,6 @@
# #
# irb/workspace-binding.rb - # irb/workspace-binding.rb -
# $Release Version: 0.9.5$ # $Release Version: 0.9.6$
# $Revision$ # $Revision$
# by Keiju ISHITSUKA(keiju@ruby-lang.org) # by Keiju ISHITSUKA(keiju@ruby-lang.org)
# #

View file

@ -1,6 +1,6 @@
# #
# irb/ws-for-case-2.rb - # irb/ws-for-case-2.rb -
# $Release Version: 0.9.5$ # $Release Version: 0.9.6$
# $Revision$ # $Revision$
# by Keiju ISHITSUKA(keiju@ruby-lang.org) # by Keiju ISHITSUKA(keiju@ruby-lang.org)
# #