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);
RUBY_DTRACE_HOOK(LOAD_ENTRY, StringValuePtr(fname));
orig_fname = rb_get_path_check_to_string(fname, rb_safe_level());
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));
RUBY_DTRACE_HOOK(LOAD_RETURN, StringValuePtr(fname));
return Qtrue;
}