Git Product home page Git Product logo

esruby's Introduction

esruby

This project brings mruby to the browser. It uses emscripten to compile the mruby source code into JavaScript (ECMAScript) and runs in the browser. It is heavily based off 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
  • sudo apt-get install build-essential cmake python nodejs
  • sudo apt-get install default-jre-headless # you will need a recent version of java if you want to run Closure Compiler when compiling any apps with optimization enabled
  • cd to a directory where you want emsdk downloaded
  • git clone https://github.com/juj/emsdk.git
  • cd emsdk
  • git reset --hard 313d5ef # optional, but it may help if you find that master is 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-64bit
  • cd emscripten/incoming
  • git remote add fork https://github.com/robfors/emscripten.git
  • git fetch fork esruby
  • git checkout -b esruby fork/esruby
  • cd ../..
  • 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 .bashrc and .profile
  • verify the emsdk environment has been successfully setup with emcc -v, errors in red are normal
  • 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.js and www/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

Binding with JS

Explore my esruby-bind gem that binds the Ruby and JS environments together.

Documentation

  • Kernel#exit : returns execution to the JavaScript event loop. It will skip the rest of the Ruby code by raising and capturing an exception inherited from Exception. It will not shutdown the interpreter, therefore any future calls to the Ruby environment from JavaScript will function as expected.

License

This project is distributed under the MIT License. See LICENSE for further details.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.