Home

Awesome

opal-irb

Gem Version

irb (interactive ruby) for Opal (Ruby running on javascript). This is interactive console (REPL) on a webpage. Good for testing Opal/ruby interactively without having to install anything. Intended to be part of a browser based interactive development tool for Opal

Try it here: http://fkchang.github.io/opal-irb/index-jq.html

Embedded example http://fkchang.github.io/opal-irb/index-embeddable.html

Original https://github.com/larryng/coffeescript-repl based port http://fkchang.github.io/opal-irb/index-homebrew.html

Instructional Media

Videos:

Blogposts:

Presentations:

Features

HOW TOS

Embedding into opal apps

Lissio

Embedding into lissio app, as made by lissio new

# gem 'opal-irb', '0.7.0' for Opal 0.7.*
# gem 'opal-irb', '0.8.*' for Opal 0.8.*
# For latest do below
gem 'opal-irb', github: 'fkchang/opal-irb'
lissio start --require opal-irb
 <%= OpalIrbUtils.include_opal_irb_jqconsole_requirements %>
require 'opal'
require 'jqconsole'                     # add these 3 jqconsole support
require 'opal_irb_jqconsole_css'        # css for opal_irb_jqconsole_css
require 'opal_irb_jqconsole'            # the console code
require 'lissio'

  def start
    super
    element << DOM do
      button.show_irb! "Show Irb"
    end

    OpalIrbJqconsole.create_bottom_panel
    OpalIrbJqconsole.add_open_panel_behavior("show_irb")
  end

Rails

    # gem 'opal-irb', '0.7.0' for Opal 0.7.*
    # gem 'opal-irb', '0.8.*' for Opal 0.8.*
    # For latest do below
    gem 'opal-irb', github: 'fkchang/opal-irb', require: 'opal-irb-rails'
    gem 'jquery-ui-rails'
/*= require_self
 *= require jquery-ui/dialog
 *= require opal-irb/jqconsole
 */
//= require jquery-ui/dialog
require 'jquery-ui/dialog'
= OpalIrbUtils.include_code_mirror.html_safe
    require 'opal_irb_jqconsole'

    # opal-browser code to add a button
    $document["#workarea"] << DOM do
      button.show_irb! "Show Irb"
    end
    # opal-jquery code to add a button
    Element.find(".main").append "<button class='btn' id='show_irb'>Show Irb</button>"

    # creates a panel at the bottom
    OpalIrbJqconsole.create_bottom_panel(hidden=true)
    # adds open panel behavior to element w/id show_irb
    OpalIrbJqconsole.add_open_panel_behavior("show_irb")
    OpalIrbJqconsole.create_bottom_panel(hidden=true)
    OpalIrbJqconsole.add_hot_key_panel_behavior(modifiers: %w(meta shift), key: "c")

Dependencies

Version Scheme

While in my mind there are a lot of things that keep opal-irb at not yet suitable to be a gem/ 0.1.0 version number, I frequently have to change code to support the latest minor release for Opal, so I think I need to adopt a scheme that tracks such. So the 1st gem release will be 0.7.0, to indicate compatibility with 0.7.* versions of opal, followed fairly quickly with a 0.8.0 release to match 0.8.0 the current version (at time of writing) of opal.

Roadmap