#ruby #repl #interpreter #plugin #vm

bin+lib rurust

High level Ruby VM bindings

13 releases

0.2.0 Feb 13, 2021
0.1.11 Oct 20, 2017
0.1.4 May 19, 2016

#32 in #repl

Download history 6/week @ 2022-11-29 19/week @ 2022-12-06 9/week @ 2022-12-13 13/week @ 2022-12-20 12/week @ 2022-12-27 3/week @ 2023-01-03 11/week @ 2023-01-10 8/week @ 2023-01-17 20/week @ 2023-01-24 26/week @ 2023-01-31 29/week @ 2023-02-07 47/week @ 2023-02-14 24/week @ 2023-02-21 6/week @ 2023-02-28 7/week @ 2023-03-07 33/week @ 2023-03-14

85 downloads per month
Used in 3 crates (via plugger-ruby)

MIT license

31KB
716 lines

rurust

Build Status Crates.io MIT licensed

A Rust wrapper over the MRI Ruby VM.

Documentation

Allows you to create a Ruby VM, eval code, plug classes, define modules, and insert C functions into the environment.

For a more high level library, take a look at plugger.

Examples

A simple REPL

extern fn callable_from_ruby() {
    println!("Hello World!");
}

fn main() {
    let mut vm = rurust::VM::new().unwrap();

    vm.class("Rust").
        method("hello_world", callable_from_ruby as *const _, 0).
        method("foo", callable_from_ruby as *const _, 0).
        build();

    loop {
        let mut line = String::new();
        std::io::stdin().read_line(&mut line).unwrap();

        let result = vm.eval(&line);
        println!("{:?}", result);
    }
}

Dependencies

~88KB