irb 1.8.3 → 1.13.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. checksums.yaml +4 -4
  2. data/.document +1 -1
  3. data/Gemfile +9 -1
  4. data/README.md +149 -25
  5. data/Rakefile +13 -3
  6. data/irb.gemspec +2 -2
  7. data/lib/irb/cmd/nop.rb +3 -52
  8. data/lib/irb/color.rb +2 -2
  9. data/lib/irb/command/backtrace.rb +17 -0
  10. data/lib/irb/command/base.rb +62 -0
  11. data/lib/irb/command/break.rb +17 -0
  12. data/lib/irb/command/catch.rb +17 -0
  13. data/lib/irb/command/chws.rb +40 -0
  14. data/lib/irb/command/context.rb +16 -0
  15. data/lib/irb/{cmd → command}/continue.rb +3 -3
  16. data/lib/irb/{cmd → command}/debug.rb +11 -20
  17. data/lib/irb/{cmd → command}/delete.rb +3 -3
  18. data/lib/irb/command/disable_irb.rb +19 -0
  19. data/lib/irb/command/edit.rb +63 -0
  20. data/lib/irb/command/exit.rb +18 -0
  21. data/lib/irb/{cmd → command}/finish.rb +3 -3
  22. data/lib/irb/command/force_exit.rb +18 -0
  23. data/lib/irb/command/help.rb +83 -0
  24. data/lib/irb/command/history.rb +45 -0
  25. data/lib/irb/command/info.rb +17 -0
  26. data/lib/irb/command/internal_helpers.rb +27 -0
  27. data/lib/irb/{cmd → command}/irb_info.rb +7 -7
  28. data/lib/irb/{cmd → command}/load.rb +23 -8
  29. data/lib/irb/{cmd → command}/ls.rb +30 -14
  30. data/lib/irb/{cmd → command}/measure.rb +18 -17
  31. data/lib/irb/{cmd → command}/next.rb +3 -3
  32. data/lib/irb/command/pushws.rb +65 -0
  33. data/lib/irb/command/show_doc.rb +51 -0
  34. data/lib/irb/command/show_source.rb +74 -0
  35. data/lib/irb/{cmd → command}/step.rb +3 -3
  36. data/lib/irb/{cmd → command}/subirb.rb +31 -17
  37. data/lib/irb/{cmd → command}/whereami.rb +3 -5
  38. data/lib/irb/command.rb +23 -0
  39. data/lib/irb/completion.rb +74 -31
  40. data/lib/irb/context.rb +144 -57
  41. data/lib/irb/debug.rb +18 -0
  42. data/lib/irb/default_commands.rb +260 -0
  43. data/lib/irb/easter-egg.rb +16 -6
  44. data/lib/irb/ext/change-ws.rb +6 -8
  45. data/lib/irb/ext/eval_history.rb +3 -3
  46. data/lib/irb/ext/loader.rb +4 -4
  47. data/lib/irb/ext/multi-irb.rb +5 -5
  48. data/lib/irb/ext/tracer.rb +12 -51
  49. data/lib/irb/ext/use-loader.rb +6 -8
  50. data/lib/irb/ext/workspaces.rb +10 -34
  51. data/lib/irb/frame.rb +1 -1
  52. data/lib/irb/help.rb +3 -3
  53. data/lib/irb/helper_method/base.rb +16 -0
  54. data/lib/irb/helper_method/conf.rb +11 -0
  55. data/lib/irb/helper_method.rb +29 -0
  56. data/lib/irb/history.rb +15 -4
  57. data/lib/irb/init.rb +119 -52
  58. data/lib/irb/input-method.rb +77 -27
  59. data/lib/irb/inspector.rb +3 -3
  60. data/lib/irb/lc/error.rb +1 -11
  61. data/lib/irb/lc/help-message +4 -0
  62. data/lib/irb/lc/ja/error.rb +1 -11
  63. data/lib/irb/lc/ja/help-message +13 -0
  64. data/lib/irb/locale.rb +2 -2
  65. data/lib/irb/nesting_parser.rb +13 -3
  66. data/lib/irb/notifier.rb +1 -1
  67. data/lib/irb/output-method.rb +2 -8
  68. data/lib/irb/pager.rb +16 -11
  69. data/lib/irb/ruby-lex.rb +2 -2
  70. data/lib/irb/ruby_logo.aa +43 -0
  71. data/lib/irb/source_finder.rb +112 -37
  72. data/lib/irb/statement.rb +24 -24
  73. data/lib/irb/version.rb +3 -3
  74. data/lib/irb/workspace.rb +22 -6
  75. data/lib/irb/ws-for-case-2.rb +1 -1
  76. data/lib/irb/xmp.rb +3 -3
  77. data/lib/irb.rb +1071 -556
  78. data/man/irb.1 +7 -0
  79. metadata +41 -31
  80. data/lib/irb/cmd/backtrace.rb +0 -21
  81. data/lib/irb/cmd/break.rb +0 -21
  82. data/lib/irb/cmd/catch.rb +0 -21
  83. data/lib/irb/cmd/chws.rb +0 -36
  84. data/lib/irb/cmd/edit.rb +0 -60
  85. data/lib/irb/cmd/help.rb +0 -23
  86. data/lib/irb/cmd/info.rb +0 -21
  87. data/lib/irb/cmd/pushws.rb +0 -45
  88. data/lib/irb/cmd/show_cmds.rb +0 -53
  89. data/lib/irb/cmd/show_doc.rb +0 -48
  90. data/lib/irb/cmd/show_source.rb +0 -61
  91. data/lib/irb/extend-command.rb +0 -354
data/man/irb.1 CHANGED
@@ -140,6 +140,13 @@ Use autocompletion.
140
140
  Don't use autocompletion.
141
141
  .Pp
142
142
  .Pp
143
+ .It Fl -regexp-completor
144
+ Use regexp based completion.
145
+ .Pp
146
+ .It Fl -type-completor
147
+ Use type based completion.
148
+ .Pp
149
+ .Pp
143
150
  .It Fl -verbose
144
151
  Show details.
145
152
  .Pp
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.8.3
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: 2023-10-14 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
@@ -17,28 +17,28 @@ dependencies:
17
17
  requirements:
18
18
  - - ">="
19
19
  - !ruby/object:Gem::Version
20
- version: 0.3.8
20
+ version: 0.4.2
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - ">="
26
26
  - !ruby/object:Gem::Version
27
- version: 0.3.8
27
+ version: 0.4.2
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: rdoc
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
32
  - - ">="
33
33
  - !ruby/object:Gem::Version
34
- version: '0'
34
+ version: 4.0.0
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
39
  - - ">="
40
40
  - !ruby/object:Gem::Version
41
- version: '0'
41
+ version: 4.0.0
42
42
  description: Interactive Ruby command-line tool for REPL (Read Eval Print Loop).
43
43
  email:
44
44
  - aycabta@gmail.com
@@ -60,36 +60,44 @@ files:
60
60
  - exe/irb
61
61
  - irb.gemspec
62
62
  - lib/irb.rb
63
- - lib/irb/cmd/backtrace.rb
64
- - lib/irb/cmd/break.rb
65
- - lib/irb/cmd/catch.rb
66
- - lib/irb/cmd/chws.rb
67
- - lib/irb/cmd/continue.rb
68
- - lib/irb/cmd/debug.rb
69
- - lib/irb/cmd/delete.rb
70
- - lib/irb/cmd/edit.rb
71
- - lib/irb/cmd/finish.rb
72
- - lib/irb/cmd/help.rb
73
- - lib/irb/cmd/info.rb
74
- - lib/irb/cmd/irb_info.rb
75
- - lib/irb/cmd/load.rb
76
- - lib/irb/cmd/ls.rb
77
- - lib/irb/cmd/measure.rb
78
- - lib/irb/cmd/next.rb
79
63
  - lib/irb/cmd/nop.rb
80
- - lib/irb/cmd/pushws.rb
81
- - lib/irb/cmd/show_cmds.rb
82
- - lib/irb/cmd/show_doc.rb
83
- - lib/irb/cmd/show_source.rb
84
- - lib/irb/cmd/step.rb
85
- - lib/irb/cmd/subirb.rb
86
- - lib/irb/cmd/whereami.rb
87
64
  - lib/irb/color.rb
88
65
  - lib/irb/color_printer.rb
66
+ - lib/irb/command.rb
67
+ - lib/irb/command/backtrace.rb
68
+ - lib/irb/command/base.rb
69
+ - lib/irb/command/break.rb
70
+ - lib/irb/command/catch.rb
71
+ - lib/irb/command/chws.rb
72
+ - lib/irb/command/context.rb
73
+ - lib/irb/command/continue.rb
74
+ - lib/irb/command/debug.rb
75
+ - lib/irb/command/delete.rb
76
+ - lib/irb/command/disable_irb.rb
77
+ - lib/irb/command/edit.rb
78
+ - lib/irb/command/exit.rb
79
+ - lib/irb/command/finish.rb
80
+ - lib/irb/command/force_exit.rb
81
+ - lib/irb/command/help.rb
82
+ - lib/irb/command/history.rb
83
+ - lib/irb/command/info.rb
84
+ - lib/irb/command/internal_helpers.rb
85
+ - lib/irb/command/irb_info.rb
86
+ - lib/irb/command/load.rb
87
+ - lib/irb/command/ls.rb
88
+ - lib/irb/command/measure.rb
89
+ - lib/irb/command/next.rb
90
+ - lib/irb/command/pushws.rb
91
+ - lib/irb/command/show_doc.rb
92
+ - lib/irb/command/show_source.rb
93
+ - lib/irb/command/step.rb
94
+ - lib/irb/command/subirb.rb
95
+ - lib/irb/command/whereami.rb
89
96
  - lib/irb/completion.rb
90
97
  - lib/irb/context.rb
91
98
  - lib/irb/debug.rb
92
99
  - lib/irb/debug/ui.rb
100
+ - lib/irb/default_commands.rb
93
101
  - lib/irb/easter-egg.rb
94
102
  - lib/irb/ext/change-ws.rb
95
103
  - lib/irb/ext/eval_history.rb
@@ -98,9 +106,11 @@ files:
98
106
  - lib/irb/ext/tracer.rb
99
107
  - lib/irb/ext/use-loader.rb
100
108
  - lib/irb/ext/workspaces.rb
101
- - lib/irb/extend-command.rb
102
109
  - lib/irb/frame.rb
103
110
  - lib/irb/help.rb
111
+ - lib/irb/helper_method.rb
112
+ - lib/irb/helper_method/base.rb
113
+ - lib/irb/helper_method/conf.rb
104
114
  - lib/irb/history.rb
105
115
  - lib/irb/init.rb
106
116
  - lib/irb/input-method.rb
@@ -147,7 +157,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
147
157
  - !ruby/object:Gem::Version
148
158
  version: '0'
149
159
  requirements: []
150
- rubygems_version: 3.4.10
160
+ rubygems_version: 3.5.7
151
161
  signing_key:
152
162
  specification_version: 4
153
163
  summary: Interactive Ruby command-line tool for REPL (Read Eval Print Loop).
@@ -1,21 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "debug"
4
-
5
- module IRB
6
- # :stopdoc:
7
-
8
- module ExtendCommand
9
- class Backtrace < DebugCommand
10
- def self.transform_args(args)
11
- args&.dump
12
- end
13
-
14
- def execute(*args)
15
- super(pre_cmds: ["backtrace", *args].join(" "))
16
- end
17
- end
18
- end
19
-
20
- # :startdoc:
21
- end
data/lib/irb/cmd/break.rb DELETED
@@ -1,21 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "debug"
4
-
5
- module IRB
6
- # :stopdoc:
7
-
8
- module ExtendCommand
9
- class Break < DebugCommand
10
- def self.transform_args(args)
11
- args&.dump
12
- end
13
-
14
- def execute(args = nil)
15
- super(pre_cmds: "break #{args}")
16
- end
17
- end
18
- end
19
-
20
- # :startdoc:
21
- end
data/lib/irb/cmd/catch.rb DELETED
@@ -1,21 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "debug"
4
-
5
- module IRB
6
- # :stopdoc:
7
-
8
- module ExtendCommand
9
- class Catch < DebugCommand
10
- def self.transform_args(args)
11
- args&.dump
12
- end
13
-
14
- def execute(*args)
15
- super(pre_cmds: ["catch", *args].join(" "))
16
- end
17
- end
18
- end
19
-
20
- # :startdoc:
21
- end
data/lib/irb/cmd/chws.rb DELETED
@@ -1,36 +0,0 @@
1
- # frozen_string_literal: false
2
- #
3
- # change-ws.rb -
4
- # by Keiju ISHITSUKA(keiju@ruby-lang.org)
5
- #
6
-
7
- require_relative "nop"
8
- require_relative "../ext/change-ws"
9
-
10
- module IRB
11
- # :stopdoc:
12
-
13
- module ExtendCommand
14
-
15
- class CurrentWorkingWorkspace < Nop
16
- category "Workspace"
17
- description "Show the current workspace."
18
-
19
- def execute(*obj)
20
- irb_context.main
21
- end
22
- end
23
-
24
- class ChangeWorkspace < Nop
25
- category "Workspace"
26
- description "Change the current workspace to an object."
27
-
28
- def execute(*obj)
29
- irb_context.change_workspace(*obj)
30
- irb_context.main
31
- end
32
- end
33
- end
34
-
35
- # :startdoc:
36
- end
data/lib/irb/cmd/edit.rb DELETED
@@ -1,60 +0,0 @@
1
- require 'shellwords'
2
- require_relative "nop"
3
- require_relative "../source_finder"
4
-
5
- module IRB
6
- # :stopdoc:
7
-
8
- module ExtendCommand
9
- class Edit < Nop
10
- category "Misc"
11
- description 'Open a file with the editor command defined with `ENV["VISUAL"]` or `ENV["EDITOR"]`.'
12
-
13
- class << self
14
- def transform_args(args)
15
- # Return a string literal as is for backward compatibility
16
- if args.nil? || args.empty? || string_literal?(args)
17
- args
18
- else # Otherwise, consider the input as a String for convenience
19
- args.strip.dump
20
- end
21
- end
22
- end
23
-
24
- def execute(*args)
25
- path = args.first
26
-
27
- if path.nil? && (irb_path = @irb_context.irb_path)
28
- path = irb_path
29
- end
30
-
31
- if !File.exist?(path)
32
- source =
33
- begin
34
- SourceFinder.new(@irb_context).find_source(path)
35
- rescue NameError
36
- # if user enters a path that doesn't exist, it'll cause NameError when passed here because find_source would try to evaluate it as well
37
- # in this case, we should just ignore the error
38
- end
39
-
40
- if source
41
- path = source.file
42
- else
43
- puts "Can not find file: #{path}"
44
- return
45
- end
46
- end
47
-
48
- if editor = (ENV['VISUAL'] || ENV['EDITOR'])
49
- puts "command: '#{editor}'"
50
- puts " path: #{path}"
51
- system(*Shellwords.split(editor), path)
52
- else
53
- puts "Can not find editor setting: ENV['VISUAL'] or ENV['EDITOR']"
54
- end
55
- end
56
- end
57
- end
58
-
59
- # :startdoc:
60
- end
data/lib/irb/cmd/help.rb DELETED
@@ -1,23 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "show_doc"
4
-
5
- module IRB
6
- module ExtendCommand
7
- class Help < ShowDoc
8
- category "Context"
9
- description "[DEPRECATED] Enter the mode to look up RI documents."
10
-
11
- DEPRECATION_MESSAGE = <<~MSG
12
- [Deprecation] The `help` command will be repurposed to display command help in the future.
13
- For RI document lookup, please use the `show_doc` command instead.
14
- For command help, please use `show_cmds` for now.
15
- MSG
16
-
17
- def execute(*names)
18
- warn DEPRECATION_MESSAGE
19
- super
20
- end
21
- end
22
- end
23
- end
data/lib/irb/cmd/info.rb DELETED
@@ -1,21 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "debug"
4
-
5
- module IRB
6
- # :stopdoc:
7
-
8
- module ExtendCommand
9
- class Info < DebugCommand
10
- def self.transform_args(args)
11
- args&.dump
12
- end
13
-
14
- def execute(*args)
15
- super(pre_cmds: ["info", *args].join(" "))
16
- end
17
- end
18
- end
19
-
20
- # :startdoc:
21
- end
@@ -1,45 +0,0 @@
1
- # frozen_string_literal: false
2
- #
3
- # change-ws.rb -
4
- # by Keiju ISHITSUKA(keiju@ruby-lang.org)
5
- #
6
-
7
- require_relative "nop"
8
- require_relative "../ext/workspaces"
9
-
10
- module IRB
11
- # :stopdoc:
12
-
13
- module ExtendCommand
14
- class Workspaces < Nop
15
- category "Workspace"
16
- description "Show workspaces."
17
-
18
- def execute(*obj)
19
- irb_context.workspaces.collect{|ws| ws.main}
20
- end
21
- end
22
-
23
- class PushWorkspace < Workspaces
24
- category "Workspace"
25
- description "Push an object to the workspace stack."
26
-
27
- def execute(*obj)
28
- irb_context.push_workspace(*obj)
29
- super
30
- end
31
- end
32
-
33
- class PopWorkspace < Workspaces
34
- category "Workspace"
35
- description "Pop a workspace from the workspace stack."
36
-
37
- def execute(*obj)
38
- irb_context.pop_workspace(*obj)
39
- super
40
- end
41
- end
42
- end
43
-
44
- # :startdoc:
45
- end
@@ -1,53 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "stringio"
4
- require_relative "nop"
5
- require_relative "../pager"
6
-
7
- module IRB
8
- # :stopdoc:
9
-
10
- module ExtendCommand
11
- class ShowCmds < Nop
12
- category "IRB"
13
- description "List all available commands and their description."
14
-
15
- def execute(*args)
16
- commands_info = IRB::ExtendCommandBundle.all_commands_info
17
- commands_grouped_by_categories = commands_info.group_by { |cmd| cmd[:category] }
18
-
19
- if irb_context.with_debugger
20
- # Remove the original "Debugging" category
21
- commands_grouped_by_categories.delete("Debugging")
22
- # Remove the `help` command as it's delegated to the debugger
23
- commands_grouped_by_categories["Context"].delete_if { |cmd| cmd[:display_name] == :help }
24
- # Add an empty "Debugging (from debug.gem)" category at the end
25
- commands_grouped_by_categories["Debugging (from debug.gem)"] = []
26
- end
27
-
28
- longest_cmd_name_length = commands_info.map { |c| c[:display_name].length }.max
29
-
30
- output = StringIO.new
31
-
32
- commands_grouped_by_categories.each do |category, cmds|
33
- output.puts Color.colorize(category, [:BOLD])
34
-
35
- cmds.each do |cmd|
36
- output.puts " #{cmd[:display_name].to_s.ljust(longest_cmd_name_length)} #{cmd[:description]}"
37
- end
38
-
39
- output.puts
40
- end
41
-
42
- # Append the debugger help at the end
43
- if irb_context.with_debugger
44
- output.puts DEBUGGER__.help
45
- end
46
-
47
- Pager.page_content(output.string)
48
- end
49
- end
50
- end
51
-
52
- # :startdoc:
53
- end
@@ -1,48 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "nop"
4
-
5
- module IRB
6
- module ExtendCommand
7
- class ShowDoc < Nop
8
- class << self
9
- def transform_args(args)
10
- # Return a string literal as is for backward compatibility
11
- if args.empty? || string_literal?(args)
12
- args
13
- else # Otherwise, consider the input as a String for convenience
14
- args.strip.dump
15
- end
16
- end
17
- end
18
-
19
- category "Context"
20
- description "Enter the mode to look up RI documents."
21
-
22
- def execute(*names)
23
- require 'rdoc/ri/driver'
24
-
25
- unless ShowDoc.const_defined?(:Ri)
26
- opts = RDoc::RI::Driver.process_args([])
27
- ShowDoc.const_set(:Ri, RDoc::RI::Driver.new(opts))
28
- end
29
-
30
- if names.empty?
31
- Ri.interactive
32
- else
33
- names.each do |name|
34
- begin
35
- Ri.display_name(name.to_s)
36
- rescue RDoc::RI::Error
37
- puts $!.message
38
- end
39
- end
40
- end
41
-
42
- nil
43
- rescue LoadError, SystemExit
44
- warn "Can't display document because `rdoc` is not installed."
45
- end
46
- end
47
- end
48
- end
@@ -1,61 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "nop"
4
- require_relative "../source_finder"
5
- require_relative "../pager"
6
- require_relative "../color"
7
-
8
- module IRB
9
- module ExtendCommand
10
- class ShowSource < Nop
11
- category "Context"
12
- description "Show the source code of a given method or constant."
13
-
14
- class << self
15
- def transform_args(args)
16
- # Return a string literal as is for backward compatibility
17
- if args.empty? || string_literal?(args)
18
- args
19
- else # Otherwise, consider the input as a String for convenience
20
- args.strip.dump
21
- end
22
- end
23
- end
24
-
25
- def execute(str = nil)
26
- unless str.is_a?(String)
27
- puts "Error: Expected a string but got #{str.inspect}"
28
- return
29
- end
30
-
31
- source = SourceFinder.new(@irb_context).find_source(str)
32
-
33
- if source
34
- show_source(source)
35
- else
36
- puts "Error: Couldn't locate a definition for #{str}"
37
- end
38
- nil
39
- end
40
-
41
- private
42
-
43
- def show_source(source)
44
- file_content = IRB::Color.colorize_code(File.read(source.file))
45
- code = file_content.lines[(source.first_line - 1)...source.last_line].join
46
- content = <<~CONTENT
47
-
48
- #{bold("From")}: #{source.file}:#{source.first_line}
49
-
50
- #{code}
51
- CONTENT
52
-
53
- Pager.page_content(content)
54
- end
55
-
56
- def bold(str)
57
- Color.colorize(str, [:BOLD])
58
- end
59
- end
60
- end
61
- end