Expand description
Ruby load path builders.
An Artichoke Ruby VM may load code (called “features”) from several file
system locations. These locations form the $LOAD_PATH
global.
Code and native extensions from the Ruby Core library and Ruby Standard Library can be loaded from an in-memory virtual file system.
Users can prepend items to the load path at interpreter
boot by setting the RUBYLIB
environment variable.
This crate exports builders which can be used to construct the initial load path at interpreter boot. See their documentation for more details.
§Examples
use std::ffi::OsStr;
use std::path::PathBuf;
use mezzaluna_load_path::{RubyCore, Rubylib};
let core_loader = RubyCore::new();
let rubylib_loader = Rubylib::with_rubylib(OsStr::new("lib"))?;
// Assemble the load path in priority order.
let load_path = rubylib_loader
.into_load_path()
.into_iter()
.chain(core_loader.load_path().into_iter().map(PathBuf::from))
.collect::<Box<[PathBuf]>>();
assert_eq!(load_path.len(), 3);