irb 1.13.0 → 1.13.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/irb/command/base.rb +2 -2
- data/lib/irb/command/debug.rb +1 -16
- data/lib/irb/command/help.rb +16 -8
- data/lib/irb/context.rb +11 -2
- data/lib/irb/helper_method/conf.rb +1 -1
- data/lib/irb/input-method.rb +1 -0
- data/lib/irb/version.rb +2 -2
- data/lib/irb.rb +10 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b57e45ef4cb7d58489abeda8131ed81a1625b05fd139e00082bf3011fc0c2fdc
|
4
|
+
data.tar.gz: 411b92eee70de798e94c0c9c30801467cdf240a43eff4da9e46230374fa8504f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0919ac233b97abb80a9d34cad9be792e85bce261cc4c29c36eac8d7ba81bd99c4592b5b8c1bdbdc7e96d778ccf20b5374987eef0224e9fb6583639633e3c2bb0'
|
7
|
+
data.tar.gz: 89dad0bbdebdee60a3f08ca2cf918293bffac4db7b183a45ab93f6cc4906ca7a62437286a08291ba76fae8e2bba31f3b6a28be3cd13a141f451a5c4e1b09041d
|
data/lib/irb/command/base.rb
CHANGED
@@ -18,12 +18,12 @@ module IRB
|
|
18
18
|
class << self
|
19
19
|
def category(category = nil)
|
20
20
|
@category = category if category
|
21
|
-
@category
|
21
|
+
@category || "No category"
|
22
22
|
end
|
23
23
|
|
24
24
|
def description(description = nil)
|
25
25
|
@description = description if description
|
26
|
-
@description
|
26
|
+
@description || "No description provided."
|
27
27
|
end
|
28
28
|
|
29
29
|
def help_message(help_message = nil)
|
data/lib/irb/command/debug.rb
CHANGED
@@ -8,11 +8,6 @@ module IRB
|
|
8
8
|
category "Debugging"
|
9
9
|
description "Start the debugger of debug.gem."
|
10
10
|
|
11
|
-
BINDING_IRB_FRAME_REGEXPS = [
|
12
|
-
'<internal:prelude>',
|
13
|
-
binding.method(:irb).source_location.first,
|
14
|
-
].map { |file| /\A#{Regexp.escape(file)}:\d+:in (`|'Binding#)irb'\z/ }
|
15
|
-
|
16
11
|
def execute(_arg)
|
17
12
|
execute_debug_command
|
18
13
|
end
|
@@ -36,7 +31,7 @@ module IRB
|
|
36
31
|
# 3. Insert a debug breakpoint at `Irb#debug_break` with the intended command.
|
37
32
|
# 4. Exit the current Irb#run call via `throw :IRB_EXIT`.
|
38
33
|
# 5. `Irb#debug_break` will be called and trigger the breakpoint, which will run the intended command.
|
39
|
-
unless
|
34
|
+
unless irb_context.from_binding?
|
40
35
|
puts "Debugging commands are only available when IRB is started with binding.irb"
|
41
36
|
return
|
42
37
|
end
|
@@ -60,16 +55,6 @@ module IRB
|
|
60
55
|
throw :IRB_EXIT
|
61
56
|
end
|
62
57
|
end
|
63
|
-
|
64
|
-
private
|
65
|
-
|
66
|
-
def binding_irb?
|
67
|
-
caller.any? do |frame|
|
68
|
-
BINDING_IRB_FRAME_REGEXPS.any? do |regexp|
|
69
|
-
frame.match?(regexp)
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
58
|
end
|
74
59
|
|
75
60
|
class DebugCommand < Debug
|
data/lib/irb/command/help.rb
CHANGED
@@ -28,17 +28,9 @@ module IRB
|
|
28
28
|
commands_grouped_by_categories = commands_info.group_by { |cmd| cmd[:category] }
|
29
29
|
commands_grouped_by_categories["Helper methods"] = helper_methods_info
|
30
30
|
|
31
|
-
user_aliases = irb_context.instance_variable_get(:@user_aliases)
|
32
|
-
|
33
|
-
commands_grouped_by_categories["Aliases"] = user_aliases.map do |alias_name, target|
|
34
|
-
{ display_name: alias_name, description: "Alias for `#{target}`" }
|
35
|
-
end
|
36
|
-
|
37
31
|
if irb_context.with_debugger
|
38
32
|
# Remove the original "Debugging" category
|
39
33
|
commands_grouped_by_categories.delete("Debugging")
|
40
|
-
# Add an empty "Debugging (from debug.gem)" category at the end
|
41
|
-
commands_grouped_by_categories["Debugging (from debug.gem)"] = []
|
42
34
|
end
|
43
35
|
|
44
36
|
longest_cmd_name_length = commands_info.map { |c| c[:display_name].length }.max
|
@@ -46,15 +38,31 @@ module IRB
|
|
46
38
|
output = StringIO.new
|
47
39
|
|
48
40
|
help_cmds = commands_grouped_by_categories.delete("Help")
|
41
|
+
no_category_cmds = commands_grouped_by_categories.delete("No category")
|
42
|
+
aliases = irb_context.instance_variable_get(:@user_aliases).map do |alias_name, target|
|
43
|
+
{ display_name: alias_name, description: "Alias for `#{target}`" }
|
44
|
+
end
|
49
45
|
|
46
|
+
# Display help commands first
|
50
47
|
add_category_to_output("Help", help_cmds, output, longest_cmd_name_length)
|
51
48
|
|
49
|
+
# Display the rest of the commands grouped by categories
|
52
50
|
commands_grouped_by_categories.each do |category, cmds|
|
53
51
|
add_category_to_output(category, cmds, output, longest_cmd_name_length)
|
54
52
|
end
|
55
53
|
|
54
|
+
# Display commands without a category
|
55
|
+
if no_category_cmds
|
56
|
+
add_category_to_output("No category", no_category_cmds, output, longest_cmd_name_length)
|
57
|
+
end
|
58
|
+
|
59
|
+
# Display aliases
|
60
|
+
add_category_to_output("Aliases", aliases, output, longest_cmd_name_length)
|
61
|
+
|
56
62
|
# Append the debugger help at the end
|
57
63
|
if irb_context.with_debugger
|
64
|
+
# Add "Debugging (from debug.gem)" category as title
|
65
|
+
add_category_to_output("Debugging (from debug.gem)", [], output, longest_cmd_name_length)
|
58
66
|
output.puts DEBUGGER__.help
|
59
67
|
end
|
60
68
|
|
data/lib/irb/context.rb
CHANGED
@@ -85,7 +85,7 @@ module IRB
|
|
85
85
|
@io = nil
|
86
86
|
case use_multiline?
|
87
87
|
when nil
|
88
|
-
if
|
88
|
+
if term_interactive? && IRB.conf[:PROMPT_MODE] != :INF_RUBY && !use_singleline?
|
89
89
|
# Both of multiline mode and singleline mode aren't specified.
|
90
90
|
@io = RelineInputMethod.new(build_completor)
|
91
91
|
else
|
@@ -99,7 +99,7 @@ module IRB
|
|
99
99
|
unless @io
|
100
100
|
case use_singleline?
|
101
101
|
when nil
|
102
|
-
if (defined?(ReadlineInputMethod) &&
|
102
|
+
if (defined?(ReadlineInputMethod) && term_interactive? &&
|
103
103
|
IRB.conf[:PROMPT_MODE] != :INF_RUBY)
|
104
104
|
@io = ReadlineInputMethod.new
|
105
105
|
else
|
@@ -151,6 +151,11 @@ module IRB
|
|
151
151
|
@command_aliases = @user_aliases.merge(KEYWORD_ALIASES)
|
152
152
|
end
|
153
153
|
|
154
|
+
private def term_interactive?
|
155
|
+
return true if ENV['TEST_IRB_FORCE_INTERACTIVE']
|
156
|
+
STDIN.tty? && ENV['TERM'] != 'dumb'
|
157
|
+
end
|
158
|
+
|
154
159
|
# because all input will eventually be evaluated as Ruby code,
|
155
160
|
# command names that conflict with Ruby keywords need special workaround
|
156
161
|
# we can remove them once we implemented a better command system for IRB
|
@@ -602,6 +607,10 @@ module IRB
|
|
602
607
|
nil
|
603
608
|
end
|
604
609
|
|
610
|
+
def from_binding?
|
611
|
+
@irb.from_binding
|
612
|
+
end
|
613
|
+
|
605
614
|
def evaluate_expression(code, line_no) # :nodoc:
|
606
615
|
result = nil
|
607
616
|
if IRB.conf[:MEASURE] && IRB.conf[:MEASURE_CALLBACKS].empty?
|
data/lib/irb/input-method.rb
CHANGED
data/lib/irb/version.rb
CHANGED
data/lib/irb.rb
CHANGED
@@ -311,7 +311,9 @@ require_relative "irb/pager"
|
|
311
311
|
# ### Input Method
|
312
312
|
#
|
313
313
|
# The IRB input method determines how command input is to be read; by default,
|
314
|
-
# the input method for a session is IRB::RelineInputMethod.
|
314
|
+
# the input method for a session is IRB::RelineInputMethod. Unless the
|
315
|
+
# value of the TERM environment variable is 'dumb', in which case the
|
316
|
+
# most simplistic input method is used.
|
315
317
|
#
|
316
318
|
# You can set the input method by:
|
317
319
|
#
|
@@ -329,7 +331,8 @@ require_relative "irb/pager"
|
|
329
331
|
# IRB::ReadlineInputMethod.
|
330
332
|
# * `--nosingleline` or `--multiline` sets the input method to
|
331
333
|
# IRB::RelineInputMethod.
|
332
|
-
#
|
334
|
+
# * `--nosingleline` together with `--nomultiline` sets the
|
335
|
+
# input to IRB::StdioInputMethod.
|
333
336
|
#
|
334
337
|
#
|
335
338
|
# Method `conf.use_multiline?` and its synonym `conf.use_reline` return:
|
@@ -928,8 +931,11 @@ module IRB
|
|
928
931
|
# The lexer used by this irb session
|
929
932
|
attr_accessor :scanner
|
930
933
|
|
934
|
+
attr_reader :from_binding
|
935
|
+
|
931
936
|
# Creates a new irb session
|
932
|
-
def initialize(workspace = nil, input_method = nil)
|
937
|
+
def initialize(workspace = nil, input_method = nil, from_binding: false)
|
938
|
+
@from_binding = from_binding
|
933
939
|
@context = Context.new(self, workspace, input_method)
|
934
940
|
@context.workspace.load_helper_methods_to_main
|
935
941
|
@signal_status = :IN_IRB
|
@@ -1593,7 +1599,7 @@ class Binding
|
|
1593
1599
|
else
|
1594
1600
|
# If we're not in a debugger session, create a new IRB instance with the current
|
1595
1601
|
# workspace
|
1596
|
-
binding_irb = IRB::Irb.new(workspace)
|
1602
|
+
binding_irb = IRB::Irb.new(workspace, from_binding: true)
|
1597
1603
|
binding_irb.context.irb_path = irb_path
|
1598
1604
|
binding_irb.run(IRB.conf)
|
1599
1605
|
binding_irb.debug_break
|
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.13.
|
4
|
+
version: 1.13.1
|
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: 2024-05-
|
12
|
+
date: 2024-05-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: reline
|