Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Coffescript was so cool…

branch: master

This branch is 0 commits ahead and 0 commits behind master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 bin
Octocat-spinner-32 lib
Octocat-spinner-32 .gitignore
Octocat-spinner-32 .npmignore
Octocat-spinner-32 MIT-LICENSE
Octocat-spinner-32 README.md
Octocat-spinner-32 package.json
README.md

Opal for Node.js

Use Ruby on Node.js for REAL-WORLD rofl-SCALING


Use Node.js FOR SPEED

@RoflscaleTips


@hipsterhacker I approve of your choices of roflscale technologies, particularly Node. Your roflmillions of users will appreciate it.

@RoflscaleTips


mongodb should be ported to nodejs for improved scalability

@RoflscaleTips

Usage

Run with opal-node app.opal

Example

A naive rack-like implementation for Opal-Ruby

# server.rb
class Server
  def initialize port
    @http = `require('http')`
    @port = port
  end

  def start &block
    %x{
      this.http.createServer(function(req, res) {
        var rackResponse = (block.call(block._s, req, res));
        res.end(rackResponse[2].join(' '));
      }).listen(this.port);
    }
  end
end

# app.rb
require 'server'
server = Server.new 3000
server.start do
  [200, {'Content-Type' => 'text/plain'}, ["Hello World!\n"]]
end

This is the original Node.js example:

# the original nodejs example
http = require('http')
var port = process.env.port || 1337;
http.createServer(function(req, res) {
  res.writeHead(200, { 'Content-Type': 'text/plain' });
  res.end('Hello World\n');
}).listen(port);

Requirements

You need Node.js and Opal (v0.3.19)

gem install opal -v0.3.19

License

This project rocks and uses MIT-LICENSE.

Something went wrong with that request. Please try again.