blob: 837e2553ac1058b996f2e77b4f3b44b203dd49be (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
#
# loader.rb -
# $Release Version: 0.9.5$
# $Revision$
# $Date$
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
#
# --
#
#
#
module IRB
class LoadAbort < Exception;end
module IrbLoader
@RCS_ID='-$Id$-'
alias ruby_load load
alias ruby_require require
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
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
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
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
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
end
end
|