irb 1.6.2 → 1.6.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +13 -10
- data/README.md +53 -16
- data/exe/irb +0 -2
- data/irb.gemspec +5 -0
- data/lib/irb/cmd/chws.rb +0 -6
- data/lib/irb/cmd/fork.rb +0 -6
- data/lib/irb/cmd/help.rb +0 -6
- data/lib/irb/cmd/load.rb +0 -6
- data/lib/irb/cmd/ls.rb +20 -7
- data/lib/irb/cmd/nop.rb +1 -6
- data/lib/irb/cmd/pushws.rb +0 -6
- data/lib/irb/cmd/show_source.rb +3 -3
- data/lib/irb/cmd/subirb.rb +1 -6
- data/lib/irb/color.rb +1 -1
- data/lib/irb/completion.rb +8 -14
- data/lib/irb/context.rb +2 -7
- data/lib/irb/ext/change-ws.rb +0 -6
- data/lib/irb/ext/history.rb +2 -8
- data/lib/irb/ext/loader.rb +0 -7
- data/lib/irb/ext/multi-irb.rb +0 -6
- data/lib/irb/ext/save-history.rb +1 -6
- data/lib/irb/ext/tracer.rb +3 -8
- data/lib/irb/ext/use-loader.rb +0 -6
- data/lib/irb/ext/workspaces.rb +0 -6
- data/lib/irb/extend-command.rb +5 -10
- data/lib/irb/frame.rb +0 -6
- data/lib/irb/help.rb +0 -6
- data/lib/irb/init.rb +1 -9
- data/lib/irb/input-method.rb +1 -6
- data/lib/irb/inspector.rb +13 -10
- data/lib/irb/lc/error.rb +0 -6
- data/lib/irb/lc/help-message +2 -2
- data/lib/irb/lc/ja/error.rb +1 -7
- data/lib/irb/locale.rb +1 -6
- data/lib/irb/notifier.rb +0 -6
- data/lib/irb/output-method.rb +0 -6
- data/lib/irb/ruby-lex.rb +37 -52
- data/lib/irb/version.rb +2 -8
- data/lib/irb/workspace.rb +4 -15
- data/lib/irb/ws-for-case-2.rb +0 -6
- data/lib/irb/xmp.rb +0 -6
- data/lib/irb.rb +20 -12
- metadata +8 -4
data/lib/irb/init.rb
CHANGED
@@ -1,14 +1,8 @@
|
|
1
1
|
# frozen_string_literal: false
|
2
2
|
#
|
3
3
|
# irb/init.rb - irb initialize module
|
4
|
-
# $Release Version: 0.9.6$
|
5
|
-
# $Revision$
|
6
4
|
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
|
7
5
|
#
|
8
|
-
# --
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
12
6
|
|
13
7
|
module IRB # :nodoc:
|
14
8
|
|
@@ -407,9 +401,9 @@ module IRB # :nodoc:
|
|
407
401
|
end
|
408
402
|
if home = ENV["HOME"]
|
409
403
|
yield proc{|rc| home+"/.irb#{rc}"}
|
404
|
+
yield proc{|rc| home+"/.config/irb/irb#{rc}"}
|
410
405
|
end
|
411
406
|
current_dir = Dir.pwd
|
412
|
-
yield proc{|rc| current_dir+"/.config/irb/irb#{rc}"}
|
413
407
|
yield proc{|rc| current_dir+"/.irb#{rc}"}
|
414
408
|
yield proc{|rc| current_dir+"/irb#{rc.sub(/\A_?/, '.')}"}
|
415
409
|
yield proc{|rc| current_dir+"/_irb#{rc}"}
|
@@ -427,8 +421,6 @@ module IRB # :nodoc:
|
|
427
421
|
end
|
428
422
|
end
|
429
423
|
|
430
|
-
|
431
|
-
DefaultEncodings = Struct.new(:external, :internal)
|
432
424
|
class << IRB
|
433
425
|
private
|
434
426
|
def set_encoding(extern, intern = nil, override: true)
|
data/lib/irb/input-method.rb
CHANGED
@@ -1,14 +1,9 @@
|
|
1
1
|
# frozen_string_literal: false
|
2
2
|
#
|
3
3
|
# irb/input-method.rb - input methods used irb
|
4
|
-
# $Release Version: 0.9.6$
|
5
|
-
# $Revision$
|
6
4
|
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
|
7
5
|
#
|
8
|
-
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
6
|
+
|
12
7
|
require_relative 'src_encoding'
|
13
8
|
require_relative 'magic-file'
|
14
9
|
require_relative 'completion'
|
data/lib/irb/inspector.rb
CHANGED
@@ -1,15 +1,8 @@
|
|
1
1
|
# frozen_string_literal: false
|
2
2
|
#
|
3
3
|
# irb/inspector.rb - inspect methods
|
4
|
-
# $Release Version: 0.9.6$
|
5
|
-
# $Revision: 1.19 $
|
6
|
-
# $Date: 2002/06/11 07:51:31 $
|
7
4
|
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
|
8
5
|
#
|
9
|
-
# --
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
13
6
|
|
14
7
|
module IRB # :nodoc:
|
15
8
|
|
@@ -42,6 +35,7 @@ module IRB # :nodoc:
|
|
42
35
|
# irb(main):001:0> "what?" #=> omg! what?
|
43
36
|
#
|
44
37
|
class Inspector
|
38
|
+
KERNEL_INSPECT = Object.instance_method(:inspect)
|
45
39
|
# Default inspectors available to irb, this includes:
|
46
40
|
#
|
47
41
|
# +:pp+:: Using Kernel#pretty_inspect
|
@@ -100,9 +94,18 @@ module IRB # :nodoc:
|
|
100
94
|
# Proc to call when the input is evaluated and output in irb.
|
101
95
|
def inspect_value(v)
|
102
96
|
@inspect.call(v)
|
103
|
-
rescue
|
104
|
-
puts "
|
105
|
-
|
97
|
+
rescue => e
|
98
|
+
puts "An error occurred when inspecting the object: #{e.inspect}"
|
99
|
+
|
100
|
+
begin
|
101
|
+
# TODO: change this to bind_call when we drop support for Ruby 2.6
|
102
|
+
puts "Result of Kernel#inspect: #{KERNEL_INSPECT.bind(v).call}"
|
103
|
+
''
|
104
|
+
rescue => e
|
105
|
+
puts "An error occurred when running Kernel#inspect: #{e.inspect}"
|
106
|
+
puts e.backtrace.join("\n")
|
107
|
+
''
|
108
|
+
end
|
106
109
|
end
|
107
110
|
end
|
108
111
|
|
data/lib/irb/lc/error.rb
CHANGED
data/lib/irb/lc/help-message
CHANGED
@@ -22,8 +22,8 @@ Usage: irb.rb [options] [programfile] [arguments]
|
|
22
22
|
Show truncated result on assignment (default).
|
23
23
|
--inspect Use 'inspect' for output.
|
24
24
|
--noinspect Don't use 'inspect' for output.
|
25
|
-
--multiline Use multiline editor module.
|
26
|
-
--nomultiline Don't use multiline editor module
|
25
|
+
--multiline Use multiline editor module (default).
|
26
|
+
--nomultiline Don't use multiline editor module.
|
27
27
|
--singleline Use single line editor module.
|
28
28
|
--nosingleline Don't use single line editor module (default).
|
29
29
|
--colorize Use color-highlighting (default).
|
data/lib/irb/lc/ja/error.rb
CHANGED
data/lib/irb/locale.rb
CHANGED
data/lib/irb/notifier.rb
CHANGED
data/lib/irb/output-method.rb
CHANGED
@@ -1,14 +1,8 @@
|
|
1
1
|
# frozen_string_literal: false
|
2
2
|
#
|
3
3
|
# output-method.rb - output methods used by irb
|
4
|
-
# $Release Version: 0.9.6$
|
5
|
-
# $Revision$
|
6
4
|
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
|
7
5
|
#
|
8
|
-
# --
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
12
6
|
|
13
7
|
module IRB
|
14
8
|
# An abstract output class for IO in irb. This is mainly used internally by
|
data/lib/irb/ruby-lex.rb
CHANGED
@@ -1,14 +1,8 @@
|
|
1
1
|
# frozen_string_literal: false
|
2
2
|
#
|
3
3
|
# irb/ruby-lex.rb - ruby lexcal analyzer
|
4
|
-
# $Release Version: 0.9.6$
|
5
|
-
# $Revision$
|
6
4
|
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
|
7
5
|
#
|
8
|
-
# --
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
12
6
|
|
13
7
|
require "ripper"
|
14
8
|
require "jruby" if RUBY_ENGINE == "jruby"
|
@@ -22,7 +16,8 @@ class RubyLex
|
|
22
16
|
end
|
23
17
|
end
|
24
18
|
|
25
|
-
def initialize
|
19
|
+
def initialize(context)
|
20
|
+
@context = context
|
26
21
|
@exp_line_no = @line_no = 1
|
27
22
|
@indent = 0
|
28
23
|
@continue = false
|
@@ -48,13 +43,13 @@ class RubyLex
|
|
48
43
|
end
|
49
44
|
|
50
45
|
# io functions
|
51
|
-
def set_input(io,
|
46
|
+
def set_input(io, &block)
|
52
47
|
@io = io
|
53
48
|
if @io.respond_to?(:check_termination)
|
54
49
|
@io.check_termination do |code|
|
55
50
|
if Reline::IOGate.in_pasting?
|
56
|
-
lex = RubyLex.new
|
57
|
-
rest = lex.check_termination_in_prev_line(code
|
51
|
+
lex = RubyLex.new(@context)
|
52
|
+
rest = lex.check_termination_in_prev_line(code)
|
58
53
|
if rest
|
59
54
|
Reline.delete_text
|
60
55
|
rest.bytes.reverse_each do |c|
|
@@ -67,12 +62,13 @@ class RubyLex
|
|
67
62
|
else
|
68
63
|
# Accept any single-line input for symbol aliases or commands that transform args
|
69
64
|
command = code.split(/\s/, 2).first
|
70
|
-
if context.symbol_alias?(command) || context.transform_args?(command)
|
65
|
+
if @context.symbol_alias?(command) || @context.transform_args?(command)
|
71
66
|
next true
|
72
67
|
end
|
73
68
|
|
74
69
|
code.gsub!(/\s*\z/, '').concat("\n")
|
75
|
-
|
70
|
+
tokens = self.class.ripper_lex_without_warning(code, context: @context)
|
71
|
+
ltype, indent, continue, code_block_open = check_state(code, tokens)
|
76
72
|
if ltype or indent > 0 or continue or code_block_open
|
77
73
|
false
|
78
74
|
else
|
@@ -85,7 +81,7 @@ class RubyLex
|
|
85
81
|
@io.dynamic_prompt do |lines|
|
86
82
|
lines << '' if lines.empty?
|
87
83
|
result = []
|
88
|
-
tokens = self.class.ripper_lex_without_warning(lines.map{ |l| l + "\n" }.join, context: context)
|
84
|
+
tokens = self.class.ripper_lex_without_warning(lines.map{ |l| l + "\n" }.join, context: @context)
|
89
85
|
code = String.new
|
90
86
|
partial_tokens = []
|
91
87
|
unprocessed_tokens = []
|
@@ -96,8 +92,9 @@ class RubyLex
|
|
96
92
|
if t.tok.include?("\n")
|
97
93
|
t_str = t.tok
|
98
94
|
t_str.each_line("\n") do |s|
|
99
|
-
code << s
|
100
|
-
|
95
|
+
code << s
|
96
|
+
next unless s.include?("\n")
|
97
|
+
ltype, indent, continue, code_block_open = check_state(code, partial_tokens)
|
101
98
|
result << @prompt.call(ltype, indent, continue || code_block_open, @line_no + line_num_offset)
|
102
99
|
line_num_offset += 1
|
103
100
|
end
|
@@ -108,29 +105,22 @@ class RubyLex
|
|
108
105
|
end
|
109
106
|
|
110
107
|
unless unprocessed_tokens.empty?
|
111
|
-
ltype, indent, continue, code_block_open = check_state(code, unprocessed_tokens
|
108
|
+
ltype, indent, continue, code_block_open = check_state(code, unprocessed_tokens)
|
112
109
|
result << @prompt.call(ltype, indent, continue || code_block_open, @line_no + line_num_offset)
|
113
110
|
end
|
114
111
|
result
|
115
112
|
end
|
116
113
|
end
|
117
114
|
|
118
|
-
if
|
119
|
-
@input = p
|
120
|
-
elsif block_given?
|
115
|
+
if block_given?
|
121
116
|
@input = block
|
122
117
|
else
|
123
118
|
@input = Proc.new{@io.gets}
|
124
119
|
end
|
125
120
|
end
|
126
121
|
|
127
|
-
def set_prompt(
|
128
|
-
|
129
|
-
if p.respond_to?(:call)
|
130
|
-
@prompt = p
|
131
|
-
else
|
132
|
-
@prompt = Proc.new{print p}
|
133
|
-
end
|
122
|
+
def set_prompt(&block)
|
123
|
+
@prompt = block
|
134
124
|
end
|
135
125
|
|
136
126
|
ERROR_TOKENS = [
|
@@ -188,6 +178,7 @@ class RubyLex
|
|
188
178
|
if line_count >= line_index
|
189
179
|
return prev_spaces
|
190
180
|
end
|
181
|
+
next if t.event == :on_tstring_content || t.event == :on_words_sep
|
191
182
|
if (@tokens.size - 1) > i
|
192
183
|
md = @tokens[i + 1].tok.match(/(\A +)/)
|
193
184
|
prev_spaces = md.nil? ? 0 : md[1].count(' ')
|
@@ -197,11 +188,11 @@ class RubyLex
|
|
197
188
|
prev_spaces
|
198
189
|
end
|
199
190
|
|
200
|
-
def set_auto_indent
|
201
|
-
if @io.respond_to?(:auto_indent) and context.auto_indent_mode
|
191
|
+
def set_auto_indent
|
192
|
+
if @io.respond_to?(:auto_indent) and @context.auto_indent_mode
|
202
193
|
@io.auto_indent do |lines, line_index, byte_pointer, is_newline|
|
203
194
|
if is_newline
|
204
|
-
@tokens = self.class.ripper_lex_without_warning(lines[0..line_index].join("\n"), context: context)
|
195
|
+
@tokens = self.class.ripper_lex_without_warning(lines[0..line_index].join("\n"), context: @context)
|
205
196
|
prev_spaces = find_prev_spaces(line_index)
|
206
197
|
depth_difference = check_newline_depth_difference
|
207
198
|
depth_difference = 0 if depth_difference < 0
|
@@ -210,19 +201,18 @@ class RubyLex
|
|
210
201
|
code = line_index.zero? ? '' : lines[0..(line_index - 1)].map{ |l| l + "\n" }.join
|
211
202
|
last_line = lines[line_index]&.byteslice(0, byte_pointer)
|
212
203
|
code += last_line if last_line
|
213
|
-
@tokens = self.class.ripper_lex_without_warning(code, context: context)
|
204
|
+
@tokens = self.class.ripper_lex_without_warning(code, context: @context)
|
214
205
|
check_corresponding_token_depth(lines, line_index)
|
215
206
|
end
|
216
207
|
end
|
217
208
|
end
|
218
209
|
end
|
219
210
|
|
220
|
-
def check_state(code, tokens
|
221
|
-
tokens = self.class.ripper_lex_without_warning(code, context: context) unless tokens
|
211
|
+
def check_state(code, tokens)
|
222
212
|
ltype = process_literal_type(tokens)
|
223
213
|
indent = process_nesting_level(tokens)
|
224
214
|
continue = process_continue(tokens)
|
225
|
-
lvars_code = self.class.generate_local_variables_assign_code(context.local_variables)
|
215
|
+
lvars_code = self.class.generate_local_variables_assign_code(@context.local_variables)
|
226
216
|
code = "#{lvars_code}\n#{code}" if lvars_code
|
227
217
|
code_block_open = check_code_block(code, tokens)
|
228
218
|
[ltype, indent, continue, code_block_open]
|
@@ -243,13 +233,13 @@ class RubyLex
|
|
243
233
|
@code_block_open = false
|
244
234
|
end
|
245
235
|
|
246
|
-
def each_top_level_statement
|
236
|
+
def each_top_level_statement
|
247
237
|
initialize_input
|
248
238
|
catch(:TERM_INPUT) do
|
249
239
|
loop do
|
250
240
|
begin
|
251
241
|
prompt
|
252
|
-
unless l = lex
|
242
|
+
unless l = lex
|
253
243
|
throw :TERM_INPUT if @line == ''
|
254
244
|
else
|
255
245
|
@line_no += l.count("\n")
|
@@ -279,19 +269,19 @@ class RubyLex
|
|
279
269
|
end
|
280
270
|
end
|
281
271
|
|
282
|
-
def lex
|
272
|
+
def lex
|
283
273
|
line = @input.call
|
284
274
|
if @io.respond_to?(:check_termination)
|
285
275
|
return line # multiline
|
286
276
|
end
|
287
277
|
code = @line + (line.nil? ? '' : line)
|
288
278
|
code.gsub!(/\s*\z/, '').concat("\n")
|
289
|
-
@tokens = self.class.ripper_lex_without_warning(code, context: context)
|
290
|
-
@ltype, @indent, @continue, @code_block_open = check_state(code, @tokens
|
279
|
+
@tokens = self.class.ripper_lex_without_warning(code, context: @context)
|
280
|
+
@ltype, @indent, @continue, @code_block_open = check_state(code, @tokens)
|
291
281
|
line
|
292
282
|
end
|
293
283
|
|
294
|
-
def process_continue(tokens
|
284
|
+
def process_continue(tokens)
|
295
285
|
# last token is always newline
|
296
286
|
if tokens.size >= 2 and tokens[-2].event == :on_regexp_end
|
297
287
|
# end of regexp literal
|
@@ -312,7 +302,7 @@ class RubyLex
|
|
312
302
|
false
|
313
303
|
end
|
314
304
|
|
315
|
-
def check_code_block(code, tokens
|
305
|
+
def check_code_block(code, tokens)
|
316
306
|
return true if tokens.empty?
|
317
307
|
if tokens.last.event == :on_heredoc_beg
|
318
308
|
return true
|
@@ -404,7 +394,7 @@ class RubyLex
|
|
404
394
|
false
|
405
395
|
end
|
406
396
|
|
407
|
-
def process_nesting_level(tokens
|
397
|
+
def process_nesting_level(tokens)
|
408
398
|
indent = 0
|
409
399
|
in_oneliner_def = nil
|
410
400
|
tokens.each_with_index { |t, index|
|
@@ -642,7 +632,7 @@ class RubyLex
|
|
642
632
|
end
|
643
633
|
|
644
634
|
case t.event
|
645
|
-
when :on_ignored_nl, :on_nl, :on_comment
|
635
|
+
when :on_ignored_nl, :on_nl, :on_comment, :on_heredoc_end, :on_embdoc_end
|
646
636
|
if in_oneliner_def != :BODY
|
647
637
|
corresponding_token_depth = nil
|
648
638
|
spaces_at_line_head = 0
|
@@ -760,7 +750,7 @@ class RubyLex
|
|
760
750
|
pending_heredocs.first || start_token.last
|
761
751
|
end
|
762
752
|
|
763
|
-
def process_literal_type(tokens
|
753
|
+
def process_literal_type(tokens)
|
764
754
|
start_token = check_string_literal(tokens)
|
765
755
|
return nil if start_token == ""
|
766
756
|
|
@@ -781,20 +771,15 @@ class RubyLex
|
|
781
771
|
when :on_qsymbols_beg then ?]
|
782
772
|
when :on_symbols_beg then ?]
|
783
773
|
when :on_heredoc_beg
|
784
|
-
start_token&.tok =~ /<<[-~]?(['"`])
|
785
|
-
|
786
|
-
when ?" then ?"
|
787
|
-
when ?' then ?'
|
788
|
-
when ?` then ?`
|
789
|
-
else ?"
|
790
|
-
end
|
774
|
+
start_token&.tok =~ /<<[-~]?(['"`])\w+\1/
|
775
|
+
$1 || ?"
|
791
776
|
else
|
792
777
|
nil
|
793
778
|
end
|
794
779
|
end
|
795
780
|
|
796
|
-
def check_termination_in_prev_line(code
|
797
|
-
tokens = self.class.ripper_lex_without_warning(code, context: context)
|
781
|
+
def check_termination_in_prev_line(code)
|
782
|
+
tokens = self.class.ripper_lex_without_warning(code, context: @context)
|
798
783
|
past_first_newline = false
|
799
784
|
index = tokens.rindex do |t|
|
800
785
|
# traverse first token before last line
|
data/lib/irb/version.rb
CHANGED
@@ -1,17 +1,11 @@
|
|
1
1
|
# frozen_string_literal: false
|
2
2
|
#
|
3
3
|
# irb/version.rb - irb version definition file
|
4
|
-
# $Release Version: 0.9.6$
|
5
|
-
# $Revision$
|
6
4
|
# by Keiju ISHITSUKA(keiju@ishitsuka.com)
|
7
5
|
#
|
8
|
-
# --
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
12
6
|
|
13
7
|
module IRB # :nodoc:
|
14
|
-
VERSION = "1.6.
|
8
|
+
VERSION = "1.6.3"
|
15
9
|
@RELEASE_VERSION = VERSION
|
16
|
-
@LAST_UPDATE_DATE = "
|
10
|
+
@LAST_UPDATE_DATE = "2023-03-06"
|
17
11
|
end
|
data/lib/irb/workspace.rb
CHANGED
@@ -1,14 +1,8 @@
|
|
1
1
|
# frozen_string_literal: false
|
2
2
|
#
|
3
3
|
# irb/workspace-binding.rb -
|
4
|
-
# $Release Version: 0.9.6$
|
5
|
-
# $Revision$
|
6
4
|
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
|
7
5
|
#
|
8
|
-
# --
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
12
6
|
|
13
7
|
require "delegate"
|
14
8
|
|
@@ -115,7 +109,7 @@ EOF
|
|
115
109
|
attr_reader :main
|
116
110
|
|
117
111
|
# Evaluate the given +statements+ within the context of this workspace.
|
118
|
-
def evaluate(
|
112
|
+
def evaluate(statements, file = __FILE__, line = __LINE__)
|
119
113
|
eval(statements, @binding, file, line)
|
120
114
|
end
|
121
115
|
|
@@ -128,6 +122,8 @@ EOF
|
|
128
122
|
end
|
129
123
|
|
130
124
|
# error message manipulator
|
125
|
+
# WARN: Rails patches this method to filter its own backtrace. Be cautious when changing it.
|
126
|
+
# See: https://github.com/rails/rails/blob/main/railties/lib/rails/commands/console/console_command.rb#L8:~:text=def,filter_backtrace
|
131
127
|
def filter_backtrace(bt)
|
132
128
|
return nil if bt =~ /\/irb\/.*\.rb/
|
133
129
|
return nil if bt =~ /\/irb\.rb/
|
@@ -142,11 +138,7 @@ EOF
|
|
142
138
|
end
|
143
139
|
|
144
140
|
def code_around_binding
|
145
|
-
|
146
|
-
file, pos = @binding.source_location
|
147
|
-
else
|
148
|
-
file, pos = @binding.eval('[__FILE__, __LINE__]')
|
149
|
-
end
|
141
|
+
file, pos = @binding.source_location
|
150
142
|
|
151
143
|
if defined?(::SCRIPT_LINES__[file]) && lines = ::SCRIPT_LINES__[file]
|
152
144
|
code = ::SCRIPT_LINES__[file].join('')
|
@@ -173,8 +165,5 @@ EOF
|
|
173
165
|
|
174
166
|
"\nFrom: #{file} @ line #{pos + 1} :\n\n#{body}#{Color.clear}\n"
|
175
167
|
end
|
176
|
-
|
177
|
-
def IRB.delete_caller
|
178
|
-
end
|
179
168
|
end
|
180
169
|
end
|
data/lib/irb/ws-for-case-2.rb
CHANGED
data/lib/irb/xmp.rb
CHANGED
data/lib/irb.rb
CHANGED
@@ -1,14 +1,9 @@
|
|
1
1
|
# frozen_string_literal: false
|
2
2
|
#
|
3
3
|
# irb.rb - irb main module
|
4
|
-
# $Release Version: 0.9.6 $
|
5
|
-
# $Revision$
|
6
4
|
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
|
7
5
|
#
|
8
|
-
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
6
|
+
|
12
7
|
require "ripper"
|
13
8
|
require "reline"
|
14
9
|
|
@@ -468,12 +463,16 @@ module IRB
|
|
468
463
|
# be parsed as :assign and echo will be suppressed, but the latter is
|
469
464
|
# parsed as a :method_add_arg and the output won't be suppressed
|
470
465
|
|
466
|
+
PROMPT_MAIN_TRUNCATE_LENGTH = 32
|
467
|
+
PROMPT_MAIN_TRUNCATE_OMISSION = '...'.freeze
|
468
|
+
CONTROL_CHARACTERS_PATTERN = "\x00-\x1F".freeze
|
469
|
+
|
471
470
|
# Creates a new irb session
|
472
471
|
def initialize(workspace = nil, input_method = nil)
|
473
472
|
@context = Context.new(self, workspace, input_method)
|
474
473
|
@context.main.extend ExtendCommandBundle
|
475
474
|
@signal_status = :IN_IRB
|
476
|
-
@scanner = RubyLex.new
|
475
|
+
@scanner = RubyLex.new(@context)
|
477
476
|
end
|
478
477
|
|
479
478
|
# A hook point for `debug` command's TracePoint after :IRB_EXIT as well as its clean-up
|
@@ -543,7 +542,7 @@ module IRB
|
|
543
542
|
@context.io.prompt
|
544
543
|
end
|
545
544
|
|
546
|
-
@scanner.set_input(@context.io
|
545
|
+
@scanner.set_input(@context.io) do
|
547
546
|
signal_status(:IN_INPUT) do
|
548
547
|
if l = @context.io.gets
|
549
548
|
print l if @context.verbose?
|
@@ -561,9 +560,9 @@ module IRB
|
|
561
560
|
end
|
562
561
|
end
|
563
562
|
|
564
|
-
@scanner.set_auto_indent
|
563
|
+
@scanner.set_auto_indent
|
565
564
|
|
566
|
-
@scanner.each_top_level_statement
|
565
|
+
@scanner.each_top_level_statement do |line, line_no|
|
567
566
|
signal_status(:IN_EVAL) do
|
568
567
|
begin
|
569
568
|
line.untaint if RUBY_VERSION < '2.7'
|
@@ -780,6 +779,15 @@ module IRB
|
|
780
779
|
end
|
781
780
|
end
|
782
781
|
|
782
|
+
def truncate_prompt_main(str) # :nodoc:
|
783
|
+
str = str.tr(CONTROL_CHARACTERS_PATTERN, ' ')
|
784
|
+
if str.size <= PROMPT_MAIN_TRUNCATE_LENGTH
|
785
|
+
str
|
786
|
+
else
|
787
|
+
str[0, PROMPT_MAIN_TRUNCATE_LENGTH - PROMPT_MAIN_TRUNCATE_OMISSION.size] + PROMPT_MAIN_TRUNCATE_OMISSION
|
788
|
+
end
|
789
|
+
end
|
790
|
+
|
783
791
|
def prompt(prompt, ltype, indent, line_no) # :nodoc:
|
784
792
|
p = prompt.dup
|
785
793
|
p.gsub!(/%([0-9]+)?([a-zA-Z])/) do
|
@@ -787,9 +795,9 @@ module IRB
|
|
787
795
|
when "N"
|
788
796
|
@context.irb_name
|
789
797
|
when "m"
|
790
|
-
@context.main.to_s
|
798
|
+
truncate_prompt_main(@context.main.to_s)
|
791
799
|
when "M"
|
792
|
-
@context.main.inspect
|
800
|
+
truncate_prompt_main(@context.main.inspect)
|
793
801
|
when "l"
|
794
802
|
ltype
|
795
803
|
when "i"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: irb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.6.
|
4
|
+
version: 1.6.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- aycabta
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2023-03-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: reline
|
@@ -110,7 +110,11 @@ homepage: https://github.com/ruby/irb
|
|
110
110
|
licenses:
|
111
111
|
- Ruby
|
112
112
|
- BSD-2-Clause
|
113
|
-
metadata:
|
113
|
+
metadata:
|
114
|
+
homepage_uri: https://github.com/ruby/irb
|
115
|
+
source_code_uri: https://github.com/ruby/irb
|
116
|
+
documentation_uri: https://github.com/ruby/irb
|
117
|
+
changelog_uri: https://github.com/ruby/irb/releases
|
114
118
|
post_install_message:
|
115
119
|
rdoc_options: []
|
116
120
|
require_paths:
|
@@ -126,7 +130,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
126
130
|
- !ruby/object:Gem::Version
|
127
131
|
version: '0'
|
128
132
|
requirements: []
|
129
|
-
rubygems_version: 3.
|
133
|
+
rubygems_version: 3.4.1
|
130
134
|
signing_key:
|
131
135
|
specification_version: 4
|
132
136
|
summary: Interactive Ruby command-line tool for REPL (Read Eval Print Loop).
|