Extended maintenance of Ruby 1.9.3 ended on February 23, 2015. Read more

In Files

  • irb/ext/loader.rb

IRB::IrbLoader

Public Instance Methods

irb_load(fn, priv = nil) click to toggle source
 
               # File irb/ext/loader.rb, line 22
def irb_load(fn, priv = nil)
  path = search_file_from_ruby_path(fn)
  raise LoadError, "No such file to load -- #{fn}" unless path

  load_file(path, priv)
end
            
load_file(path, priv = nil) click to toggle source
 
               # File irb/ext/loader.rb, line 62
    def load_file(path, priv = nil)
      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
          irb.suspend_input_method(FileInputMethod.new(path)) do
            |back_io|
            irb.signal_status(:IN_LOAD) do
#             p irb.conf
              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
            
old() click to toggle source
 
               # File irb/ext/loader.rb, line 90
def old
  back_io = @io
  back_path = @irb_path
  back_name = @irb_name
  back_scanner = @irb.scanner
  begin
    @io = FileInputMethod.new(path)
    @irb_name = File.basename(path)
    @irb_path = path
    @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
  ensure
    @io = back_io
    @irb_name = back_name
    @irb_path = back_path
    @irb.scanner = back_scanner
  end
end
            
search_file_from_ruby_path(fn) click to toggle source
 
               # File irb/ext/loader.rb, line 29
def search_file_from_ruby_path(fn)
  if /^#{Regexp.quote(File::Separator)}/ =~ fn
    return fn if File.exist?(fn)
    return nil
  end

  for path in $:
    if File.exist?(f = File.join(path, fn))
      return f
    end
  end
  return nil
end
            
source_file(path) click to toggle source
 
               # File irb/ext/loader.rb, line 43
def source_file(path)
  irb.suspend_name(path, File.basename(path)) do
    irb.suspend_input_method(FileInputMethod.new(path)) 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
            

Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.

If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.

If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.

If you want to help improve the Ruby documentation, please visit Documenting-ruby.org.