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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e4425b668e9f62b7535ef0db6b790b8e15a0ca62d4b81461d758c645c6043496
4
- data.tar.gz: 36977d4a243c9acbc057729ff7bd6ea2432f8cfdb4013e7e4f2c05bebef26c70
3
+ metadata.gz: b57e45ef4cb7d58489abeda8131ed81a1625b05fd139e00082bf3011fc0c2fdc
4
+ data.tar.gz: 411b92eee70de798e94c0c9c30801467cdf240a43eff4da9e46230374fa8504f
5
5
  SHA512:
6
- metadata.gz: 804b6fa04f60f7ecc3bf98a9aa818fd8a0e177528c455ac46e853683463176b3eb651eb81e079b70870d2c4f55ab99d4292f10563f42b4c50d697e8e9684b810
7
- data.tar.gz: 0f554e6950eda72508cf3af5eb4c446fc0584eec20c843cbf7ae653698b233add55251028dcf7a4991df5dfdfb90956589b728d727d4deb9e64cfe524349aab5
6
+ metadata.gz: '0919ac233b97abb80a9d34cad9be792e85bce261cc4c29c36eac8d7ba81bd99c4592b5b8c1bdbdc7e96d778ccf20b5374987eef0224e9fb6583639633e3c2bb0'
7
+ data.tar.gz: 89dad0bbdebdee60a3f08ca2cf918293bffac4db7b183a45ab93f6cc4906ca7a62437286a08291ba76fae8e2bba31f3b6a28be3cd13a141f451a5c4e1b09041d
@@ -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)
@@ -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 binding_irb?
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
@@ -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 STDIN.tty? && IRB.conf[:PROMPT_MODE] != :INF_RUBY && !use_singleline?
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) && STDIN.tty? &&
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?
@@ -1,7 +1,7 @@
1
1
  module IRB
2
2
  module HelperMethod
3
3
  class Conf < Base
4
- description "Returns the current context."
4
+ description "Returns the current IRB context."
5
5
 
6
6
  def execute
7
7
  IRB.CurrentContext
@@ -67,6 +67,7 @@ module IRB
67
67
  #
68
68
  # See IO#gets for more information.
69
69
  def gets
70
+ puts if @stdout.tty? # workaround for debug compatibility test
70
71
  print @prompt
71
72
  line = @stdin.gets
72
73
  @line[@line_no += 1] = line
data/lib/irb/version.rb CHANGED
@@ -5,7 +5,7 @@
5
5
  #
6
6
 
7
7
  module IRB # :nodoc:
8
- VERSION = "1.13.0"
8
+ VERSION = "1.13.1"
9
9
  @RELEASE_VERSION = VERSION
10
- @LAST_UPDATE_DATE = "2024-05-01"
10
+ @LAST_UPDATE_DATE = "2024-05-05"
11
11
  end
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.0
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-01 00:00:00.000000000 Z
12
+ date: 2024-05-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: reline