summaryrefslogtreecommitdiff
path: root/lib/irb
diff options
context:
space:
mode:
authorkeiju <keiju@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-07-07 11:36:20 +0000
committerkeiju <keiju@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-07-07 11:36:20 +0000
commitc7fa0c727c8342717d2c75c1c5750a54df461eae (patch)
tree418093a0a9aedf90397204d97730cffb9b95df07 /lib/irb
parent649237de8f9e1c784493f4a8f29178ac0e969237 (diff)
* 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
Diffstat (limited to 'lib/irb')
-rw-r--r--lib/irb/cmd/chws.rb2
-rw-r--r--lib/irb/cmd/fork.rb2
-rw-r--r--lib/irb/cmd/help.rb2
-rw-r--r--lib/irb/cmd/load.rb2
-rw-r--r--lib/irb/cmd/nop.rb2
-rw-r--r--lib/irb/cmd/pushws.rb2
-rw-r--r--lib/irb/cmd/subirb.rb2
-rw-r--r--lib/irb/context.rb47
-rw-r--r--lib/irb/ext/change-ws.rb2
-rw-r--r--lib/irb/ext/history.rb2
-rw-r--r--lib/irb/ext/loader.rb2
-rw-r--r--lib/irb/ext/math-mode.rb2
-rw-r--r--lib/irb/ext/multi-irb.rb2
-rw-r--r--lib/irb/ext/save-history.rb2
-rw-r--r--lib/irb/ext/tracer.rb2
-rw-r--r--lib/irb/ext/use-loader.rb2
-rw-r--r--lib/irb/ext/workspaces.rb2
-rw-r--r--lib/irb/extend-command.rb2
-rw-r--r--lib/irb/help.rb2
-rw-r--r--lib/irb/init.rb10
-rw-r--r--lib/irb/input-method.rb2
-rw-r--r--lib/irb/lc/error.rb2
-rw-r--r--lib/irb/lc/help-message2
-rw-r--r--lib/irb/lc/ja/error.rb2
-rw-r--r--lib/irb/lc/ja/help-message2
-rw-r--r--lib/irb/locale.rb4
-rw-r--r--lib/irb/notifier.rb2
-rw-r--r--lib/irb/output-method.rb2
-rw-r--r--lib/irb/ruby-lex.rb2
-rw-r--r--lib/irb/ruby-token.rb2
-rw-r--r--lib/irb/slex.rb2
-rw-r--r--lib/irb/version.rb6
-rw-r--r--lib/irb/workspace.rb2
-rw-r--r--lib/irb/ws-for-case-2.rb2
34 files changed, 85 insertions, 42 deletions
diff --git a/lib/irb/cmd/chws.rb b/lib/irb/cmd/chws.rb
index e225b52585..65c977016b 100644
--- a/lib/irb/cmd/chws.rb
+++ b/lib/irb/cmd/chws.rb
@@ -1,6 +1,6 @@
#
# change-ws.rb -
-# $Release Version: 0.9.5$
+# $Release Version: 0.9.6$
# $Revision$
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
#
diff --git a/lib/irb/cmd/fork.rb b/lib/irb/cmd/fork.rb
index 534f13f56a..45350cb1b7 100644
--- a/lib/irb/cmd/fork.rb
+++ b/lib/irb/cmd/fork.rb
@@ -1,6 +1,6 @@
#
# fork.rb -
-# $Release Version: 0.9.5 $
+# $Release Version: 0.9.6 $
# $Revision$
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
#
diff --git a/lib/irb/cmd/help.rb b/lib/irb/cmd/help.rb
index 146acdfa81..de3c6bd6bf 100644
--- a/lib/irb/cmd/help.rb
+++ b/lib/irb/cmd/help.rb
@@ -1,6 +1,6 @@
#
# help.rb - helper using ri
-# $Release Version: 0.9.5$
+# $Release Version: 0.9.6$
# $Revision$
#
# --
diff --git a/lib/irb/cmd/load.rb b/lib/irb/cmd/load.rb
index 5988b7bbd1..2a6de21ed7 100644
--- a/lib/irb/cmd/load.rb
+++ b/lib/irb/cmd/load.rb
@@ -1,6 +1,6 @@
#
# load.rb -
-# $Release Version: 0.9.5$
+# $Release Version: 0.9.6$
# $Revision$
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
#
diff --git a/lib/irb/cmd/nop.rb b/lib/irb/cmd/nop.rb
index 873c0f43f4..2b028975c8 100644
--- a/lib/irb/cmd/nop.rb
+++ b/lib/irb/cmd/nop.rb
@@ -1,6 +1,6 @@
#
# nop.rb -
-# $Release Version: 0.9.5$
+# $Release Version: 0.9.6$
# $Revision$
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
#
diff --git a/lib/irb/cmd/pushws.rb b/lib/irb/cmd/pushws.rb
index a82939f39d..5fd567731c 100644
--- a/lib/irb/cmd/pushws.rb
+++ b/lib/irb/cmd/pushws.rb
@@ -1,6 +1,6 @@
#
# change-ws.rb -
-# $Release Version: 0.9.5$
+# $Release Version: 0.9.6$
# $Revision$
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
#
diff --git a/lib/irb/cmd/subirb.rb b/lib/irb/cmd/subirb.rb
index eea6330bf1..4d54a72b6f 100644
--- a/lib/irb/cmd/subirb.rb
+++ b/lib/irb/cmd/subirb.rb
@@ -1,5 +1,5 @@
# multi.rb -
-# $Release Version: 0.9.5$
+# $Release Version: 0.9.6$
# $Revision$
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
#
diff --git a/lib/irb/context.rb b/lib/irb/context.rb
index a3f5e5a79c..a2778f76ab 100644
--- a/lib/irb/context.rb
+++ b/lib/irb/context.rb
@@ -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)
diff --git a/lib/irb/ext/change-ws.rb b/lib/irb/ext/change-ws.rb
index 3ae1eab7a4..dea969d384 100644
--- a/lib/irb/ext/change-ws.rb
+++ b/lib/irb/ext/change-ws.rb
@@ -1,6 +1,6 @@
#
# irb/ext/cb.rb -
-# $Release Version: 0.9.5$
+# $Release Version: 0.9.6$
# $Revision$
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
#
diff --git a/lib/irb/ext/history.rb b/lib/irb/ext/history.rb
index 9142146c42..1495f9eb14 100644
--- a/lib/irb/ext/history.rb
+++ b/lib/irb/ext/history.rb
@@ -1,6 +1,6 @@
#
# history.rb -
-# $Release Version: 0.9.5$
+# $Release Version: 0.9.6$
# $Revision$
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
#
diff --git a/lib/irb/ext/loader.rb b/lib/irb/ext/loader.rb
index cee8f51cc9..26a3203676 100644
--- a/lib/irb/ext/loader.rb
+++ b/lib/irb/ext/loader.rb
@@ -1,6 +1,6 @@
#
# loader.rb -
-# $Release Version: 0.9.5$
+# $Release Version: 0.9.6$
# $Revision$
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
#
diff --git a/lib/irb/ext/math-mode.rb b/lib/irb/ext/math-mode.rb
index 370fab229d..41be79841c 100644
--- a/lib/irb/ext/math-mode.rb
+++ b/lib/irb/ext/math-mode.rb
@@ -1,6 +1,6 @@
#
# math-mode.rb -
-# $Release Version: 0.9.5$
+# $Release Version: 0.9.6$
# $Revision$
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
#
diff --git a/lib/irb/ext/multi-irb.rb b/lib/irb/ext/multi-irb.rb
index 5085a3f272..7bb1a7cfab 100644
--- a/lib/irb/ext/multi-irb.rb
+++ b/lib/irb/ext/multi-irb.rb
@@ -1,6 +1,6 @@
#
# irb/multi-irb.rb - multiple irb module
-# $Release Version: 0.9.5$
+# $Release Version: 0.9.6$
# $Revision$
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
#
diff --git a/lib/irb/ext/save-history.rb b/lib/irb/ext/save-history.rb
index 72c6b578bf..e3597c6216 100644
--- a/lib/irb/ext/save-history.rb
+++ b/lib/irb/ext/save-history.rb
@@ -1,5 +1,5 @@
# save-history.rb -
-# $Release Version: 0.9.5$
+# $Release Version: 0.9.6$
# $Revision$
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
#
diff --git a/lib/irb/ext/tracer.rb b/lib/irb/ext/tracer.rb
index 6728c46137..46a9d53a2e 100644
--- a/lib/irb/ext/tracer.rb
+++ b/lib/irb/ext/tracer.rb
@@ -1,6 +1,6 @@
#
# irb/lib/tracer.rb -
-# $Release Version: 0.9.5$
+# $Release Version: 0.9.6$
# $Revision$
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
#
diff --git a/lib/irb/ext/use-loader.rb b/lib/irb/ext/use-loader.rb
index b643dd099e..64283b8989 100644
--- a/lib/irb/ext/use-loader.rb
+++ b/lib/irb/ext/use-loader.rb
@@ -1,6 +1,6 @@
#
# use-loader.rb -
-# $Release Version: 0.9.5$
+# $Release Version: 0.9.6$
# $Revision$
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
#
diff --git a/lib/irb/ext/workspaces.rb b/lib/irb/ext/workspaces.rb
index 654b8118ea..118ea598c0 100644
--- a/lib/irb/ext/workspaces.rb
+++ b/lib/irb/ext/workspaces.rb
@@ -1,6 +1,6 @@
#
# push-ws.rb -
-# $Release Version: 0.9.5$
+# $Release Version: 0.9.6$
# $Revision$
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
#
diff --git a/lib/irb/extend-command.rb b/lib/irb/extend-command.rb
index 61a43e4a78..7bc033cee1 100644
--- a/lib/irb/extend-command.rb
+++ b/lib/irb/extend-command.rb
@@ -1,6 +1,6 @@
#
# irb/extend-command.rb - irb extend command
-# $Release Version: 0.9.5$
+# $Release Version: 0.9.6$
# $Revision$
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
#
diff --git a/lib/irb/help.rb b/lib/irb/help.rb
index cae9c8a832..4a308b6e46 100644
--- a/lib/irb/help.rb
+++ b/lib/irb/help.rb
@@ -1,6 +1,6 @@
#
# irb/help.rb - print usage module
-# $Release Version: 0.9.5$
+# $Release Version: 0.9.6$
# $Revision$
# by Keiju ISHITSUKA(keiju@ishitsuka.com)
#
diff --git a/lib/irb/init.rb b/lib/irb/init.rb
index 8f88802f5d..489850a86b 100644
--- a/lib/irb/init.rb
+++ b/lib/irb/init.rb
@@ -1,6 +1,6 @@
#
# irb/init.rb - irb initialize module
-# $Release Version: 0.9.5$
+# $Release Version: 0.9.6$
# $Revision$
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
#
@@ -44,7 +44,7 @@ module IRB
@CONF[:MATH_MODE] = false
@CONF[:USE_READLINE] = false unless defined?(ReadlineInputMethod)
- @CONF[:INSPECT_MODE] = nil
+ @CONF[:INSPECT_MODE] = true
@CONF[:USE_TRACER] = false
@CONF[:USE_LOADER] = false
@CONF[:IGNORE_SIGINT] = true
@@ -145,7 +145,11 @@ module IRB
opt = $1 || ARGV.shift
set_encoding(*opt.split(':', 2))
when "--inspect"
- @CONF[:INSPECT_MODE] = true
+ if /^-/ !~ ARGV.first
+ @CONF[:INSPECT_MODE] = ARGV.shift
+ else
+ @CONF[:INSPECT_MODE] = true
+ end
when "--noinspect"
@CONF[:INSPECT_MODE] = false
when "--readline"
diff --git a/lib/irb/input-method.rb b/lib/irb/input-method.rb
index 9c3d682c66..7227df4ca0 100644
--- a/lib/irb/input-method.rb
+++ b/lib/irb/input-method.rb
@@ -1,6 +1,6 @@
#
# irb/input-method.rb - input methods used irb
-# $Release Version: 0.9.5$
+# $Release Version: 0.9.6$
# $Revision$
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
#
diff --git a/lib/irb/lc/error.rb b/lib/irb/lc/error.rb
index ed7d0361fe..742821e3af 100644
--- a/lib/irb/lc/error.rb
+++ b/lib/irb/lc/error.rb
@@ -1,6 +1,6 @@
#
# irb/lc/error.rb -
-# $Release Version: 0.9.5$
+# $Release Version: 0.9.6$
# $Revision$
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
#
diff --git a/lib/irb/lc/help-message b/lib/irb/lc/help-message
index 9c08a5c29d..dd30b9fd24 100644
--- a/lib/irb/lc/help-message
+++ b/lib/irb/lc/help-message
@@ -1,7 +1,7 @@
# -*- coding: US-ASCII -*-
#
# irb/lc/help-message.rb -
-# $Release Version: 0.9.5$
+# $Release Version: 0.9.6$
# $Revision$
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
#
diff --git a/lib/irb/lc/ja/error.rb b/lib/irb/lc/ja/error.rb
index c73b640637..9a7670f459 100644
--- a/lib/irb/lc/ja/error.rb
+++ b/lib/irb/lc/ja/error.rb
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# irb/lc/ja/error.rb -
-# $Release Version: 0.9.5$
+# $Release Version: 0.9.6$
# $Revision$
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
#
diff --git a/lib/irb/lc/ja/help-message b/lib/irb/lc/ja/help-message
index d156039c9b..f2c4066cf6 100644
--- a/lib/irb/lc/ja/help-message
+++ b/lib/irb/lc/ja/help-message
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# irb/lc/ja/help-message.rb -
-# $Release Version: 0.9.5$
+# $Release Version: 0.9.6$
# $Revision$
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
#
diff --git a/lib/irb/locale.rb b/lib/irb/locale.rb
index 9c96d15525..9924409ba1 100644
--- a/lib/irb/locale.rb
+++ b/lib/irb/locale.rb
@@ -1,6 +1,6 @@
#
# irb/locale.rb - internationalization module
-# $Release Version: 0.9.5$
+# $Release Version: 0.9.6$
# $Revision$
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
#
@@ -141,7 +141,7 @@ module IRB
dir = File.dirname(file)
dir = "" if dir == "."
base = File.basename(file)
- if dir[0] == ?/ #/
+ if dir =~ /^\//
return lc_path = search_file(dir, base)
else
for path in $:
diff --git a/lib/irb/notifier.rb b/lib/irb/notifier.rb
index f76fc8040c..fdfcdd2dbc 100644
--- a/lib/irb/notifier.rb
+++ b/lib/irb/notifier.rb
@@ -1,6 +1,6 @@
#
# notifier.rb - output methods used by irb
-# $Release Version: 0.9.5$
+# $Release Version: 0.9.6$
# $Revision$
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
#
diff --git a/lib/irb/output-method.rb b/lib/irb/output-method.rb
index bbfc072536..4201523a45 100644
--- a/lib/irb/output-method.rb
+++ b/lib/irb/output-method.rb
@@ -1,6 +1,6 @@
#
# output-method.rb - optput methods used by irb
-# $Release Version: 0.9.5$
+# $Release Version: 0.9.6$
# $Revision$
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
#
diff --git a/lib/irb/ruby-lex.rb b/lib/irb/ruby-lex.rb
index 1def148885..b36629b38e 100644
--- a/lib/irb/ruby-lex.rb
+++ b/lib/irb/ruby-lex.rb
@@ -1,6 +1,6 @@
#
# irb/ruby-lex.rb - ruby lexcal analyzer
-# $Release Version: 0.9.5$
+# $Release Version: 0.9.6$
# $Revision$
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
#
diff --git a/lib/irb/ruby-token.rb b/lib/irb/ruby-token.rb
index 9eb3bc1739..9b06eab21b 100644
--- a/lib/irb/ruby-token.rb
+++ b/lib/irb/ruby-token.rb
@@ -1,6 +1,6 @@
#
# irb/ruby-token.rb - ruby tokens
-# $Release Version: 0.9.5$
+# $Release Version: 0.9.6$
# $Revision$
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
#
diff --git a/lib/irb/slex.rb b/lib/irb/slex.rb
index 6b3d1f37e3..fac62bfd93 100644
--- a/lib/irb/slex.rb
+++ b/lib/irb/slex.rb
@@ -1,6 +1,6 @@
#
# irb/slex.rb - simple lex analyzer
-# $Release Version: 0.9.5$
+# $Release Version: 0.9.6$
# $Revision$
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
#
diff --git a/lib/irb/version.rb b/lib/irb/version.rb
index a9ccc1ce95..621a127ebd 100644
--- a/lib/irb/version.rb
+++ b/lib/irb/version.rb
@@ -1,6 +1,6 @@
#
# irb/version.rb - irb version definition file
-# $Release Version: 0.9.5$
+# $Release Version: 0.9.6$
# $Revision$
# by Keiju ISHITSUKA(keiju@ishitsuka.com)
#
@@ -10,6 +10,6 @@
#
module IRB
- @RELEASE_VERSION = "0.9.5"
- @LAST_UPDATE_DATE = "05/04/13"
+ @RELEASE_VERSION = "0.9.6"
+ @LAST_UPDATE_DATE = "09/06/30"
end
diff --git a/lib/irb/workspace.rb b/lib/irb/workspace.rb
index 1b88914a84..991df2e652 100644
--- a/lib/irb/workspace.rb
+++ b/lib/irb/workspace.rb
@@ -1,6 +1,6 @@
#
# irb/workspace-binding.rb -
-# $Release Version: 0.9.5$
+# $Release Version: 0.9.6$
# $Revision$
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
#
diff --git a/lib/irb/ws-for-case-2.rb b/lib/irb/ws-for-case-2.rb
index d7db90c96b..bb3932ad62 100644
--- a/lib/irb/ws-for-case-2.rb
+++ b/lib/irb/ws-for-case-2.rb
@@ -1,6 +1,6 @@
#
# irb/ws-for-case-2.rb -
-# $Release Version: 0.9.5$
+# $Release Version: 0.9.6$
# $Revision$
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
#