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.
- checksums.yaml +4 -4
- data/README.md +3 -11
- data/Rakefile +10 -0
- data/irb.gemspec +1 -1
- data/lib/irb/cmd/nop.rb +1 -1
- data/lib/irb/color.rb +2 -2
- data/lib/irb/command/backtrace.rb +2 -6
- data/lib/irb/command/base.rb +7 -9
- data/lib/irb/command/break.rb +2 -6
- data/lib/irb/command/catch.rb +2 -6
- data/lib/irb/command/chws.rb +11 -5
- data/lib/irb/command/context.rb +16 -0
- data/lib/irb/command/continue.rb +2 -2
- data/lib/irb/command/debug.rb +8 -1
- data/lib/irb/command/delete.rb +2 -2
- data/lib/irb/command/disable_irb.rb +19 -0
- data/lib/irb/command/edit.rb +6 -13
- data/lib/irb/command/exit.rb +1 -3
- data/lib/irb/command/finish.rb +2 -2
- data/lib/irb/command/force_exit.rb +1 -3
- data/lib/irb/command/help.rb +8 -17
- data/lib/irb/command/history.rb +4 -6
- data/lib/irb/command/info.rb +2 -6
- data/lib/irb/command/internal_helpers.rb +27 -0
- data/lib/irb/command/irb_info.rb +2 -2
- data/lib/irb/command/load.rb +20 -3
- data/lib/irb/command/ls.rb +20 -10
- data/lib/irb/command/measure.rb +12 -6
- data/lib/irb/command/next.rb +2 -2
- data/lib/irb/command/pushws.rb +10 -5
- data/lib/irb/command/show_doc.rb +9 -18
- data/lib/irb/command/show_source.rb +5 -12
- data/lib/irb/command/step.rb +2 -2
- data/lib/irb/command/subirb.rb +28 -12
- data/lib/irb/command/whereami.rb +1 -1
- data/lib/irb/command.rb +8 -303
- data/lib/irb/completion.rb +16 -5
- data/lib/irb/context.rb +21 -19
- data/lib/irb/default_commands.rb +260 -0
- data/lib/irb/ext/change-ws.rb +3 -5
- data/lib/irb/ext/multi-irb.rb +4 -4
- data/lib/irb/ext/workspaces.rb +3 -4
- data/lib/irb/help.rb +1 -1
- data/lib/irb/helper_method/base.rb +16 -0
- data/lib/irb/helper_method/conf.rb +11 -0
- data/lib/irb/helper_method.rb +29 -0
- data/lib/irb/history.rb +6 -3
- data/lib/irb/init.rb +60 -44
- data/lib/irb/input-method.rb +18 -10
- data/lib/irb/lc/error.rb +0 -5
- data/lib/irb/lc/ja/error.rb +0 -5
- data/lib/irb/lc/ja/help-message +10 -0
- data/lib/irb/statement.rb +5 -27
- data/lib/irb/version.rb +2 -2
- data/lib/irb/workspace.rb +18 -2
- data/lib/irb.rb +675 -624
- 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
|
-
|
71
|
-
|
72
|
-
|
73
|
-
@
|
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
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
|
112
|
-
main
|
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
|