Provides a few commands for loading files within an irb session.
See ExtendCommandBundle
for more information.
Methods
- I
- L
- S
Instance Public methods
irb_load(fn, priv = nil) Link
Loads the given file similarly to Kernel#load
load_file(path, priv = nil) Link
Loads the given file in the current session’s context and evaluates it.
See Irb#suspend_input_method
for more information.
# File ruby/lib/irb/ext/loader.rb, line 69 def load_file(path, priv = nil) irb = irb_context.irb irb.suspend_name(path, File.basename(path)) do if priv ws = WorkSpace.new(Module.new) else ws = WorkSpace.new end irb.suspend_workspace(ws) do FileInputMethod.open(path) do |io| irb.suspend_input_method(io) do |back_io| irb.signal_status(:IN_LOAD) do if back_io.kind_of?(FileInputMethod) irb.eval_input else begin irb.eval_input rescue LoadAbort print "load abort!!\n" end end end end end end end end
source_file(path) Link
Loads a given file in the current session and displays the source lines
See Irb#suspend_input_method
for more information.
# File ruby/lib/irb/ext/loader.rb, line 44 def source_file(path) irb = irb_context.irb irb.suspend_name(path, File.basename(path)) do FileInputMethod.open(path) do |io| irb.suspend_input_method(io) do |back_io| irb.signal_status(:IN_LOAD) do if back_io.kind_of?(FileInputMethod) irb.eval_input else begin irb.eval_input rescue LoadAbort print "load abort!!\n" end end end end end end end