Class: IRB::ExtendCommand::Require

Inherits:
Nop show all
Includes:
IrbLoader
Defined in:
lib/irb/cmd/load.rb

Instance Attribute Summary

Attributes inherited from Nop

#irb_context

Instance Method Summary collapse

Methods included from IrbLoader

#irb_load, #load_file, #old, #search_file_from_ruby_path, #source_file

Methods inherited from Nop

execute, #initialize, #irb

Constructor Details

This class inherits a constructor from IRB::ExtendCommand::Nop

Instance Method Details

#execute(file_name) ⇒ Object


30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/irb/cmd/load.rb', line 30

def execute(file_name)
# return ruby_require(file_name) unless IRB.conf[:USE_LOADER]

  rex = Regexp.new("#{Regexp.quote(file_name)}(\.o|\.rb)?")
  return false if $".find{|f| f =~ rex}

  case file_name
  when /\.rb$/
    begin
      if irb_load(file_name)
 $".push file_name
 return true
      end
    rescue LoadError
    end
  when /\.(so|o|sl)$/
    return ruby_require(file_name)
  end

  begin
    irb_load(f = file_name + ".rb")
    $".push f
    return true
  rescue LoadError
    return ruby_require(file_name)
  end
end