irb 0.9.6 → 1.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.document +4 -0
- data/Gemfile +10 -2
- data/LICENSE.txt +3 -3
- data/README.md +3 -3
- data/Rakefile +17 -1
- data/doc/irb/irb-tools.rd.ja +184 -0
- data/doc/irb/irb.rd.ja +427 -0
- data/irb.gemspec +18 -4
- data/lib/irb/cmd/fork.rb +2 -4
- data/lib/irb/cmd/help.rb +10 -5
- data/lib/irb/cmd/info.rb +32 -0
- data/lib/irb/cmd/ls.rb +101 -0
- data/lib/irb/cmd/measure.rb +43 -0
- data/lib/irb/cmd/nop.rb +10 -4
- data/lib/irb/cmd/pushws.rb +0 -1
- data/lib/irb/cmd/show_source.rb +93 -0
- data/lib/irb/cmd/whereami.rb +20 -0
- data/lib/irb/color.rb +246 -0
- data/lib/irb/color_printer.rb +47 -0
- data/lib/irb/completion.rb +254 -55
- data/lib/irb/context.rb +165 -72
- data/lib/irb/easter-egg.rb +138 -0
- data/lib/irb/ext/change-ws.rb +0 -1
- data/lib/irb/ext/history.rb +47 -11
- data/lib/irb/ext/loader.rb +46 -20
- data/lib/irb/ext/multi-irb.rb +7 -7
- data/lib/irb/ext/save-history.rb +36 -11
- data/lib/irb/ext/tracer.rb +14 -2
- data/lib/irb/ext/use-loader.rb +4 -3
- data/lib/irb/ext/workspaces.rb +0 -1
- data/lib/irb/extend-command.rb +113 -63
- data/lib/irb/frame.rb +12 -7
- data/lib/irb/help.rb +0 -1
- data/lib/irb/init.rb +146 -26
- data/lib/irb/input-method.rb +287 -9
- data/lib/irb/inspector.rb +15 -11
- data/lib/irb/lc/error.rb +55 -16
- data/lib/irb/lc/help-message +25 -13
- data/lib/irb/lc/ja/error.rb +55 -14
- data/lib/irb/lc/ja/help-message +11 -6
- data/lib/irb/locale.rb +13 -4
- data/lib/irb/notifier.rb +12 -8
- data/lib/irb/output-method.rb +6 -6
- data/lib/irb/ruby-lex.rb +673 -992
- data/lib/irb/ruby_logo.aa +37 -0
- data/lib/irb/version.rb +2 -2
- data/lib/irb/workspace.rb +65 -21
- data/lib/irb/xmp.rb +1 -1
- data/lib/irb.rb +276 -96
- data/man/irb.1 +229 -0
- metadata +25 -31
- data/.gitignore +0 -9
- data/.travis.yml +0 -6
- data/lib/irb/lc/.document +0 -4
- data/lib/irb/ruby-token.rb +0 -267
- data/lib/irb/slex.rb +0 -282
data/lib/irb/lc/error.rb
CHANGED
@@ -9,24 +9,63 @@
|
|
9
9
|
#
|
10
10
|
#
|
11
11
|
#
|
12
|
-
require "e2mmap"
|
13
12
|
|
14
13
|
# :stopdoc:
|
15
14
|
module IRB
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
15
|
+
class UnrecognizedSwitch < StandardError
|
16
|
+
def initialize(val)
|
17
|
+
super("Unrecognized switch: #{val}")
|
18
|
+
end
|
19
|
+
end
|
20
|
+
class NotImplementedError < StandardError
|
21
|
+
def initialize(val)
|
22
|
+
super("Need to define `#{val}'")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
class CantReturnToNormalMode < StandardError
|
26
|
+
def initialize
|
27
|
+
super("Can't return to normal mode.")
|
28
|
+
end
|
29
|
+
end
|
30
|
+
class IllegalParameter < StandardError
|
31
|
+
def initialize(val)
|
32
|
+
super("Invalid parameter(#{val}).")
|
33
|
+
end
|
34
|
+
end
|
35
|
+
class IrbAlreadyDead < StandardError
|
36
|
+
def initialize
|
37
|
+
super("Irb is already dead.")
|
38
|
+
end
|
39
|
+
end
|
40
|
+
class IrbSwitchedToCurrentThread < StandardError
|
41
|
+
def initialize
|
42
|
+
super("Switched to current thread.")
|
43
|
+
end
|
44
|
+
end
|
45
|
+
class NoSuchJob < StandardError
|
46
|
+
def initialize(val)
|
47
|
+
super("No such job(#{val}).")
|
48
|
+
end
|
49
|
+
end
|
50
|
+
class CantShiftToMultiIrbMode < StandardError
|
51
|
+
def initialize
|
52
|
+
super("Can't shift to multi irb mode.")
|
53
|
+
end
|
54
|
+
end
|
55
|
+
class CantChangeBinding < StandardError
|
56
|
+
def initialize(val)
|
57
|
+
super("Can't change binding to (#{val}).")
|
58
|
+
end
|
59
|
+
end
|
60
|
+
class UndefinedPromptMode < StandardError
|
61
|
+
def initialize(val)
|
62
|
+
super("Undefined prompt mode(#{val}).")
|
63
|
+
end
|
64
|
+
end
|
65
|
+
class IllegalRCGenerator < StandardError
|
66
|
+
def initialize
|
67
|
+
super("Define illegal RC_NAME_GENERATOR.")
|
68
|
+
end
|
69
|
+
end
|
31
70
|
end
|
32
71
|
# :startdoc:
|
data/lib/irb/lc/help-message
CHANGED
@@ -10,7 +10,7 @@
|
|
10
10
|
#
|
11
11
|
#
|
12
12
|
Usage: irb.rb [options] [programfile] [arguments]
|
13
|
-
-f
|
13
|
+
-f Suppress read of ~/.irbrc
|
14
14
|
-d Set $DEBUG to true (same as `ruby -d')
|
15
15
|
-r load-module Same as `ruby -r'
|
16
16
|
-I path Specify $LOAD_PATH directory
|
@@ -18,28 +18,40 @@ Usage: irb.rb [options] [programfile] [arguments]
|
|
18
18
|
-E enc Same as `ruby -E`
|
19
19
|
-w Same as `ruby -w`
|
20
20
|
-W[level=2] Same as `ruby -W`
|
21
|
-
--context-mode n Set n[0-
|
21
|
+
--context-mode n Set n[0-4] to method to create Binding Object,
|
22
22
|
when new workspace was created
|
23
|
-
--
|
23
|
+
--extra-doc-dir Add an extra doc dir for the doc dialog
|
24
|
+
--echo Show result (default)
|
24
25
|
--noecho Don't show result
|
25
|
-
--
|
26
|
-
|
27
|
-
--
|
28
|
-
|
26
|
+
--echo-on-assignment
|
27
|
+
Show result on assignment
|
28
|
+
--noecho-on-assignment
|
29
|
+
Don't show result on assignment
|
30
|
+
--truncate-echo-on-assignment
|
31
|
+
Show truncated result on assignment (default)
|
32
|
+
--inspect Use `inspect' for output
|
33
|
+
--noinspect Don't use inspect for output
|
34
|
+
--multiline Use multiline editor module
|
35
|
+
--nomultiline Don't use multiline editor module
|
36
|
+
--singleline Use singleline editor module
|
37
|
+
--nosingleline Don't use singleline editor module
|
38
|
+
--colorize Use colorization
|
39
|
+
--nocolorize Don't use colorization
|
40
|
+
--autocomplete Use autocompletion
|
41
|
+
--noautocomplete Don't use autocompletion
|
29
42
|
--prompt prompt-mode/--prompt-mode prompt-mode
|
30
|
-
|
31
|
-
|
43
|
+
Switch prompt mode. Pre-defined prompt modes are
|
44
|
+
`default', `simple', `xmp' and `inf-ruby'
|
32
45
|
--inf-ruby-mode Use prompt appropriate for inf-ruby-mode on emacs.
|
33
|
-
|
46
|
+
Suppresses --multiline and --singleline.
|
34
47
|
--sample-book-mode/--simple-prompt
|
35
48
|
Simple prompt mode
|
36
49
|
--noprompt No prompt mode
|
37
50
|
--single-irb Share self with sub-irb.
|
38
51
|
--tracer Display trace for each execution of commands.
|
39
52
|
--back-trace-limit n
|
40
|
-
|
41
|
-
|
42
|
-
--irb_debug n Set internal debug level to n (not for popular use)
|
53
|
+
Display backtrace top n and tail n. The default
|
54
|
+
value is 16.
|
43
55
|
--verbose Show details
|
44
56
|
--noverbose Don't show details
|
45
57
|
-v, --version Print the version of irb
|
data/lib/irb/lc/ja/error.rb
CHANGED
@@ -9,23 +9,64 @@
|
|
9
9
|
#
|
10
10
|
#
|
11
11
|
#
|
12
|
-
require "e2mmap"
|
13
12
|
|
14
13
|
# :stopdoc:
|
15
14
|
module IRB
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
15
|
+
class UnrecognizedSwitch < StandardError
|
16
|
+
def initialize(val)
|
17
|
+
super("スイッチ(#{val})が分りません")
|
18
|
+
end
|
19
|
+
end
|
20
|
+
class NotImplementedError < StandardError
|
21
|
+
def initialize(val)
|
22
|
+
super("`#{val}'の定義が必要です")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
class CantReturnToNormalMode < StandardError
|
26
|
+
def initialize
|
27
|
+
super("Normalモードに戻れません.")
|
28
|
+
end
|
29
|
+
end
|
30
|
+
class IllegalParameter < StandardError
|
31
|
+
def initialize(val)
|
32
|
+
super("パラメータ(#{val})が間違っています.")
|
33
|
+
end
|
34
|
+
end
|
35
|
+
class IrbAlreadyDead < StandardError
|
36
|
+
def initialize
|
37
|
+
super("Irbは既に死んでいます.")
|
38
|
+
end
|
39
|
+
end
|
40
|
+
class IrbSwitchedToCurrentThread < StandardError
|
41
|
+
def initialize
|
42
|
+
super("カレントスレッドに切り替わりました.")
|
43
|
+
end
|
44
|
+
end
|
45
|
+
class NoSuchJob < StandardError
|
46
|
+
def initialize(val)
|
47
|
+
super("そのようなジョブ(#{val})はありません.")
|
48
|
+
end
|
49
|
+
end
|
50
|
+
class CantShiftToMultiIrbMode < StandardError
|
51
|
+
def initialize
|
52
|
+
super("multi-irb modeに移れません.")
|
53
|
+
end
|
54
|
+
end
|
55
|
+
class CantChangeBinding < StandardError
|
56
|
+
def initialize(val)
|
57
|
+
super("バインディング(#{val})に変更できません.")
|
58
|
+
end
|
59
|
+
end
|
60
|
+
class UndefinedPromptMode < StandardError
|
61
|
+
def initialize(val)
|
62
|
+
super("プロンプトモード(#{val})は定義されていません.")
|
63
|
+
end
|
64
|
+
end
|
65
|
+
class IllegalRCGenerator < StandardError
|
66
|
+
def initialize
|
67
|
+
super("RC_NAME_GENERATORが正しく定義されていません.")
|
68
|
+
end
|
69
|
+
end
|
29
70
|
end
|
30
71
|
# :startdoc:
|
31
72
|
# vim:fileencoding=utf-8
|
data/lib/irb/lc/ja/help-message
CHANGED
@@ -21,16 +21,23 @@ Usage: irb.rb [options] [programfile] [arguments]
|
|
21
21
|
オブジェクトの作成方法を 0 から 3 のいずれかに設定する.
|
22
22
|
--echo 実行結果を表示する(デフォルト).
|
23
23
|
--noecho 実行結果を表示しない.
|
24
|
-
--inspect 結果出力にinspect
|
24
|
+
--inspect 結果出力にinspectを用いる.
|
25
25
|
--noinspect 結果出力にinspectを用いない.
|
26
|
-
--
|
27
|
-
--
|
26
|
+
--multiline マルチラインエディタを利用する.
|
27
|
+
--nomultiline マルチラインエディタを利用しない.
|
28
|
+
--singleline シングルラインエディタを利用する.
|
29
|
+
--nosingleline シングルラインエディタを利用しない.
|
30
|
+
--colorize 色付けを利用する.
|
31
|
+
--nocolorize 色付けを利用しない.
|
32
|
+
--autocomplete オートコンプリートを利用する.
|
33
|
+
--noautocomplete オートコンプリートを利用しない.
|
28
34
|
--prompt prompt-mode/--prompt-mode prompt-mode
|
29
35
|
プロンプトモードを切替えます. 現在定義されているプ
|
30
36
|
ロンプトモードは, default, simple, xmp, inf-rubyが
|
31
37
|
用意されています.
|
32
38
|
--inf-ruby-mode emacsのinf-ruby-mode用のプロンプト表示を行なう. 特
|
33
|
-
|
39
|
+
に指定がない限り, シングルラインエディタとマルチラ
|
40
|
+
インエディタは使わなくなる.
|
34
41
|
--sample-book-mode/--simple-prompt
|
35
42
|
非常にシンプルなプロンプトを用いるモードです.
|
36
43
|
--noprompt プロンプト表示を行なわない.
|
@@ -41,8 +48,6 @@ Usage: irb.rb [options] [programfile] [arguments]
|
|
41
48
|
バックトレース表示をバックトレースの頭から n, 後ろ
|
42
49
|
からnだけ行なう. デフォルトは16
|
43
50
|
|
44
|
-
--irb_debug n irbのデバッグレベルをnに設定する(非推奨).
|
45
|
-
|
46
51
|
--verbose 詳細なメッセージを出力する.
|
47
52
|
--noverbose 詳細なメッセージを出力しない(デフォルト).
|
48
53
|
-v, --version irbのバージョンを表示する.
|
data/lib/irb/locale.rb
CHANGED
@@ -21,8 +21,10 @@ module IRB # :nodoc:
|
|
21
21
|
LOCALE_DIR = "/lc/"
|
22
22
|
|
23
23
|
@@legacy_encoding_alias_map = {}.freeze
|
24
|
+
@@loaded = []
|
24
25
|
|
25
26
|
def initialize(locale = nil)
|
27
|
+
@override_encoding = nil
|
26
28
|
@lang = @territory = @encoding_name = @modifier = nil
|
27
29
|
@locale = locale || ENV["IRB_LANG"] || ENV["LC_MESSAGES"] || ENV["LC_ALL"] || ENV["LANG"] || "C"
|
28
30
|
if m = LOCALE_NAME_RE.match(@locale)
|
@@ -39,12 +41,16 @@ module IRB # :nodoc:
|
|
39
41
|
@encoding ||= (Encoding.find('locale') rescue Encoding::ASCII_8BIT)
|
40
42
|
end
|
41
43
|
|
42
|
-
attr_reader :lang, :territory, :
|
44
|
+
attr_reader :lang, :territory, :modifier
|
45
|
+
|
46
|
+
def encoding
|
47
|
+
@override_encoding || @encoding
|
48
|
+
end
|
43
49
|
|
44
50
|
def String(mes)
|
45
51
|
mes = super(mes)
|
46
|
-
if
|
47
|
-
mes.encode(
|
52
|
+
if encoding
|
53
|
+
mes.encode(encoding, undef: :replace)
|
48
54
|
else
|
49
55
|
mes
|
50
56
|
end
|
@@ -107,7 +113,10 @@ module IRB # :nodoc:
|
|
107
113
|
def load(file, priv=nil)
|
108
114
|
found = find(file)
|
109
115
|
if found
|
110
|
-
|
116
|
+
unless @@loaded.include?(found)
|
117
|
+
@@loaded << found # cache
|
118
|
+
return real_load(found, priv)
|
119
|
+
end
|
111
120
|
else
|
112
121
|
raise LoadError, "No such file to load -- #{file}"
|
113
122
|
end
|
data/lib/irb/notifier.rb
CHANGED
@@ -10,17 +10,21 @@
|
|
10
10
|
#
|
11
11
|
#
|
12
12
|
|
13
|
-
require "e2mmap"
|
14
13
|
require_relative "output-method"
|
15
14
|
|
16
15
|
module IRB
|
17
16
|
# An output formatter used internally by the lexer.
|
18
17
|
module Notifier
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
18
|
+
class ErrUndefinedNotifier < StandardError
|
19
|
+
def initialize(val)
|
20
|
+
super("undefined notifier level: #{val} is specified")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
class ErrUnrecognizedLevel < StandardError
|
24
|
+
def initialize(val)
|
25
|
+
super("unrecognized notifier level: #{val} is specified")
|
26
|
+
end
|
27
|
+
end
|
24
28
|
|
25
29
|
# Define a new Notifier output source, returning a new CompositeNotifier
|
26
30
|
# with the given +prefix+ and +output_method+.
|
@@ -162,10 +166,10 @@ module IRB
|
|
162
166
|
@level_notifier = value
|
163
167
|
when Integer
|
164
168
|
l = @notifiers[value]
|
165
|
-
|
169
|
+
raise ErrUndefinedNotifier, value unless l
|
166
170
|
@level_notifier = l
|
167
171
|
else
|
168
|
-
|
172
|
+
raise ErrUnrecognizedLevel, value unless l
|
169
173
|
end
|
170
174
|
end
|
171
175
|
|
data/lib/irb/output-method.rb
CHANGED
@@ -10,21 +10,21 @@
|
|
10
10
|
#
|
11
11
|
#
|
12
12
|
|
13
|
-
require "e2mmap"
|
14
|
-
|
15
13
|
module IRB
|
16
14
|
# An abstract output class for IO in irb. This is mainly used internally by
|
17
15
|
# IRB::Notifier. You can define your own output method to use with Irb.new,
|
18
16
|
# or Context.new
|
19
17
|
class OutputMethod
|
20
|
-
|
21
|
-
|
22
|
-
|
18
|
+
class NotImplementedError < StandardError
|
19
|
+
def initialize(val)
|
20
|
+
super("Need to define `#{val}'")
|
21
|
+
end
|
22
|
+
end
|
23
23
|
|
24
24
|
# Open this method to implement your own output method, raises a
|
25
25
|
# NotImplementedError if you don't define #print in your own class.
|
26
26
|
def print(*opts)
|
27
|
-
|
27
|
+
raise NotImplementedError, "print"
|
28
28
|
end
|
29
29
|
|
30
30
|
# Prints the given +opts+, with a newline delimiter.
|