Home

Awesome

Plezi - a real-time web application framework for Ruby

Gem Version Inline docs GitHub

Note: at this point, plezi.io is mostly a wrapper around the iodine Ruby server. Use iodine directly if possible.

Are microservices on your mind? Do you dream of a an SPA that's easy to scale? Did you wonder if you could write a whole Websockets, RESTful AJAX back-end with just a few lines of code (business logic not included)?

Welcome to your new home with plezi.io, the Ruby real-time framework that assumes the business logic is seperate from the web service logic.

Short and Sweet

What if your next Pub/Sub application could be as easy as:

require 'plezi'
class MyChatroom
  # HTTP
  def index
    render :index
  end
  def on_open
    subscribe channel: :chat
    @name = ::ERB::Util.h(params[:nickname] || "anonymous")
    publish channel: :chat, message: "#{@name} joined the chat."
  end
  def on_message data
    publish channel: :chat, message: "#{@name}: #{::ERB::Util.h data}"
  end
  def on_shutdown
    write "Server is going away. Come back again some other time, #{@name}."
  end
end

Plezi.route '/(:nickname)', MyChatroom

What does Plezi have to offer?

Plezi is a Rack based framework with support for native (server side implemented) Websockets.

Plezi will provide the following features over plain Rack:

Things Plezi doesn't do (anymore / ever):

Do notice, Websockets require Iodine (the server), since (currently) it's the only Ruby server known to support native Websockets using a Websocket Callback Object.

Installation

Add this line to your application's Gemfile:

gem 'plezi'

And then execute:

$ bundle

Or install it yourself as:

$ gem install plezi

Usage

A new application (default applications include a simple chatroom demo):

 $  plezi new app_name

A simple hello world from irb:

require 'plezi'

class HelloWorld
  def index
    "Hello World!"
  end
end

Plezi.route '*', HelloWorld

exit # <= if running from terminal, this will start the server

Documentation

Plezi is fairly well documented.

Documentation is available both in the forms of tutorials and explanations available on the plezi.io website as well as through the YARD documentation.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/boazsegev/plezi.

License

The gem is available as open source under the terms of the MIT License.