Module IRB::IrbLoader
In: lib/irb/ext/loader.rb

Methods

External Aliases

load -> ruby_load
require -> ruby_require

Public Instance methods

[Source]

    # File lib/irb/ext/loader.rb, line 23
23:     def irb_load(fn, priv = nil)
24:       path = search_file_from_ruby_path(fn)
25:       raise LoadError, "No such file to load -- #{fn}" unless path
26: 
27:       load_file(path, priv)
28:     end

[Source]

    # File lib/irb/ext/loader.rb, line 63
63:     def load_file(path, priv = nil)
64:       irb.suspend_name(path, File.basename(path)) do
65:         
66:         if priv
67:           ws = WorkSpace.new(Module.new)
68:         else
69:           ws = WorkSpace.new
70:         end
71:         irb.suspend_workspace(ws) do
72:           irb.suspend_input_method(FileInputMethod.new(path)) do
73:             |back_io|
74:             irb.signal_status(:IN_LOAD) do 
75: #             p irb.conf
76:               if back_io.kind_of?(FileInputMethod)
77:                 irb.eval_input
78:               else
79:                 begin
80:                   irb.eval_input
81:                 rescue LoadAbort
82:                   print "load abort!!\n"
83:                 end
84:               end
85:             end
86:           end
87:         end
88:       end
89:     end

[Source]

     # File lib/irb/ext/loader.rb, line 91
 91:     def old
 92:       back_io = @io
 93:       back_path = @irb_path
 94:       back_name = @irb_name
 95:       back_scanner = @irb.scanner
 96:       begin
 97:         @io = FileInputMethod.new(path)
 98:         @irb_name = File.basename(path)
 99:         @irb_path = path
100:         @irb.signal_status(:IN_LOAD) do
101:           if back_io.kind_of?(FileInputMethod)
102:             @irb.eval_input
103:           else
104:             begin
105:               @irb.eval_input
106:             rescue LoadAbort
107:               print "load abort!!\n"
108:             end
109:           end
110:         end
111:       ensure
112:         @io = back_io
113:         @irb_name = back_name
114:         @irb_path = back_path
115:         @irb.scanner = back_scanner
116:       end
117:     end

[Source]

    # File lib/irb/ext/loader.rb, line 30
30:     def search_file_from_ruby_path(fn)
31:       if /^#{Regexp.quote(File::Separator)}/ =~ fn
32:         return fn if File.exist?(fn)
33:         return nil
34:       end
35: 
36:       for path in $:
37:         if File.exist?(f = File.join(path, fn))
38:           return f
39:         end
40:       end
41:       return nil
42:     end

[Source]

    # File lib/irb/ext/loader.rb, line 44
44:     def source_file(path)
45:       irb.suspend_name(path, File.basename(path)) do
46:         irb.suspend_input_method(FileInputMethod.new(path)) do
47:           |back_io|
48:           irb.signal_status(:IN_LOAD) do 
49:             if back_io.kind_of?(FileInputMethod)
50:               irb.eval_input
51:             else
52:               begin
53:                 irb.eval_input
54:               rescue LoadAbort
55:                 print "load abort!!\n"
56:               end
57:             end
58:           end
59:         end
60:       end
61:     end

[Validate]