ESRuby
This project brings mruby to the browser. It uses emscripten (https://github.com/kripken/emscripten) to compile the mruby source code into JavaScript (ECMAScript) and runs in the browser. It is heavily based off webruby (https://github.com/xxuejie/webruby) but has been adjusted to work with the updates to emscripten and mruby.
Install
ESRuby depends on emsdk to provide a tool chain consisting of emscripten and LLVM. Although the tool chain is available from apt-get we will need to build emscripten from source using my branch as I have introduced some new features that have not made it into the release yet.
- we will start with a clean instance of Ubuntu 16.04 with ruby MRI installed
cdto a directory where you want emsdk downloadedgit clone https://github.com/juj/emsdk.gitcd emsdkgit reset --hard 313d5ef# optional, but it may help if you find thatmasteris too new for my fork- as per the documentation we will first install from the main repositories then replace emscripten with my fork:
./emsdk install sdk-incoming-64bit./emsdk activate sdk-incoming-64bitcd emscripten/incominggit remote add fork https://github.com/robfors/emscripten.gitgit fetch fork esrubygit checkout -b esruby fork/esrubycd ../..source ./emsdk_env.sh# calling this will add necessary paths to bash- optional: make the last command persistent by adding\
[ -f /path_to_emsdk/emsdk_env.sh ] && source /path_to_emsdk/emsdk_env.sh > /dev/null 2>&1\ to your.bashrcand.profile - verify emsdk is working with
emcc -v - install this gem with
gem install esruby
Try
- create a new esruby project with
esruby new project cd project- build the project with
esruby build config.rb - you will now have
www/app.jsandwww/index.html - a simple way to serve these files would be
ruby -run -e httpd www -p 4444 - the app with be available at http://localhost:4444 # License
This project is distributed under the MIT License. See LICENSE for further details.