irb 1.12.0 → 1.13.0

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 (57) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +3 -11
  3. data/Rakefile +10 -0
  4. data/irb.gemspec +1 -1
  5. data/lib/irb/cmd/nop.rb +1 -1
  6. data/lib/irb/color.rb +2 -2
  7. data/lib/irb/command/backtrace.rb +2 -6
  8. data/lib/irb/command/base.rb +7 -9
  9. data/lib/irb/command/break.rb +2 -6
  10. data/lib/irb/command/catch.rb +2 -6
  11. data/lib/irb/command/chws.rb +11 -5
  12. data/lib/irb/command/context.rb +16 -0
  13. data/lib/irb/command/continue.rb +2 -2
  14. data/lib/irb/command/debug.rb +8 -1
  15. data/lib/irb/command/delete.rb +2 -2
  16. data/lib/irb/command/disable_irb.rb +19 -0
  17. data/lib/irb/command/edit.rb +6 -13
  18. data/lib/irb/command/exit.rb +1 -3
  19. data/lib/irb/command/finish.rb +2 -2
  20. data/lib/irb/command/force_exit.rb +1 -3
  21. data/lib/irb/command/help.rb +8 -17
  22. data/lib/irb/command/history.rb +4 -6
  23. data/lib/irb/command/info.rb +2 -6
  24. data/lib/irb/command/internal_helpers.rb +27 -0
  25. data/lib/irb/command/irb_info.rb +2 -2
  26. data/lib/irb/command/load.rb +20 -3
  27. data/lib/irb/command/ls.rb +20 -10
  28. data/lib/irb/command/measure.rb +12 -6
  29. data/lib/irb/command/next.rb +2 -2
  30. data/lib/irb/command/pushws.rb +10 -5
  31. data/lib/irb/command/show_doc.rb +9 -18
  32. data/lib/irb/command/show_source.rb +5 -12
  33. data/lib/irb/command/step.rb +2 -2
  34. data/lib/irb/command/subirb.rb +28 -12
  35. data/lib/irb/command/whereami.rb +1 -1
  36. data/lib/irb/command.rb +8 -303
  37. data/lib/irb/completion.rb +16 -5
  38. data/lib/irb/context.rb +21 -19
  39. data/lib/irb/default_commands.rb +260 -0
  40. data/lib/irb/ext/change-ws.rb +3 -5
  41. data/lib/irb/ext/multi-irb.rb +4 -4
  42. data/lib/irb/ext/workspaces.rb +3 -4
  43. data/lib/irb/help.rb +1 -1
  44. data/lib/irb/helper_method/base.rb +16 -0
  45. data/lib/irb/helper_method/conf.rb +11 -0
  46. data/lib/irb/helper_method.rb +29 -0
  47. data/lib/irb/history.rb +6 -3
  48. data/lib/irb/init.rb +60 -44
  49. data/lib/irb/input-method.rb +18 -10
  50. data/lib/irb/lc/error.rb +0 -5
  51. data/lib/irb/lc/ja/error.rb +0 -5
  52. data/lib/irb/lc/ja/help-message +10 -0
  53. data/lib/irb/statement.rb +5 -27
  54. data/lib/irb/version.rb +2 -2
  55. data/lib/irb/workspace.rb +18 -2
  56. data/lib/irb.rb +675 -624
  57. metadata +12 -5
data/lib/irb/statement.rb CHANGED
@@ -16,10 +16,6 @@ module IRB
16
16
  raise NotImplementedError
17
17
  end
18
18
 
19
- def evaluable_code
20
- raise NotImplementedError
21
- end
22
-
23
19
  class EmptyInput < Statement
24
20
  def is_assignment?
25
21
  false
@@ -37,10 +33,6 @@ module IRB
37
33
  def code
38
34
  ""
39
35
  end
40
-
41
- def evaluable_code
42
- code
43
- end
44
36
  end
45
37
 
46
38
  class Expression < Statement
@@ -60,18 +52,15 @@ module IRB
60
52
  def is_assignment?
61
53
  @is_assignment
62
54
  end
63
-
64
- def evaluable_code
65
- @code
66
- end
67
55
  end
68
56
 
69
57
  class Command < Statement
70
- def initialize(code, command, arg, command_class)
71
- @code = code
72
- @command = command
73
- @arg = arg
58
+ attr_reader :command_class, :arg
59
+
60
+ def initialize(original_code, command_class, arg)
61
+ @code = original_code
74
62
  @command_class = command_class
63
+ @arg = arg
75
64
  end
76
65
 
77
66
  def is_assignment?
@@ -86,17 +75,6 @@ module IRB
86
75
  require_relative 'command/debug'
87
76
  IRB::Command::DebugCommand > @command_class
88
77
  end
89
-
90
- def evaluable_code
91
- # Hook command-specific transformation to return valid Ruby code
92
- if @command_class.respond_to?(:transform_args)
93
- arg = @command_class.transform_args(@arg)
94
- else
95
- arg = @arg
96
- end
97
-
98
- [@command, arg].compact.join(' ')
99
- end
100
78
  end
101
79
  end
102
80
  end
data/lib/irb/version.rb CHANGED
@@ -5,7 +5,7 @@
5
5
  #
6
6
 
7
7
  module IRB # :nodoc:
8
- VERSION = "1.12.0"
8
+ VERSION = "1.13.0"
9
9
  @RELEASE_VERSION = VERSION
10
- @LAST_UPDATE_DATE = "2024-03-06"
10
+ @LAST_UPDATE_DATE = "2024-05-01"
11
11
  end
data/lib/irb/workspace.rb CHANGED
@@ -6,6 +6,8 @@
6
6
 
7
7
  require "delegate"
8
8
 
9
+ require_relative "helper_method"
10
+
9
11
  IRB::TOPLEVEL_BINDING = binding
10
12
  module IRB # :nodoc:
11
13
  class WorkSpace
@@ -108,8 +110,10 @@ EOF
108
110
  # <code>IRB.conf[:__MAIN__]</code>
109
111
  attr_reader :main
110
112
 
111
- def load_commands_to_main
112
- main.extend ExtendCommandBundle
113
+ def load_helper_methods_to_main
114
+ ancestors = class<<main;ancestors;end
115
+ main.extend ExtendCommandBundle if !ancestors.include?(ExtendCommandBundle)
116
+ main.extend HelpersContainer if !ancestors.include?(HelpersContainer)
113
117
  end
114
118
 
115
119
  # Evaluate the given +statements+ within the context of this workspace.
@@ -170,4 +174,16 @@ EOF
170
174
  "\nFrom: #{file} @ line #{pos + 1} :\n\n#{body}#{Color.clear}\n"
171
175
  end
172
176
  end
177
+
178
+ module HelpersContainer
179
+ def self.install_helper_methods
180
+ HelperMethod.helper_methods.each do |name, helper_method_class|
181
+ define_method name do |*args, **opts, &block|
182
+ helper_method_class.instance.execute(*args, **opts, &block)
183
+ end unless method_defined?(name)
184
+ end
185
+ end
186
+
187
+ install_helper_methods
188
+ end
173
189
  end