PageRenderTime 105ms CodeModel.GetById 99ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/tools/Ruby/lib/ruby/1.8/irb/cmd/load.rb

http://github.com/agross/netopenspace
Ruby | 67 lines | 44 code | 10 blank | 13 comment | 2 complexity | bfe6e70866c8b4dc19e9c813f8cb639e MD5 | raw file
 1#
 2#   load.rb - 
 3#   	$Release Version: 0.9.5$
 4#   	$Revision: 11708 $
 5#   	$Date: 2007-02-13 08:01:19 +0900 (Tue, 13 Feb 2007) $
 6#   	by Keiju ISHITSUKA(keiju@ruby-lang.org)
 7#
 8# --
 9#
10#   
11#
12
13require "irb/cmd/nop.rb"
14require "irb/ext/loader"
15
16module IRB
17  module ExtendCommand
18    class Load<Nop
19      include IrbLoader
20
21      def execute(file_name, priv = nil)
22#	return ruby_load(file_name) unless IRB.conf[:USE_LOADER]
23	return irb_load(file_name, priv)
24      end
25    end
26
27    class Require<Nop
28      include IrbLoader
29      
30      def execute(file_name)
31#	return ruby_require(file_name) unless IRB.conf[:USE_LOADER]
32
33	rex = Regexp.new("#{Regexp.quote(file_name)}(\.o|\.rb)?")
34	return false if $".find{|f| f =~ rex}
35
36	case file_name
37	when /\.rb$/
38	  begin
39	    if irb_load(file_name)
40	      $".push file_name
41	      return true
42	    end
43	  rescue LoadError
44	  end
45	when /\.(so|o|sl)$/
46	  return ruby_require(file_name)
47	end
48	
49	begin
50	  irb_load(f = file_name + ".rb")
51	  $".push f
52	  return true
53	rescue LoadError
54	  return ruby_require(file_name)
55	end
56      end
57    end
58
59    class Source<Nop
60      include IrbLoader
61      def execute(file_name)
62	source_file(file_name)
63      end
64    end
65  end
66
67end