load(p1, p2 = v2)
public
Loads and executes the Ruby program in the file filename. If the
filename does not resolve to an absolute path, the file is searched for in
the library directories listed in $:. If the optional wrap
parameter is true, the loaded script will be executed under an
anonymous module, protecting the calling program’s global namespace. In
no circumstance will any local variables in the loaded file be propagated
to the loading environment.
Show source
static VALUE
rb_f_load(int argc, VALUE *argv)
{
VALUE fname, wrap, path, orig_fname;
rb_scan_args(argc, argv, "11", &fname, &wrap);
if (RUBY_DTRACE_LOAD_ENTRY_ENABLED()) {
RUBY_DTRACE_LOAD_ENTRY(StringValuePtr(fname),
rb_sourcefile(),
rb_sourceline());
}
orig_fname = FilePathValue(fname);
fname = rb_str_encode_ospath(orig_fname);
path = rb_find_file(fname);
if (!path) {
if (!rb_file_load_ok(RSTRING_PTR(fname)))
load_failed(orig_fname);
path = fname;
}
rb_load_internal(path, RTEST(wrap));
if (RUBY_DTRACE_LOAD_RETURN_ENABLED()) {
RUBY_DTRACE_LOAD_RETURN(StringValuePtr(fname),
rb_sourcefile(),
rb_sourceline());
}
return Qtrue;
}