irb 1.4.1 → 1.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +1 -0
- data/README.md +4 -0
- data/irb.gemspec +2 -2
- data/lib/irb/cmd/chws.rb +4 -2
- data/lib/irb/cmd/fork.rb +5 -2
- data/lib/irb/cmd/help.rb +4 -2
- data/lib/irb/cmd/info.rb +4 -2
- data/lib/irb/cmd/load.rb +3 -2
- data/lib/irb/cmd/ls.rb +4 -2
- data/lib/irb/cmd/measure.rb +4 -2
- data/lib/irb/cmd/nop.rb +4 -2
- data/lib/irb/cmd/pushws.rb +4 -2
- data/lib/irb/cmd/show_source.rb +4 -2
- data/lib/irb/cmd/subirb.rb +4 -2
- data/lib/irb/cmd/whereami.rb +4 -2
- data/lib/irb/color.rb +42 -29
- data/lib/irb/color_printer.rb +4 -1
- data/lib/irb/completion.rb +37 -8
- data/lib/irb/context.rb +21 -17
- data/lib/irb/ext/multi-irb.rb +0 -1
- data/lib/irb/ext/save-history.rb +3 -3
- data/lib/irb/extend-command.rb +25 -25
- data/lib/irb/init.rb +12 -4
- data/lib/irb/input-method.rb +18 -6
- data/lib/irb/inspector.rb +3 -11
- data/lib/irb/lc/error.rb +4 -7
- data/lib/irb/lc/help-message +43 -53
- data/lib/irb/lc/ja/encoding_aliases.rb +4 -2
- data/lib/irb/lc/ja/error.rb +4 -7
- data/lib/irb/lc/ja/help-message +0 -12
- data/lib/irb/ruby-lex.rb +24 -36
- data/lib/irb/version.rb +2 -2
- data/lib/irb/workspace.rb +6 -13
- data/lib/irb.rb +11 -59
- metadata +5 -3
data/lib/irb/extend-command.rb
CHANGED
@@ -47,7 +47,7 @@ module IRB # :nodoc:
|
|
47
47
|
|
48
48
|
@EXTEND_COMMANDS = [
|
49
49
|
[
|
50
|
-
:irb_current_working_workspace, :CurrentWorkingWorkspace, "
|
50
|
+
:irb_current_working_workspace, :CurrentWorkingWorkspace, "cmd/chws",
|
51
51
|
[:irb_print_working_workspace, OVERRIDE_ALL],
|
52
52
|
[:irb_cwws, OVERRIDE_ALL],
|
53
53
|
[:irb_pwws, OVERRIDE_ALL],
|
@@ -59,7 +59,7 @@ module IRB # :nodoc:
|
|
59
59
|
[:irb_pwb, OVERRIDE_ALL],
|
60
60
|
],
|
61
61
|
[
|
62
|
-
:irb_change_workspace, :ChangeWorkspace, "
|
62
|
+
:irb_change_workspace, :ChangeWorkspace, "cmd/chws",
|
63
63
|
[:irb_chws, OVERRIDE_ALL],
|
64
64
|
[:irb_cws, OVERRIDE_ALL],
|
65
65
|
[:chws, NO_OVERRIDE],
|
@@ -70,13 +70,13 @@ module IRB # :nodoc:
|
|
70
70
|
],
|
71
71
|
|
72
72
|
[
|
73
|
-
:irb_workspaces, :Workspaces, "
|
73
|
+
:irb_workspaces, :Workspaces, "cmd/pushws",
|
74
74
|
[:workspaces, NO_OVERRIDE],
|
75
75
|
[:irb_bindings, OVERRIDE_ALL],
|
76
76
|
[:bindings, NO_OVERRIDE],
|
77
77
|
],
|
78
78
|
[
|
79
|
-
:irb_push_workspace, :PushWorkspace, "
|
79
|
+
:irb_push_workspace, :PushWorkspace, "cmd/pushws",
|
80
80
|
[:irb_pushws, OVERRIDE_ALL],
|
81
81
|
[:pushws, NO_OVERRIDE],
|
82
82
|
[:irb_push_binding, OVERRIDE_ALL],
|
@@ -84,7 +84,7 @@ module IRB # :nodoc:
|
|
84
84
|
[:pushb, NO_OVERRIDE],
|
85
85
|
],
|
86
86
|
[
|
87
|
-
:irb_pop_workspace, :PopWorkspace, "
|
87
|
+
:irb_pop_workspace, :PopWorkspace, "cmd/pushws",
|
88
88
|
[:irb_popws, OVERRIDE_ALL],
|
89
89
|
[:popws, NO_OVERRIDE],
|
90
90
|
[:irb_pop_binding, OVERRIDE_ALL],
|
@@ -93,55 +93,55 @@ module IRB # :nodoc:
|
|
93
93
|
],
|
94
94
|
|
95
95
|
[
|
96
|
-
:irb_load, :Load, "
|
96
|
+
:irb_load, :Load, "cmd/load"],
|
97
97
|
[
|
98
|
-
:irb_require, :Require, "
|
98
|
+
:irb_require, :Require, "cmd/load"],
|
99
99
|
[
|
100
|
-
:irb_source, :Source, "
|
100
|
+
:irb_source, :Source, "cmd/load",
|
101
101
|
[:source, NO_OVERRIDE],
|
102
102
|
],
|
103
103
|
|
104
104
|
[
|
105
|
-
:irb, :IrbCommand, "
|
105
|
+
:irb, :IrbCommand, "cmd/subirb"],
|
106
106
|
[
|
107
|
-
:irb_jobs, :Jobs, "
|
107
|
+
:irb_jobs, :Jobs, "cmd/subirb",
|
108
108
|
[:jobs, NO_OVERRIDE],
|
109
109
|
],
|
110
110
|
[
|
111
|
-
:irb_fg, :Foreground, "
|
111
|
+
:irb_fg, :Foreground, "cmd/subirb",
|
112
112
|
[:fg, NO_OVERRIDE],
|
113
113
|
],
|
114
114
|
[
|
115
|
-
:irb_kill, :Kill, "
|
115
|
+
:irb_kill, :Kill, "cmd/subirb",
|
116
116
|
[:kill, OVERRIDE_PRIVATE_ONLY],
|
117
117
|
],
|
118
118
|
|
119
119
|
[
|
120
|
-
:irb_help, :Help, "
|
120
|
+
:irb_help, :Help, "cmd/help",
|
121
121
|
[:help, NO_OVERRIDE],
|
122
122
|
],
|
123
123
|
|
124
124
|
[
|
125
|
-
:irb_info, :Info, "
|
125
|
+
:irb_info, :Info, "cmd/info"
|
126
126
|
],
|
127
127
|
|
128
128
|
[
|
129
|
-
:irb_ls, :Ls, "
|
129
|
+
:irb_ls, :Ls, "cmd/ls",
|
130
130
|
[:ls, NO_OVERRIDE],
|
131
131
|
],
|
132
132
|
|
133
133
|
[
|
134
|
-
:irb_measure, :Measure, "
|
134
|
+
:irb_measure, :Measure, "cmd/measure",
|
135
135
|
[:measure, NO_OVERRIDE],
|
136
136
|
],
|
137
137
|
|
138
138
|
[
|
139
|
-
:irb_show_source, :ShowSource, "
|
139
|
+
:irb_show_source, :ShowSource, "cmd/show_source",
|
140
140
|
[:show_source, NO_OVERRIDE],
|
141
141
|
],
|
142
142
|
|
143
143
|
[
|
144
|
-
:irb_whereami, :Whereami, "
|
144
|
+
:irb_whereami, :Whereami, "cmd/whereami",
|
145
145
|
[:whereami, NO_OVERRIDE],
|
146
146
|
],
|
147
147
|
|
@@ -187,7 +187,7 @@ module IRB # :nodoc:
|
|
187
187
|
kwargs = ", **kwargs" if RUBY_ENGINE == "ruby" && RUBY_VERSION >= "2.7.0"
|
188
188
|
line = __LINE__; eval %[
|
189
189
|
def #{cmd_name}(*opts#{kwargs}, &b)
|
190
|
-
|
190
|
+
require_relative "#{load_file}"
|
191
191
|
arity = ExtendCommand::#{cmd_class}.instance_method(:execute).arity
|
192
192
|
args = (1..(arity < 0 ? ~arity : arity)).map {|i| "arg" + i.to_s }
|
193
193
|
args << "*opts#{kwargs}" if arity < 0
|
@@ -235,7 +235,7 @@ module IRB # :nodoc:
|
|
235
235
|
alias_method to, from
|
236
236
|
}
|
237
237
|
else
|
238
|
-
print "irb: warn: can't alias #{to} from #{from}.\n"
|
238
|
+
Kernel.print "irb: warn: can't alias #{to} from #{from}.\n"
|
239
239
|
end
|
240
240
|
end
|
241
241
|
|
@@ -262,10 +262,10 @@ module IRB # :nodoc:
|
|
262
262
|
CE = ContextExtender # :nodoc:
|
263
263
|
|
264
264
|
@EXTEND_COMMANDS = [
|
265
|
-
[:eval_history=, "
|
266
|
-
[:use_tracer=, "
|
267
|
-
[:use_loader=, "
|
268
|
-
[:save_history=, "
|
265
|
+
[:eval_history=, "ext/history.rb"],
|
266
|
+
[:use_tracer=, "ext/tracer.rb"],
|
267
|
+
[:use_loader=, "ext/use-loader.rb"],
|
268
|
+
[:save_history=, "ext/save-history.rb"],
|
269
269
|
]
|
270
270
|
|
271
271
|
# Installs the default context extensions as irb commands:
|
@@ -288,7 +288,7 @@ module IRB # :nodoc:
|
|
288
288
|
line = __LINE__; Context.module_eval %[
|
289
289
|
def #{cmd_name}(*opts, &b)
|
290
290
|
Context.module_eval {remove_method(:#{cmd_name})}
|
291
|
-
|
291
|
+
require_relative "#{load_file}"
|
292
292
|
__send__ :#{cmd_name}, *opts, &b
|
293
293
|
end
|
294
294
|
for ali in aliases
|
data/lib/irb/init.rb
CHANGED
@@ -289,6 +289,10 @@ module IRB # :nodoc:
|
|
289
289
|
@CONF[:PROMPT_MODE] = prompt_mode
|
290
290
|
when "--noprompt"
|
291
291
|
@CONF[:PROMPT_MODE] = :NULL
|
292
|
+
when "--script"
|
293
|
+
noscript = false
|
294
|
+
when "--noscript"
|
295
|
+
noscript = true
|
292
296
|
when "--inf-ruby-mode"
|
293
297
|
@CONF[:PROMPT_MODE] = :INF_RUBY
|
294
298
|
when "--sample-book-mode", "--simple-prompt"
|
@@ -309,16 +313,20 @@ module IRB # :nodoc:
|
|
309
313
|
IRB.print_usage
|
310
314
|
exit 0
|
311
315
|
when "--"
|
312
|
-
if opt = argv.shift
|
316
|
+
if !noscript && (opt = argv.shift)
|
313
317
|
@CONF[:SCRIPT] = opt
|
314
318
|
$0 = opt
|
315
319
|
end
|
316
320
|
break
|
317
|
-
when
|
321
|
+
when /^-./
|
318
322
|
fail UnrecognizedSwitch, opt
|
319
323
|
else
|
320
|
-
|
321
|
-
|
324
|
+
if noscript
|
325
|
+
argv.unshift(opt)
|
326
|
+
else
|
327
|
+
@CONF[:SCRIPT] = opt
|
328
|
+
$0 = opt
|
329
|
+
end
|
322
330
|
break
|
323
331
|
end
|
324
332
|
end
|
data/lib/irb/input-method.rb
CHANGED
@@ -14,7 +14,6 @@ require_relative 'magic-file'
|
|
14
14
|
require_relative 'completion'
|
15
15
|
require 'io/console'
|
16
16
|
require 'reline'
|
17
|
-
require 'rdoc'
|
18
17
|
|
19
18
|
module IRB
|
20
19
|
STDIN_FILE_NAME = "(line)" # :nodoc:
|
@@ -39,7 +38,7 @@ module IRB
|
|
39
38
|
public :gets
|
40
39
|
|
41
40
|
def winsize
|
42
|
-
if instance_variable_defined?(:@stdout)
|
41
|
+
if instance_variable_defined?(:@stdout) && @stdout.tty?
|
43
42
|
@stdout.winsize
|
44
43
|
else
|
45
44
|
[24, 80]
|
@@ -84,8 +83,7 @@ module IRB
|
|
84
83
|
#
|
85
84
|
# See IO#eof? for more information.
|
86
85
|
def eof?
|
87
|
-
|
88
|
-
if rs and rs[0]
|
86
|
+
if @stdin.wait_readable(0.00001)
|
89
87
|
c = @stdin.getc
|
90
88
|
result = c.nil? ? true : false
|
91
89
|
@stdin.ungetc(c) unless c.nil?
|
@@ -139,7 +137,7 @@ module IRB
|
|
139
137
|
# Creates a new input method object
|
140
138
|
def initialize(file)
|
141
139
|
super
|
142
|
-
@io = IRB::MagicFile.open(file)
|
140
|
+
@io = file.is_a?(IO) ? file : IRB::MagicFile.open(file)
|
143
141
|
@external_encoding = @io.external_encoding
|
144
142
|
end
|
145
143
|
# The file name of this input method, usually given during initialization.
|
@@ -263,7 +261,7 @@ module IRB
|
|
263
261
|
end
|
264
262
|
end
|
265
263
|
|
266
|
-
class
|
264
|
+
class RelineInputMethod < InputMethod
|
267
265
|
include Reline
|
268
266
|
|
269
267
|
# Creates a new input method object using Reline
|
@@ -322,6 +320,11 @@ module IRB
|
|
322
320
|
[195, 164], # The "ä" that appears when Alt+d is pressed on xterm.
|
323
321
|
[226, 136, 130] # The "∂" that appears when Alt+d in pressed on iTerm2.
|
324
322
|
]
|
323
|
+
begin
|
324
|
+
require 'rdoc'
|
325
|
+
rescue LoadError
|
326
|
+
return nil
|
327
|
+
end
|
325
328
|
|
326
329
|
if just_cursor_moving and completion_journey_data.nil?
|
327
330
|
return nil
|
@@ -467,4 +470,13 @@ module IRB
|
|
467
470
|
str
|
468
471
|
end
|
469
472
|
end
|
473
|
+
|
474
|
+
class ReidlineInputMethod < RelineInputMethod
|
475
|
+
def initialize
|
476
|
+
warn <<~MSG.strip
|
477
|
+
IRB::ReidlineInputMethod is deprecated, please use IRB::RelineInputMethod instead.
|
478
|
+
MSG
|
479
|
+
super
|
480
|
+
end
|
481
|
+
end
|
470
482
|
end
|
data/lib/irb/inspector.rb
CHANGED
@@ -108,18 +108,10 @@ module IRB # :nodoc:
|
|
108
108
|
|
109
109
|
Inspector.def_inspector([false, :to_s, :raw]){|v| v.to_s}
|
110
110
|
Inspector.def_inspector([:p, :inspect]){|v|
|
111
|
-
|
112
|
-
if IRB.conf[:MAIN_CONTEXT]&.use_colorize? && Color.inspect_colorable?(v)
|
113
|
-
result = Color.colorize_code(result)
|
114
|
-
end
|
115
|
-
result
|
111
|
+
Color.colorize_code(v.inspect, colorable: Color.colorable? && Color.inspect_colorable?(v))
|
116
112
|
}
|
117
|
-
Inspector.def_inspector([true, :pp, :pretty_inspect], proc{
|
118
|
-
|
119
|
-
IRB::ColorPrinter.pp(v, '').chomp
|
120
|
-
else
|
121
|
-
v.pretty_inspect.chomp
|
122
|
-
end
|
113
|
+
Inspector.def_inspector([true, :pp, :pretty_inspect], proc{require_relative "color_printer"}){|v|
|
114
|
+
IRB::ColorPrinter.pp(v, '').chomp
|
123
115
|
}
|
124
116
|
Inspector.def_inspector([:yaml, :YAML], proc{require "yaml"}){|v|
|
125
117
|
begin
|
data/lib/irb/lc/error.rb
CHANGED
@@ -10,8 +10,9 @@
|
|
10
10
|
#
|
11
11
|
#
|
12
12
|
|
13
|
-
# :stopdoc:
|
14
13
|
module IRB
|
14
|
+
# :stopdoc:
|
15
|
+
|
15
16
|
class UnrecognizedSwitch < StandardError
|
16
17
|
def initialize(val)
|
17
18
|
super("Unrecognized switch: #{val}")
|
@@ -47,11 +48,6 @@ module IRB
|
|
47
48
|
super("No such job(#{val}).")
|
48
49
|
end
|
49
50
|
end
|
50
|
-
class CantShiftToMultiIrbMode < StandardError
|
51
|
-
def initialize
|
52
|
-
super("Can't shift to multi irb mode.")
|
53
|
-
end
|
54
|
-
end
|
55
51
|
class CantChangeBinding < StandardError
|
56
52
|
def initialize(val)
|
57
53
|
super("Can't change binding to (#{val}).")
|
@@ -67,5 +63,6 @@ module IRB
|
|
67
63
|
super("Define illegal RC_NAME_GENERATOR.")
|
68
64
|
end
|
69
65
|
end
|
66
|
+
|
67
|
+
# :startdoc:
|
70
68
|
end
|
71
|
-
# :startdoc:
|
data/lib/irb/lc/help-message
CHANGED
@@ -1,61 +1,51 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
#
|
3
|
-
# irb/lc/help-message.rb -
|
4
|
-
# $Release Version: 0.9.6$
|
5
|
-
# $Revision$
|
6
|
-
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
|
7
|
-
#
|
8
|
-
# --
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
12
1
|
Usage: irb.rb [options] [programfile] [arguments]
|
13
|
-
-f
|
14
|
-
-d Set $DEBUG to true (same as
|
15
|
-
-r load-module
|
16
|
-
-I path Specify $LOAD_PATH directory
|
17
|
-
-U
|
18
|
-
-E
|
19
|
-
|
20
|
-
-
|
2
|
+
-f Don't initialize from configuration file.
|
3
|
+
-d Set $DEBUG and $VERBOSE to true (same as 'ruby -d').
|
4
|
+
-r load-module Require load-module (same as 'ruby -r').
|
5
|
+
-I path Specify $LOAD_PATH directory (same as 'ruby -I').
|
6
|
+
-U Set external and internal encodings to UTF-8.
|
7
|
+
-E ex[:in] Set default external (ex) and internal (in) encodings
|
8
|
+
(same as 'ruby -E').
|
9
|
+
-w Suppress warnings (same as 'ruby -w').
|
10
|
+
-W[level=2] Set warning level: 0=silence, 1=medium, 2=verbose
|
11
|
+
(same as 'ruby -W').
|
21
12
|
--context-mode n Set n[0-4] to method to create Binding Object,
|
22
|
-
when new workspace was created
|
23
|
-
--extra-doc-dir Add an extra doc dir for the doc dialog
|
24
|
-
--echo Show result (default)
|
25
|
-
--noecho Don't show result
|
13
|
+
when new workspace was created.
|
14
|
+
--extra-doc-dir Add an extra doc dir for the doc dialog.
|
15
|
+
--echo Show result (default).
|
16
|
+
--noecho Don't show result.
|
26
17
|
--echo-on-assignment
|
27
|
-
Show result on assignment
|
18
|
+
Show result on assignment.
|
28
19
|
--noecho-on-assignment
|
29
|
-
Don't show result on assignment
|
20
|
+
Don't show result on assignment.
|
30
21
|
--truncate-echo-on-assignment
|
31
|
-
Show truncated result on assignment (default)
|
32
|
-
--inspect Use
|
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
|
37
|
-
--nosingleline Don't use
|
38
|
-
--colorize Use
|
39
|
-
--nocolorize Don't use
|
40
|
-
--autocomplete Use
|
41
|
-
--noautocomplete Don't use
|
42
|
-
--prompt prompt-mode
|
43
|
-
|
44
|
-
|
22
|
+
Show truncated result on assignment (default).
|
23
|
+
--inspect Use 'inspect' for output.
|
24
|
+
--noinspect Don't use 'inspect' for output.
|
25
|
+
--multiline Use multiline editor module.
|
26
|
+
--nomultiline Don't use multiline editor module (default).
|
27
|
+
--singleline Use single line editor module.
|
28
|
+
--nosingleline Don't use single line editor module (default).
|
29
|
+
--colorize Use color-highlighting (default).
|
30
|
+
--nocolorize Don't use color-highlighting.
|
31
|
+
--autocomplete Use auto-completion (default).
|
32
|
+
--noautocomplete Don't use auto-completion.
|
33
|
+
--prompt prompt-mode, --prompt-mode prompt-mode
|
34
|
+
Set prompt mode. Pre-defined prompt modes are:
|
35
|
+
'default', 'classic', 'simple', 'inf-ruby', 'xmp', 'null'.
|
45
36
|
--inf-ruby-mode Use prompt appropriate for inf-ruby-mode on emacs.
|
46
37
|
Suppresses --multiline and --singleline.
|
47
|
-
--sample-book-mode
|
48
|
-
|
49
|
-
--noprompt
|
38
|
+
--sample-book-mode, --simple-prompt
|
39
|
+
Set prompt mode to 'simple'.
|
40
|
+
--noprompt Don't output prompt.
|
41
|
+
--script Script mode (default, treat first argument as script)
|
42
|
+
--noscript No script mode (leave arguments in argv)
|
50
43
|
--single-irb Share self with sub-irb.
|
51
|
-
--tracer
|
52
|
-
--back-trace-limit n
|
53
|
-
Display backtrace top n and
|
54
|
-
|
55
|
-
--
|
56
|
-
--
|
57
|
-
-
|
58
|
-
-
|
59
|
-
-- Separate options of irb from the list of command-line args
|
60
|
-
|
61
|
-
# vim:fileencoding=utf-8
|
44
|
+
--tracer Show stack trace for each command.
|
45
|
+
--back-trace-limit n[=16]
|
46
|
+
Display backtrace top n and bottom n.
|
47
|
+
--verbose Show details.
|
48
|
+
--noverbose Don't show details.
|
49
|
+
-v, --version Print the version of irb.
|
50
|
+
-h, --help Print help.
|
51
|
+
-- Separate options of irb from the list of command-line args.
|
data/lib/irb/lc/ja/error.rb
CHANGED
@@ -10,8 +10,9 @@
|
|
10
10
|
#
|
11
11
|
#
|
12
12
|
|
13
|
-
# :stopdoc:
|
14
13
|
module IRB
|
14
|
+
# :stopdoc:
|
15
|
+
|
15
16
|
class UnrecognizedSwitch < StandardError
|
16
17
|
def initialize(val)
|
17
18
|
super("スイッチ(#{val})が分りません")
|
@@ -47,11 +48,6 @@ module IRB
|
|
47
48
|
super("そのようなジョブ(#{val})はありません.")
|
48
49
|
end
|
49
50
|
end
|
50
|
-
class CantShiftToMultiIrbMode < StandardError
|
51
|
-
def initialize
|
52
|
-
super("multi-irb modeに移れません.")
|
53
|
-
end
|
54
|
-
end
|
55
51
|
class CantChangeBinding < StandardError
|
56
52
|
def initialize(val)
|
57
53
|
super("バインディング(#{val})に変更できません.")
|
@@ -67,6 +63,7 @@ module IRB
|
|
67
63
|
super("RC_NAME_GENERATORが正しく定義されていません.")
|
68
64
|
end
|
69
65
|
end
|
66
|
+
|
67
|
+
# :startdoc:
|
70
68
|
end
|
71
|
-
# :startdoc:
|
72
69
|
# vim:fileencoding=utf-8
|
data/lib/irb/lc/ja/help-message
CHANGED
@@ -1,13 +1,3 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
# irb/lc/ja/help-message.rb -
|
3
|
-
# $Release Version: 0.9.6$
|
4
|
-
# $Revision$
|
5
|
-
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
|
6
|
-
#
|
7
|
-
# --
|
8
|
-
#
|
9
|
-
#
|
10
|
-
#
|
11
1
|
Usage: irb.rb [options] [programfile] [arguments]
|
12
2
|
-f ~/.irbrc を読み込まない.
|
13
3
|
-d $DEBUG をtrueにする(ruby -d と同じ)
|
@@ -53,5 +43,3 @@ Usage: irb.rb [options] [programfile] [arguments]
|
|
53
43
|
-v, --version irbのバージョンを表示する.
|
54
44
|
-h, --help irb のヘルプを表示する.
|
55
45
|
-- 以降のコマンドライン引数をオプションとして扱わない.
|
56
|
-
|
57
|
-
# vim:fileencoding=utf-8
|
data/lib/irb/ruby-lex.rb
CHANGED
@@ -139,7 +139,7 @@ class RubyLex
|
|
139
139
|
def self.ripper_lex_without_warning(code, context: nil)
|
140
140
|
verbose, $VERBOSE = $VERBOSE, nil
|
141
141
|
if context
|
142
|
-
lvars = context
|
142
|
+
lvars = context.workspace&.binding&.local_variables
|
143
143
|
if lvars && !lvars.empty?
|
144
144
|
code = "#{lvars.join('=')}=nil\n#{code}"
|
145
145
|
line_no = 0
|
@@ -147,30 +147,24 @@ class RubyLex
|
|
147
147
|
line_no = 1
|
148
148
|
end
|
149
149
|
end
|
150
|
-
|
150
|
+
|
151
151
|
compile_with_errors_suppressed(code, line_no: line_no) do |inner_code, line_no|
|
152
152
|
lexer = Ripper::Lexer.new(inner_code, '-', line_no)
|
153
153
|
if lexer.respond_to?(:scan) # Ruby 2.7+
|
154
|
-
|
155
|
-
pos_to_index = {}
|
156
|
-
lexer.scan.each do |t|
|
154
|
+
lexer.scan.each_with_object([]) do |t, tokens|
|
157
155
|
next if t.pos.first == 0
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
if ERROR_TOKENS.include?(
|
162
|
-
tokens[index] = t
|
163
|
-
end
|
156
|
+
prev_tk = tokens.last
|
157
|
+
position_overlapped = prev_tk && t.pos[0] == prev_tk.pos[0] && t.pos[1] < prev_tk.pos[1] + prev_tk.tok.bytesize
|
158
|
+
if position_overlapped
|
159
|
+
tokens[-1] = t if ERROR_TOKENS.include?(prev_tk.event) && !ERROR_TOKENS.include?(t.event)
|
164
160
|
else
|
165
|
-
pos_to_index[t.pos] = tokens.size
|
166
161
|
tokens << t
|
167
162
|
end
|
168
163
|
end
|
169
164
|
else
|
170
|
-
|
165
|
+
lexer.parse.reject { |it| it.pos.first == 0 }
|
171
166
|
end
|
172
167
|
end
|
173
|
-
tokens
|
174
168
|
ensure
|
175
169
|
$VERBOSE = verbose
|
176
170
|
end
|
@@ -209,12 +203,7 @@ class RubyLex
|
|
209
203
|
last_line = lines[line_index]&.byteslice(0, byte_pointer)
|
210
204
|
code += last_line if last_line
|
211
205
|
@tokens = self.class.ripper_lex_without_warning(code, context: context)
|
212
|
-
|
213
|
-
if corresponding_token_depth
|
214
|
-
corresponding_token_depth
|
215
|
-
else
|
216
|
-
nil
|
217
|
-
end
|
206
|
+
check_corresponding_token_depth(lines, line_index)
|
218
207
|
end
|
219
208
|
end
|
220
209
|
end
|
@@ -308,7 +297,7 @@ class RubyLex
|
|
308
297
|
return true
|
309
298
|
elsif tokens.size >= 1 and tokens[-1].event == :on_heredoc_end # "EOH\n"
|
310
299
|
return false
|
311
|
-
elsif tokens.size >= 2 and
|
300
|
+
elsif tokens.size >= 2 and tokens[-2].state.anybits?(Ripper::EXPR_BEG | Ripper::EXPR_FNAME) and tokens[-2].tok !~ /\A\.\.\.?\z/
|
312
301
|
# end of literal except for regexp
|
313
302
|
# endless range at end of line is not a continue
|
314
303
|
return true
|
@@ -389,21 +378,20 @@ class RubyLex
|
|
389
378
|
$VERBOSE = verbose
|
390
379
|
end
|
391
380
|
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
end
|
381
|
+
last_lex_state = tokens.last.state
|
382
|
+
|
383
|
+
if last_lex_state.allbits?(Ripper::EXPR_BEG)
|
384
|
+
return false
|
385
|
+
elsif last_lex_state.allbits?(Ripper::EXPR_DOT)
|
386
|
+
return true
|
387
|
+
elsif last_lex_state.allbits?(Ripper::EXPR_CLASS)
|
388
|
+
return true
|
389
|
+
elsif last_lex_state.allbits?(Ripper::EXPR_FNAME)
|
390
|
+
return true
|
391
|
+
elsif last_lex_state.allbits?(Ripper::EXPR_VALUE)
|
392
|
+
return true
|
393
|
+
elsif last_lex_state.allbits?(Ripper::EXPR_ARG)
|
394
|
+
return false
|
407
395
|
end
|
408
396
|
|
409
397
|
false
|
data/lib/irb/version.rb
CHANGED
data/lib/irb/workspace.rb
CHANGED
@@ -158,27 +158,20 @@ EOF
|
|
158
158
|
end
|
159
159
|
end
|
160
160
|
|
161
|
-
|
162
|
-
use_colorize = IRB.conf.fetch(:USE_COLORIZE, true)
|
163
|
-
if use_colorize
|
164
|
-
lines = Color.colorize_code(code).lines
|
165
|
-
else
|
166
|
-
lines = code.lines
|
167
|
-
end
|
161
|
+
lines = Color.colorize_code(code).lines
|
168
162
|
pos -= 1
|
169
163
|
|
170
164
|
start_pos = [pos - 5, 0].max
|
171
165
|
end_pos = [pos + 5, lines.size - 1].min
|
172
166
|
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
fmt = " %2s %#{end_pos.to_s.length}d: %s"
|
177
|
-
end
|
167
|
+
line_number_fmt = Color.colorize("%#{end_pos.to_s.length}d", [:BLUE, :BOLD])
|
168
|
+
fmt = " %2s #{line_number_fmt}: %s"
|
169
|
+
|
178
170
|
body = (start_pos..end_pos).map do |current_pos|
|
179
171
|
sprintf(fmt, pos == current_pos ? '=>' : '', current_pos + 1, lines[current_pos])
|
180
172
|
end.join("")
|
181
|
-
|
173
|
+
|
174
|
+
"\nFrom: #{file} @ line #{pos + 1} :\n\n#{body}#{Color.clear}\n"
|
182
175
|
end
|
183
176
|
|
184
177
|
def IRB.delete_caller
|