irb 1.3.8.pre.7 → 1.3.8.pre.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/doc/irb/irb.rd.ja +6 -0
- data/irb.gemspec +1 -1
- data/lib/irb/cmd/help.rb +2 -1
- data/lib/irb/completion.rb +45 -12
- data/lib/irb/context.rb +18 -1
- data/lib/irb/input-method.rb +34 -10
- data/lib/irb/lc/help-message +7 -1
- data/lib/irb/ruby-lex.rb +27 -11
- data/lib/irb/version.rb +2 -2
- data/lib/irb/workspace.rb +3 -0
- data/lib/irb.rb +11 -3
- data/man/irb.1 +11 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 11626f5579d5c88f1358bac49d6cfb81663193cf79b19b49e5958bf930fb61de
|
4
|
+
data.tar.gz: 75253829683f5dee7208b964abd7ae7924867bf910fcdbba9cd9fdf4a3848751
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b7faa90700c773424719934303c87ade13c38426c5a604425e9bf5921cb1e7234bd002f7179ecbe64597806b286acbff314e085e93ccb0b02ee69399bda59e77
|
7
|
+
data.tar.gz: 05b5f9834f71f15733c7541c66ad7a8ef32a38acdb2101d923db70810c47b4d82382ae187754eaf97931dbe0546b7767985c27a178e2883b5812638825fed376
|
data/doc/irb/irb.rd.ja
CHANGED
@@ -51,6 +51,12 @@ irbの使い方は, Rubyさえ知っていればいたって簡単です. 基本
|
|
51
51
|
オブジェクトの作成方法を 0 から 3 のいずれかに設定する.
|
52
52
|
--echo 実行結果を表示する(デフォルト).
|
53
53
|
--noecho 実行結果を表示しない.
|
54
|
+
--echo-on-assignment
|
55
|
+
代入時に実行結果を表示する.
|
56
|
+
--noecho-on-assignment
|
57
|
+
代入時に実行結果を表示しない.
|
58
|
+
--truncate-echo-on-assignment
|
59
|
+
代入時に省略された実行結果を表示する(デフォルト).
|
54
60
|
--inspect 結果出力にinspectを用いる.
|
55
61
|
--noinspect 結果出力にinspectを用いない.
|
56
62
|
--singleline シングルラインエディタを利用する.
|
data/irb.gemspec
CHANGED
data/lib/irb/cmd/help.rb
CHANGED
@@ -17,7 +17,8 @@ module IRB
|
|
17
17
|
class Help < Nop
|
18
18
|
def execute(*names)
|
19
19
|
require 'rdoc/ri/driver'
|
20
|
-
|
20
|
+
opts = RDoc::RI::Driver.process_args([])
|
21
|
+
IRB::ExtendCommand::Help.const_set(:Ri, RDoc::RI::Driver.new(opts))
|
21
22
|
rescue LoadError, SystemExit
|
22
23
|
IRB::ExtendCommand::Help.remove_method(:execute)
|
23
24
|
# raise NoMethodError in ensure
|
data/lib/irb/completion.rb
CHANGED
@@ -38,16 +38,48 @@ module IRB
|
|
38
38
|
|
39
39
|
BASIC_WORD_BREAK_CHARACTERS = " \t\n`><=;|&{("
|
40
40
|
|
41
|
-
def self.
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
41
|
+
def self.absolute_path?(p) # TODO Remove this method after 2.6 EOL.
|
42
|
+
if File.respond_to?(:absolute_path?)
|
43
|
+
File.absolute_path?(p)
|
44
|
+
else
|
45
|
+
if File.absolute_path(p) == p
|
46
|
+
true
|
47
|
+
else
|
48
|
+
false
|
47
49
|
end
|
48
|
-
|
49
|
-
|
50
|
-
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.retrieve_gem_and_system_load_path
|
54
|
+
gem_paths = Gem::Specification.latest_specs(true).map { |s|
|
55
|
+
s.require_paths.map { |p|
|
56
|
+
if absolute_path?(p)
|
57
|
+
p
|
58
|
+
else
|
59
|
+
File.join(s.full_gem_path, p)
|
60
|
+
end
|
61
|
+
}
|
62
|
+
}.flatten if defined?(Gem::Specification)
|
63
|
+
(gem_paths.to_a | $LOAD_PATH).sort
|
64
|
+
end
|
65
|
+
|
66
|
+
def self.retrieve_files_to_require_from_load_path
|
67
|
+
@@files_from_load_path ||=
|
68
|
+
(
|
69
|
+
shortest = []
|
70
|
+
rest = retrieve_gem_and_system_load_path.each_with_object([]) { |path, result|
|
71
|
+
begin
|
72
|
+
names = Dir.glob("**/*.{rb,#{RbConfig::CONFIG['DLEXT']}}", base: path)
|
73
|
+
rescue Errno::ENOENT
|
74
|
+
nil
|
75
|
+
end
|
76
|
+
next if names.empty?
|
77
|
+
names.map! { |n| n.sub(/\.(rb|#{RbConfig::CONFIG['DLEXT']})\z/, '') }.sort!
|
78
|
+
shortest << names.shift
|
79
|
+
result.concat(names)
|
80
|
+
}
|
81
|
+
shortest.sort! | rest
|
82
|
+
)
|
51
83
|
end
|
52
84
|
|
53
85
|
def self.retrieve_files_to_require_relative_from_current_dir
|
@@ -160,7 +192,7 @@ module IRB
|
|
160
192
|
sym = $1
|
161
193
|
candidates = Symbol.all_symbols.collect do |s|
|
162
194
|
":" + s.id2name.encode(Encoding.default_external)
|
163
|
-
rescue
|
195
|
+
rescue EncodingError
|
164
196
|
# ignore
|
165
197
|
end
|
166
198
|
candidates.grep(/^#{Regexp.quote(sym)}/)
|
@@ -258,7 +290,7 @@ module IRB
|
|
258
290
|
all_gvars.grep(Regexp.new(Regexp.quote(gvar)))
|
259
291
|
end
|
260
292
|
|
261
|
-
when /^([
|
293
|
+
when /^([^.:"].*)(\.|::)([^.]*)$/
|
262
294
|
# variable.func or func.func
|
263
295
|
receiver = $1
|
264
296
|
sep = $2
|
@@ -296,7 +328,8 @@ module IRB
|
|
296
328
|
candidates.uniq!
|
297
329
|
end
|
298
330
|
if doc_namespace
|
299
|
-
|
331
|
+
rec_class = rec.is_a?(Module) ? rec : rec.class
|
332
|
+
"#{rec_class.name}#{sep}#{candidates.find{ |i| i == message }}"
|
300
333
|
else
|
301
334
|
select_message(receiver, message, candidates, sep)
|
302
335
|
end
|
data/lib/irb/context.rb
CHANGED
@@ -264,13 +264,28 @@ module IRB
|
|
264
264
|
#
|
265
265
|
# a = "omg"
|
266
266
|
# #=> omg
|
267
|
+
#
|
267
268
|
# a = "omg" * 10
|
268
269
|
# #=> omgomgomgomgomgomgomg...
|
270
|
+
#
|
269
271
|
# IRB.CurrentContext.echo_on_assignment = false
|
270
272
|
# a = "omg"
|
273
|
+
#
|
271
274
|
# IRB.CurrentContext.echo_on_assignment = true
|
272
|
-
# a = "omg"
|
275
|
+
# a = "omg" * 10
|
273
276
|
# #=> omgomgomgomgomgomgomgomgomgomg
|
277
|
+
#
|
278
|
+
# To set the behaviour of showing on assignment in irb:
|
279
|
+
#
|
280
|
+
# IRB.conf[:ECHO_ON_ASSIGNMENT] = :truncate or true or false
|
281
|
+
#
|
282
|
+
# or
|
283
|
+
#
|
284
|
+
# irb_context.echo_on_assignment = :truncate or true or false
|
285
|
+
#
|
286
|
+
# or
|
287
|
+
#
|
288
|
+
# IRB.CurrentContext.echo_on_assignment = :truncate or true or false
|
274
289
|
attr_accessor :echo_on_assignment
|
275
290
|
# Whether a newline is put before multiline output.
|
276
291
|
#
|
@@ -463,6 +478,8 @@ module IRB
|
|
463
478
|
# Exits the current session, see IRB.irb_exit
|
464
479
|
def exit(ret = 0)
|
465
480
|
IRB.irb_exit(@irb, ret)
|
481
|
+
rescue UncaughtThrowError
|
482
|
+
super
|
466
483
|
end
|
467
484
|
|
468
485
|
NOPRINTING_IVARS = ["@last_value"] # :nodoc:
|
data/lib/irb/input-method.rb
CHANGED
@@ -265,7 +265,8 @@ module IRB
|
|
265
265
|
|
266
266
|
class ReidlineInputMethod < InputMethod
|
267
267
|
include Reline
|
268
|
-
|
268
|
+
|
269
|
+
# Creates a new input method object using Reline
|
269
270
|
def initialize
|
270
271
|
IRB.__send__(:set_encoding, Reline.encoding_system_needs.name, override: false)
|
271
272
|
super
|
@@ -315,12 +316,10 @@ module IRB
|
|
315
316
|
|
316
317
|
SHOW_DOC_DIALOG = ->() {
|
317
318
|
dialog.trap_key = nil
|
318
|
-
alt_d =
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
return nil
|
323
|
-
end
|
319
|
+
alt_d = [
|
320
|
+
[Reline::Key.new(nil, 0xE4, true)], # Normal Alt+d.
|
321
|
+
[195, 164] # The "ä" that appears when Alt+d is pressed on xterm.
|
322
|
+
]
|
324
323
|
|
325
324
|
if just_cursor_moving and completion_journey_data.nil?
|
326
325
|
return nil
|
@@ -332,7 +331,7 @@ module IRB
|
|
332
331
|
|
333
332
|
driver = RDoc::RI::Driver.new
|
334
333
|
|
335
|
-
if key.match?(
|
334
|
+
if key.match?(dialog.name)
|
336
335
|
begin
|
337
336
|
driver.display_names([name])
|
338
337
|
rescue RDoc::RI::Driver::NotFoundError
|
@@ -367,14 +366,39 @@ module IRB
|
|
367
366
|
end
|
368
367
|
return nil if doc.nil?
|
369
368
|
width = 40
|
369
|
+
|
370
|
+
right_x = cursor_pos_to_render.x + autocomplete_dialog.width
|
371
|
+
if right_x + width > screen_width
|
372
|
+
right_width = screen_width - (right_x + 1)
|
373
|
+
left_x = autocomplete_dialog.column - width
|
374
|
+
left_x = 0 if left_x < 0
|
375
|
+
left_width = width > autocomplete_dialog.column ? autocomplete_dialog.column : width
|
376
|
+
if right_width.positive? and left_width.positive?
|
377
|
+
if right_width >= left_width
|
378
|
+
width = right_width
|
379
|
+
x = right_x
|
380
|
+
else
|
381
|
+
width = left_width
|
382
|
+
x = left_x
|
383
|
+
end
|
384
|
+
elsif right_width.positive? and left_width <= 0
|
385
|
+
width = right_width
|
386
|
+
x = right_x
|
387
|
+
elsif right_width <= 0 and left_width.positive?
|
388
|
+
width = left_width
|
389
|
+
x = left_x
|
390
|
+
else # Both are negative width.
|
391
|
+
return nil
|
392
|
+
end
|
393
|
+
else
|
394
|
+
x = right_x
|
395
|
+
end
|
370
396
|
formatter = RDoc::Markup::ToAnsi.new
|
371
397
|
formatter.width = width
|
372
398
|
dialog.trap_key = alt_d
|
373
399
|
message = 'Press Alt+d to read the full document'
|
374
400
|
contents = [message] + doc.accept(formatter).split("\n")
|
375
401
|
|
376
|
-
x = cursor_pos_to_render.x + autocomplete_dialog.width
|
377
|
-
x = autocomplete_dialog.column - width if x + width >= screen_width
|
378
402
|
y = cursor_pos_to_render.y
|
379
403
|
DialogRenderInfo.new(pos: Reline::CursorPos.new(x, y), contents: contents, width: width, bg_color: '49')
|
380
404
|
}
|
data/lib/irb/lc/help-message
CHANGED
@@ -20,8 +20,14 @@ Usage: irb.rb [options] [programfile] [arguments]
|
|
20
20
|
-W[level=2] Same as `ruby -W`
|
21
21
|
--context-mode n Set n[0-4] to method to create Binding Object,
|
22
22
|
when new workspace was created
|
23
|
-
--echo Show result(default)
|
23
|
+
--echo Show result (default)
|
24
24
|
--noecho Don't show result
|
25
|
+
--echo-on-assignment
|
26
|
+
Show result on assignment
|
27
|
+
--noecho-on-assignment
|
28
|
+
Don't show result on assignment
|
29
|
+
--truncate-echo-on-assignment
|
30
|
+
Show truncated result on assignment (default)
|
25
31
|
--inspect Use `inspect' for output
|
26
32
|
--noinspect Don't use inspect for output
|
27
33
|
--multiline Use multiline editor module
|
data/lib/irb/ruby-lex.rb
CHANGED
@@ -207,7 +207,7 @@ class RubyLex
|
|
207
207
|
last_line = lines[line_index]&.byteslice(0, byte_pointer)
|
208
208
|
code += last_line if last_line
|
209
209
|
@tokens = self.class.ripper_lex_without_warning(code, context: context)
|
210
|
-
corresponding_token_depth = check_corresponding_token_depth
|
210
|
+
corresponding_token_depth = check_corresponding_token_depth(lines, line_index)
|
211
211
|
if corresponding_token_depth
|
212
212
|
corresponding_token_depth
|
213
213
|
else
|
@@ -477,7 +477,7 @@ class RubyLex
|
|
477
477
|
|
478
478
|
def take_corresponding_syntax_to_kw_do(tokens, index)
|
479
479
|
syntax_of_do = nil
|
480
|
-
# Finding a syntax
|
480
|
+
# Finding a syntax corresponding to "do".
|
481
481
|
index.downto(0) do |i|
|
482
482
|
tk = tokens[i]
|
483
483
|
# In "continue", the token isn't the corresponding syntax to "do".
|
@@ -508,7 +508,7 @@ class RubyLex
|
|
508
508
|
|
509
509
|
def is_the_in_correspond_to_a_for(tokens, index)
|
510
510
|
syntax_of_in = nil
|
511
|
-
# Finding a syntax
|
511
|
+
# Finding a syntax corresponding to "do".
|
512
512
|
index.downto(0) do |i|
|
513
513
|
tk = tokens[i]
|
514
514
|
# In "continue", the token isn't the corresponding syntax to "do".
|
@@ -603,7 +603,7 @@ class RubyLex
|
|
603
603
|
depth_difference
|
604
604
|
end
|
605
605
|
|
606
|
-
def check_corresponding_token_depth
|
606
|
+
def check_corresponding_token_depth(lines, line_index)
|
607
607
|
corresponding_token_depth = nil
|
608
608
|
is_first_spaces_of_line = true
|
609
609
|
is_first_printable_of_line = true
|
@@ -611,6 +611,11 @@ class RubyLex
|
|
611
611
|
spaces_at_line_head = 0
|
612
612
|
open_brace_on_line = 0
|
613
613
|
in_oneliner_def = nil
|
614
|
+
|
615
|
+
if heredoc_scope?
|
616
|
+
return lines[line_index][/^ */].length
|
617
|
+
end
|
618
|
+
|
614
619
|
@tokens.each_with_index do |t, index|
|
615
620
|
# detecting one-liner method definition
|
616
621
|
if in_oneliner_def.nil?
|
@@ -708,6 +713,9 @@ class RubyLex
|
|
708
713
|
while i < tokens.size
|
709
714
|
t = tokens[i]
|
710
715
|
case t[1]
|
716
|
+
when *end_type.last
|
717
|
+
start_token.pop
|
718
|
+
end_type.pop
|
711
719
|
when :on_tstring_beg
|
712
720
|
start_token << t
|
713
721
|
end_type << [:on_tstring_end, :on_label_end]
|
@@ -715,10 +723,14 @@ class RubyLex
|
|
715
723
|
start_token << t
|
716
724
|
end_type << :on_regexp_end
|
717
725
|
when :on_symbeg
|
718
|
-
acceptable_single_tokens = %i{on_ident on_const on_op on_cvar on_ivar on_gvar on_kw on_int}
|
719
|
-
if (i + 1) < tokens.size
|
720
|
-
|
721
|
-
|
726
|
+
acceptable_single_tokens = %i{on_ident on_const on_op on_cvar on_ivar on_gvar on_kw on_int on_backtick}
|
727
|
+
if (i + 1) < tokens.size
|
728
|
+
if acceptable_single_tokens.all?{ |st| tokens[i + 1][1] != st }
|
729
|
+
start_token << t
|
730
|
+
end_type << :on_tstring_end
|
731
|
+
else
|
732
|
+
i += 1
|
733
|
+
end
|
722
734
|
end
|
723
735
|
when :on_backtick
|
724
736
|
start_token << t
|
@@ -729,9 +741,6 @@ class RubyLex
|
|
729
741
|
when :on_heredoc_beg
|
730
742
|
start_token << t
|
731
743
|
end_type << :on_heredoc_end
|
732
|
-
when *end_type.last
|
733
|
-
start_token.pop
|
734
|
-
end_type.pop
|
735
744
|
end
|
736
745
|
i += 1
|
737
746
|
end
|
@@ -813,5 +822,12 @@ class RubyLex
|
|
813
822
|
end
|
814
823
|
false
|
815
824
|
end
|
825
|
+
|
826
|
+
private
|
827
|
+
|
828
|
+
def heredoc_scope?
|
829
|
+
heredoc_tokens = @tokens.select { |t| [:on_heredoc_beg, :on_heredoc_end].include?(t.event) }
|
830
|
+
heredoc_tokens[-1]&.event == :on_heredoc_beg
|
831
|
+
end
|
816
832
|
end
|
817
833
|
# :startdoc:
|
data/lib/irb/version.rb
CHANGED
data/lib/irb/workspace.rb
CHANGED
@@ -12,6 +12,7 @@
|
|
12
12
|
|
13
13
|
require "delegate"
|
14
14
|
|
15
|
+
IRB::TOPLEVEL_BINDING = binding
|
15
16
|
module IRB # :nodoc:
|
16
17
|
class WorkSpace
|
17
18
|
# Creates a new workspace.
|
@@ -57,6 +58,8 @@ EOF
|
|
57
58
|
__FILE__,
|
58
59
|
__LINE__ - 3)
|
59
60
|
when 4 # binding is a copy of TOPLEVEL_BINDING (default)
|
61
|
+
# Note that this will typically be IRB::TOPLEVEL_BINDING
|
62
|
+
# This is to avoid RubyGems' local variables (see issue #17623)
|
60
63
|
@binding = TOPLEVEL_BINDING.dup
|
61
64
|
end
|
62
65
|
end
|
data/lib/irb.rb
CHANGED
@@ -62,8 +62,14 @@ require_relative "irb/easter-egg"
|
|
62
62
|
# -W[level=2] Same as `ruby -W`
|
63
63
|
# --context-mode n Set n[0-4] to method to create Binding Object,
|
64
64
|
# when new workspace was created
|
65
|
-
# --echo Show result(default)
|
65
|
+
# --echo Show result (default)
|
66
66
|
# --noecho Don't show result
|
67
|
+
# --echo-on-assignment
|
68
|
+
# Show result on assignment
|
69
|
+
# --noecho-on-assignment
|
70
|
+
# Don't show result on assignment
|
71
|
+
# --truncate-echo-on-assignment
|
72
|
+
# Show truncated result on assignment (default)
|
67
73
|
# --inspect Use `inspect' for output
|
68
74
|
# --noinspect Don't use inspect for output
|
69
75
|
# --multiline Use multiline editor module
|
@@ -607,7 +613,7 @@ module IRB
|
|
607
613
|
ret = conv.primitive_convert(str, dst)
|
608
614
|
case ret
|
609
615
|
when :invalid_byte_sequence
|
610
|
-
conv.insert_output(
|
616
|
+
conv.insert_output(conv.primitive_errinfo[3].dump[1..-2])
|
611
617
|
redo
|
612
618
|
when :undefined_conversion
|
613
619
|
c = conv.primitive_errinfo[3].dup.force_encoding(conv.primitive_errinfo[1])
|
@@ -669,6 +675,8 @@ module IRB
|
|
669
675
|
lines = lines.reverse if order == :bottom
|
670
676
|
lines.map{ |l| l + "\n" }.join
|
671
677
|
}
|
678
|
+
# The "<top (required)>" in "(irb)" may be the top level of IRB so imitate the main object.
|
679
|
+
message = message.gsub(/\(irb\):(?<num>\d+):in `<(?<frame>top \(required\))>'/) { "(irb):#{$~[:num]}:in `<main>'" }
|
672
680
|
puts message
|
673
681
|
end
|
674
682
|
print "Maybe IRB bug!\n" if irb_bug
|
@@ -859,7 +867,7 @@ module IRB
|
|
859
867
|
|
860
868
|
# If the expression is invalid, Ripper.sexp should return nil which will
|
861
869
|
# result in false being returned. Any valid expression should return an
|
862
|
-
# s-expression where the second
|
870
|
+
# s-expression where the second element of the top level array is an
|
863
871
|
# array of parsed expressions. The first element of each expression is the
|
864
872
|
# expression's type.
|
865
873
|
verbose, $VERBOSE = $VERBOSE, nil
|
data/man/irb.1
CHANGED
@@ -106,12 +106,22 @@ Doesn't use singleline editor module.
|
|
106
106
|
.Pp
|
107
107
|
.Pp
|
108
108
|
.It Fl -echo
|
109
|
-
Show result(default).
|
109
|
+
Show result (default).
|
110
110
|
.Pp
|
111
111
|
.It Fl -noecho
|
112
112
|
Don't show result.
|
113
113
|
.Pp
|
114
114
|
.Pp
|
115
|
+
.It Fl -echo-on-assignment
|
116
|
+
Show result on assignment.
|
117
|
+
.Pp
|
118
|
+
.It Fl -noecho-on-assignment
|
119
|
+
Don't show result on assignment.
|
120
|
+
.Pp
|
121
|
+
.It Fl -truncate-echo-on-assignment
|
122
|
+
Show truncated result on assignment (default).
|
123
|
+
.Pp
|
124
|
+
.Pp
|
115
125
|
.It Fl -colorize
|
116
126
|
Use colorization.
|
117
127
|
.Pp
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: irb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.8.pre.
|
4
|
+
version: 1.3.8.pre.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Keiju ISHITSUKA
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-09
|
11
|
+
date: 2021-10-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: reline
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.2.8.pre.
|
19
|
+
version: 0.2.8.pre.11
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.2.8.pre.
|
26
|
+
version: 0.2.8.pre.11
|
27
27
|
description: Interactive Ruby command-line tool for REPL (Read Eval Print Loop).
|
28
28
|
email:
|
29
29
|
- keiju@ruby-lang.org
|