irb 1.3.8.pre.5 → 1.3.8.pre.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/irb.gemspec +1 -1
- data/lib/irb/cmd/help.rb +2 -1
- data/lib/irb/completion.rb +45 -9
- data/lib/irb/input-method.rb +19 -3
- data/lib/irb/ruby-lex.rb +11 -7
- data/lib/irb/version.rb +2 -2
- data/lib/irb/workspace.rb +3 -0
- data/lib/irb.rb +2 -0
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dc37bc2cdd7bf77d09704fb22c31aec464fc7aa391f2bc6a6619d8549bd0cd5d
|
4
|
+
data.tar.gz: 20b8157c7167ccf5b30fef3d4b8340c3d1a316a59c742c968d0e62e0bd5010d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9783aa13399d0eddb2e67cf3aa51760cfde1cc76f7b59d78158e83746359511e46824034d29f07181ffc91a51901bb6202562b8eab950649c0082f58295809d0
|
7
|
+
data.tar.gz: f2a27869c90d81a93497515c38da52c0e19c113a308c95c264b863fb8edc9e1f96f558343bbe4bfe47b6a527ce4eaa98757380b700626d9f445f12b994b296d2
|
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,44 @@ module IRB
|
|
38
38
|
|
39
39
|
BASIC_WORD_BREAK_CHARACTERS = " \t\n`><=;|&{("
|
40
40
|
|
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
|
49
|
+
end
|
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
|
63
|
+
(gem_paths + $LOAD_PATH).uniq.sort
|
64
|
+
end
|
65
|
+
|
41
66
|
def self.retrieve_files_to_require_from_load_path
|
42
|
-
@@files_from_load_path ||=
|
67
|
+
@@files_from_load_path ||= retrieve_gem_and_system_load_path.map { |path|
|
43
68
|
begin
|
44
69
|
Dir.glob("**/*.{rb,#{RbConfig::CONFIG['DLEXT']}}", base: path)
|
45
70
|
rescue Errno::ENOENT
|
46
71
|
[]
|
47
72
|
end
|
48
|
-
}.
|
49
|
-
|
50
|
-
|
73
|
+
}.inject([]) { |result, names|
|
74
|
+
shortest, *rest = names.map{ |n| n.sub(/\.(rb|#{RbConfig::CONFIG['DLEXT']})\z/, '') }.sort
|
75
|
+
result.unshift(shortest) if shortest
|
76
|
+
result.concat(rest)
|
77
|
+
result
|
78
|
+
}.uniq
|
51
79
|
end
|
52
80
|
|
53
81
|
def self.retrieve_files_to_require_relative_from_current_dir
|
@@ -296,7 +324,8 @@ module IRB
|
|
296
324
|
candidates.uniq!
|
297
325
|
end
|
298
326
|
if doc_namespace
|
299
|
-
|
327
|
+
rec_class = rec.is_a?(Module) ? rec : rec.class
|
328
|
+
"#{rec_class.name}#{sep}#{candidates.find{ |i| i == message }}"
|
300
329
|
else
|
301
330
|
select_message(receiver, message, candidates, sep)
|
302
331
|
end
|
@@ -315,12 +344,19 @@ module IRB
|
|
315
344
|
end
|
316
345
|
|
317
346
|
else
|
318
|
-
candidates = eval("methods | private_methods | local_variables | instance_variables | self.class.constants", bind).collect{|m| m.to_s}
|
319
|
-
candidates |= ReservedWords
|
320
|
-
|
321
347
|
if doc_namespace
|
322
|
-
|
348
|
+
vars = eval("local_variables | instance_variables", bind).collect{|m| m.to_s}
|
349
|
+
perfect_match_var = vars.find{|m| m.to_s == input}
|
350
|
+
if perfect_match_var
|
351
|
+
eval("#{perfect_match_var}.class.name", bind)
|
352
|
+
else
|
353
|
+
candidates = eval("methods | private_methods | local_variables | instance_variables | self.class.constants", bind).collect{|m| m.to_s}
|
354
|
+
candidates |= ReservedWords
|
355
|
+
candidates.find{ |i| i == input }
|
356
|
+
end
|
323
357
|
else
|
358
|
+
candidates = eval("methods | private_methods | local_variables | instance_variables | self.class.constants", bind).collect{|m| m.to_s}
|
359
|
+
candidates |= ReservedWords
|
324
360
|
candidates.grep(/^#{Regexp.quote(input)}/)
|
325
361
|
end
|
326
362
|
end
|
data/lib/irb/input-method.rb
CHANGED
@@ -314,11 +314,17 @@ module IRB
|
|
314
314
|
end
|
315
315
|
|
316
316
|
SHOW_DOC_DIALOG = ->() {
|
317
|
+
dialog.trap_key = nil
|
318
|
+
alt_d = [
|
319
|
+
[Reline::Key.new(nil, 0xE4, true)], # Normal Alt+d.
|
320
|
+
[195, 164] # The "ä" that appears when Alt+d is pressed on xterm.
|
321
|
+
]
|
317
322
|
begin
|
318
323
|
require 'rdoc'
|
319
324
|
rescue LoadError
|
320
325
|
return nil
|
321
326
|
end
|
327
|
+
|
322
328
|
if just_cursor_moving and completion_journey_data.nil?
|
323
329
|
return nil
|
324
330
|
end
|
@@ -328,6 +334,14 @@ module IRB
|
|
328
334
|
name = IRB::InputCompletor.retrieve_completion_data(name, doc_namespace: true)
|
329
335
|
|
330
336
|
driver = RDoc::RI::Driver.new
|
337
|
+
|
338
|
+
if key.match?(dialog.name)
|
339
|
+
begin
|
340
|
+
driver.display_names([name])
|
341
|
+
rescue RDoc::RI::Driver::NotFoundError
|
342
|
+
end
|
343
|
+
end
|
344
|
+
|
331
345
|
begin
|
332
346
|
name = driver.expand_name(name)
|
333
347
|
rescue RDoc::RI::Driver::NotFoundError
|
@@ -358,11 +372,13 @@ module IRB
|
|
358
372
|
width = 40
|
359
373
|
formatter = RDoc::Markup::ToAnsi.new
|
360
374
|
formatter.width = width
|
361
|
-
|
375
|
+
dialog.trap_key = alt_d
|
376
|
+
message = 'Press Alt+d to read the full document'
|
377
|
+
contents = [message] + doc.accept(formatter).split("\n")
|
362
378
|
|
363
379
|
x = cursor_pos_to_render.x + autocomplete_dialog.width
|
364
|
-
x =
|
365
|
-
y = cursor_pos_to_render.y
|
380
|
+
x = autocomplete_dialog.column - width if x + width >= screen_width
|
381
|
+
y = cursor_pos_to_render.y
|
366
382
|
DialogRenderInfo.new(pos: Reline::CursorPos.new(x, y), contents: contents, width: width, bg_color: '49')
|
367
383
|
}
|
368
384
|
|
data/lib/irb/ruby-lex.rb
CHANGED
@@ -708,6 +708,9 @@ class RubyLex
|
|
708
708
|
while i < tokens.size
|
709
709
|
t = tokens[i]
|
710
710
|
case t[1]
|
711
|
+
when *end_type.last
|
712
|
+
start_token.pop
|
713
|
+
end_type.pop
|
711
714
|
when :on_tstring_beg
|
712
715
|
start_token << t
|
713
716
|
end_type << [:on_tstring_end, :on_label_end]
|
@@ -715,10 +718,14 @@ class RubyLex
|
|
715
718
|
start_token << t
|
716
719
|
end_type << :on_regexp_end
|
717
720
|
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
|
-
|
721
|
+
acceptable_single_tokens = %i{on_ident on_const on_op on_cvar on_ivar on_gvar on_kw on_int on_backtick}
|
722
|
+
if (i + 1) < tokens.size
|
723
|
+
if acceptable_single_tokens.all?{ |st| tokens[i + 1][1] != st }
|
724
|
+
start_token << t
|
725
|
+
end_type << :on_tstring_end
|
726
|
+
else
|
727
|
+
i += 1
|
728
|
+
end
|
722
729
|
end
|
723
730
|
when :on_backtick
|
724
731
|
start_token << t
|
@@ -729,9 +736,6 @@ class RubyLex
|
|
729
736
|
when :on_heredoc_beg
|
730
737
|
start_token << t
|
731
738
|
end_type << :on_heredoc_end
|
732
|
-
when *end_type.last
|
733
|
-
start_token.pop
|
734
|
-
end_type.pop
|
735
739
|
end
|
736
740
|
i += 1
|
737
741
|
end
|
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
@@ -669,6 +669,8 @@ module IRB
|
|
669
669
|
lines = lines.reverse if order == :bottom
|
670
670
|
lines.map{ |l| l + "\n" }.join
|
671
671
|
}
|
672
|
+
# The "<top (required)>" in "(irb)" may be the top level of IRB so imitate the main object.
|
673
|
+
message = message.gsub(/\(irb\):(?<num>\d+):in `<(?<frame>top \(required\))>'/) { "(irb):#{$~[:num]}:in `<main>'" }
|
672
674
|
puts message
|
673
675
|
end
|
674
676
|
print "Maybe IRB bug!\n" if irb_bug
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
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.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Keiju ISHITSUKA
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-09-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: reline
|
15
|
+
prerelease: false
|
15
16
|
requirement: !ruby/object:Gem::Requirement
|
16
17
|
requirements:
|
17
18
|
- - ">="
|
18
19
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.2.8.pre.
|
20
|
+
version: 0.2.8.pre.9
|
20
21
|
type: :runtime
|
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.9
|
27
27
|
description: Interactive Ruby command-line tool for REPL (Read Eval Print Loop).
|
28
28
|
email:
|
29
29
|
- keiju@ruby-lang.org
|
@@ -97,7 +97,7 @@ licenses:
|
|
97
97
|
- Ruby
|
98
98
|
- BSD-2-Clause
|
99
99
|
metadata: {}
|
100
|
-
post_install_message:
|
100
|
+
post_install_message:
|
101
101
|
rdoc_options: []
|
102
102
|
require_paths:
|
103
103
|
- lib
|
@@ -112,8 +112,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
112
112
|
- !ruby/object:Gem::Version
|
113
113
|
version: 1.3.1
|
114
114
|
requirements: []
|
115
|
-
rubygems_version: 3.
|
116
|
-
signing_key:
|
115
|
+
rubygems_version: 3.1.4
|
116
|
+
signing_key:
|
117
117
|
specification_version: 4
|
118
118
|
summary: Interactive Ruby command-line tool for REPL (Read Eval Print Loop).
|
119
119
|
test_files: []
|