Skip to content

Commit d5060f7

Browse files
committed
Use require_relative to load extensions/commands
1 parent 6cd4cc7 commit d5060f7

File tree

1 file changed

+24
-24
lines changed

1 file changed

+24
-24
lines changed

lib/irb/extend-command.rb

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def irb_context
4747

4848
@EXTEND_COMMANDS = [
4949
[
50-
:irb_current_working_workspace, :CurrentWorkingWorkspace, "irb/cmd/chws",
50+
:irb_current_working_workspace, :CurrentWorkingWorkspace, "cmd/chws",
5151
[:irb_print_working_workspace, OVERRIDE_ALL],
5252
[:irb_cwws, OVERRIDE_ALL],
5353
[:irb_pwws, OVERRIDE_ALL],
@@ -59,7 +59,7 @@ def irb_context
5959
[:irb_pwb, OVERRIDE_ALL],
6060
],
6161
[
62-
:irb_change_workspace, :ChangeWorkspace, "irb/cmd/chws",
62+
:irb_change_workspace, :ChangeWorkspace, "cmd/chws",
6363
[:irb_chws, OVERRIDE_ALL],
6464
[:irb_cws, OVERRIDE_ALL],
6565
[:chws, NO_OVERRIDE],
@@ -70,21 +70,21 @@ def irb_context
7070
],
7171

7272
[
73-
:irb_workspaces, :Workspaces, "irb/cmd/pushws",
73+
:irb_workspaces, :Workspaces, "cmd/pushws",
7474
[:workspaces, NO_OVERRIDE],
7575
[:irb_bindings, OVERRIDE_ALL],
7676
[:bindings, NO_OVERRIDE],
7777
],
7878
[
79-
:irb_push_workspace, :PushWorkspace, "irb/cmd/pushws",
79+
:irb_push_workspace, :PushWorkspace, "cmd/pushws",
8080
[:irb_pushws, OVERRIDE_ALL],
8181
[:pushws, NO_OVERRIDE],
8282
[:irb_push_binding, OVERRIDE_ALL],
8383
[:irb_pushb, OVERRIDE_ALL],
8484
[:pushb, NO_OVERRIDE],
8585
],
8686
[
87-
:irb_pop_workspace, :PopWorkspace, "irb/cmd/pushws",
87+
:irb_pop_workspace, :PopWorkspace, "cmd/pushws",
8888
[:irb_popws, OVERRIDE_ALL],
8989
[:popws, NO_OVERRIDE],
9090
[:irb_pop_binding, OVERRIDE_ALL],
@@ -93,55 +93,55 @@ def irb_context
9393
],
9494

9595
[
96-
:irb_load, :Load, "irb/cmd/load"],
96+
:irb_load, :Load, "cmd/load"],
9797
[
98-
:irb_require, :Require, "irb/cmd/load"],
98+
:irb_require, :Require, "cmd/load"],
9999
[
100-
:irb_source, :Source, "irb/cmd/load",
100+
:irb_source, :Source, "cmd/load",
101101
[:source, NO_OVERRIDE],
102102
],
103103

104104
[
105-
:irb, :IrbCommand, "irb/cmd/subirb"],
105+
:irb, :IrbCommand, "cmd/subirb"],
106106
[
107-
:irb_jobs, :Jobs, "irb/cmd/subirb",
107+
:irb_jobs, :Jobs, "cmd/subirb",
108108
[:jobs, NO_OVERRIDE],
109109
],
110110
[
111-
:irb_fg, :Foreground, "irb/cmd/subirb",
111+
:irb_fg, :Foreground, "cmd/subirb",
112112
[:fg, NO_OVERRIDE],
113113
],
114114
[
115-
:irb_kill, :Kill, "irb/cmd/subirb",
115+
:irb_kill, :Kill, "cmd/subirb",
116116
[:kill, OVERRIDE_PRIVATE_ONLY],
117117
],
118118

119119
[
120-
:irb_help, :Help, "irb/cmd/help",
120+
:irb_help, :Help, "cmd/help",
121121
[:help, NO_OVERRIDE],
122122
],
123123

124124
[
125-
:irb_info, :Info, "irb/cmd/info"
125+
:irb_info, :Info, "cmd/info"
126126
],
127127

128128
[
129-
:irb_ls, :Ls, "irb/cmd/ls",
129+
:irb_ls, :Ls, "cmd/ls",
130130
[:ls, NO_OVERRIDE],
131131
],
132132

133133
[
134-
:irb_measure, :Measure, "irb/cmd/measure",
134+
:irb_measure, :Measure, "cmd/measure",
135135
[:measure, NO_OVERRIDE],
136136
],
137137

138138
[
139-
:irb_show_source, :ShowSource, "irb/cmd/show_source",
139+
:irb_show_source, :ShowSource, "cmd/show_source",
140140
[:show_source, NO_OVERRIDE],
141141
],
142142

143143
[
144-
:irb_whereami, :Whereami, "irb/cmd/whereami",
144+
:irb_whereami, :Whereami, "cmd/whereami",
145145
[:whereami, NO_OVERRIDE],
146146
],
147147

@@ -187,7 +187,7 @@ def self.def_extend_command(cmd_name, cmd_class, load_file = nil, *aliases)
187187
kwargs = ", **kwargs" if RUBY_ENGINE == "ruby" && RUBY_VERSION >= "2.7.0"
188188
line = __LINE__; eval %[
189189
def #{cmd_name}(*opts#{kwargs}, &b)
190-
require "#{load_file}"
190+
require_relative "#{load_file}"
191191
arity = ExtendCommand::#{cmd_class}.instance_method(:execute).arity
192192
args = (1..(arity < 0 ? ~arity : arity)).map {|i| "arg" + i.to_s }
193193
args << "*opts#{kwargs}" if arity < 0
@@ -262,10 +262,10 @@ module ContextExtender
262262
CE = ContextExtender # :nodoc:
263263

264264
@EXTEND_COMMANDS = [
265-
[:eval_history=, "irb/ext/history.rb"],
266-
[:use_tracer=, "irb/ext/tracer.rb"],
267-
[:use_loader=, "irb/ext/use-loader.rb"],
268-
[:save_history=, "irb/ext/save-history.rb"],
265+
[:eval_history=, "ext/history.rb"],
266+
[:use_tracer=, "ext/tracer.rb"],
267+
[:use_loader=, "ext/use-loader.rb"],
268+
[:save_history=, "ext/save-history.rb"],
269269
]
270270

271271
# Installs the default context extensions as irb commands:
@@ -288,7 +288,7 @@ def self.def_extend_command(cmd_name, load_file, *aliases)
288288
line = __LINE__; Context.module_eval %[
289289
def #{cmd_name}(*opts, &b)
290290
Context.module_eval {remove_method(:#{cmd_name})}
291-
require "#{load_file}"
291+
require_relative "#{load_file}"
292292
__send__ :#{cmd_name}, *opts, &b
293293
end
294294
for ali in aliases

0 commit comments

Comments
 (0)