This crate provides:
- An embeddable Ruby interpreter, which can be created with the
- A Rust and Ruby implementation of Ruby Core and Standard Library using high-quality Rust dependencies and modern Ruby.
- Support for injecting Rust code and types into the interpreter with a
- The ability to disable parts of the interpreter VM or library functions at
compile time. For example, deny access to the system environ by disabling
You can create an interpreter and begin executing code on it:
use artichoke::prelude::*; let mut interp = artichoke::interpreter()?; let result = interp.eval(b"2 + 5")?;
Artichoke supports calling Ruby functions from Rust and converting between Ruby boxed values and Rust native types:
use artichoke::prelude::*; let mut interp = artichoke::interpreter()?; let s = interp.convert_mut("💎"); let codepoint = s.funcall(&mut interp, "ord", & /* args */, None /* block */)?; let codepoint = codepoint.try_into::<u32>(&interp)?; assert_eq!(128142, codepoint);
All features are enabled by default.
- core-env-system - Activates the
std::envbackend for the
ENVobject. When this feature is disabled, access to the environ is emulated with an in-memory store.
- core-math-extra - Activates additional dependencies to implement some
functions in the
Mathmodule. When this feature is disabled, these functions raise
- core-random - Include an implementation of the
Randomclass. This feature includes additional dependencies. When this feature is disabled, Artichoke does not have support for generating psuedorandom numbers.
- core-time - Include an implementation of the
Timeclass. This feature includes additional dependencies. When this feature is disabled, Artichoke does not have datetime support.
- stdlib-securerandom - An implementation of a CSPRNG for the
SecureRandommodule. This feature includes additional dependencies. When this feature is disabled, the
SecureRandommodule is not present.
Detect if Ruby code parses successfully.
A "prelude" for users of the
A REPL (read–eval–print–loop) for an Artichoke interpreter.
Artichoke CLI entrypoint.
Create a new Artichoke Ruby interpreter.