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);
core-env-system- Enabled by default. This 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- Enabled by default. This enables additional dependencies to implement some functions in the
Mathmodule. When this feature is disabled, these functions raise
core-random- Enabled by default. This includes an implementation of the
Randomclass. This feature includes additional dependencies. When this feature is disabled, Artichoke does not have support for generating psuedorandom numbers.
stdlib-securerandom- Enabled by default. This feature includes 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.