module IRB::IrbLoader

def load_file(path, priv = nil)

See Irb#suspend_input_method for more information.

Loads the given file in the current session's context and evaluates it.
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