0.0
No commit activity in last 3 years
No release in over 3 years
Server side Javascript runner in Ruby on Rails.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.7
~> 10.0
>= 0

Runtime

 Project Readme

SpreadBeaver

Server side Javascript runner in Ruby on Rails.
For example, you use to React + Flux + Server side rendering.

Installation

Add this line to your application's Gemfile:

gem 'spread_beaver'

Getting Started

Edit config/application.rb

# These are the defaults if you dont specify any yourself
config.spread_beaver.pool_size = 10 #ExecJS instance size
config.spread_beaver.timeout = 20 #ExecJS timeout
config.spread_beaver.bundle = "server-side-bundle.js" #Javascript file placed at under app/assets/javascripts

Create config/initializers/spread_beaver.rb (for example)

module SpreadBeaver
  class Runner
    # Execute javascript in javascript context before every SpreadBeaver::Runner.exec
    def initialize_script
      "clearAllStores();"
    end

    # Execute queued javascript in javascript context before every SpreadBeaver::Runner.exec
    def exec_queued_module module_name, props
      "#{module_name}.init(#{props_to_s(props)});"
    end

    # Execute javascript by SpreadBeaver::Runner.exec
    def exec_module module_name, props
      "#{module_name}.render(#{props_to_s(props)});"
    end
  end
end

API

  • SpreadBeaver::Runner.queue(module_name, props):
    Push hash that has passed values to request store.
    Execute exec_queued_module with stored hash data.

  • SpreadBeaver::Runner.exec(module_name, props):
    Execute exec_module with connection pooling.

Example

Rails, Browserify, React, Flux, Server side rendering example.
Go to https://github.com/oreshinya/spread_beaver/tree/master/example !