/ferrocarril

💎 Experiments to embed Ruby on Rails in Rust with mruby

Primary LanguageRustMIT LicenseMIT

ferrocarril

CircleCI

ferrocarril aims to embed a Ruby on Rails web application that talks to an external MySQL database in Rust and serve the app with Rocket.

ferrocarril means railway in Spanish and sounds like ferrous which means containing iron.

foolsgold

The foolsgold crate is an early attempt to achieve the goal of a Rust-backed Ruby web application.

Usage

cargo run --bin foolsgold

Then, open http://localhost:8000 on your browser.

Features

REPL

Crate mruby-bin provides an rirb executable that is an IRB shell and REPL for the mruby interpreter in this workspace. rirb aims to load every extension to mruby made by this workspace in addition to all gems in the gems crate.

Usage

cargo run --bin rirb

Contributing

There is a lot to build! If you'd like to help out, take a look at the open issues. Tickets that are tagged with good first issue might be a good introduction to the codebase.

Code Overview

To familiarize yourself with the code in this workspace, consider reviewing these source files:

File Purpose Learning Objective
manual.rs mruby crate integration test Define Rust-backed Ruby sources
nemesis.rs nemesis crate Ruby runtime Define a Gem
ffi_tests.rs C API test suite Manipulate an interpreter with the C API
repl.rs REPL loop for rirb Eval code on an interpreter and handle errors

Known Missing Features

Core

mruby does not implement all Ruby 2.6 core classes.

Required classes include (at least):

  • File
  • IO
  • Regexp

Standard Library

mruby does not implement any of the Ruby 2.6 standard library.

Required packages include (at least):

  • forwardable
  • json
  • set
  • stringio
  • time
  • uri
  • zlib

Gems

Rails requires lots of gems. This workspace maintains a registry of vendored gems. To support the goal of running Rails, this crate identifies dependencies, vendors the gem sources, patches gems so they parse on mruby, reimplements C extensions in Rust, and runs the tests for each gem.