Ruby bindings for Barrister RPC
Switch branches/tags
Nothing to show
Clone or download
Pull request Compare This branch is 3 commits ahead of coopernurse:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Barrister for Ruby

This project contains Ruby bindings for the Barrister RPC system.


Install the package:

gem install barrister

If you are writing a server, you will also need the main barrister command line tool to convert your IDL files to JSON. It's written in Python, and can be installed via:

pip install barrister

See the docs for more information on the barrister tool and IDL format.

Basic Usage


require 'barrister'

# specify URL to the server endpoint
trans ="http://localhost:7667/calc")

# automatically connects to endpoint and loads IDL JSON contract
# also creates proxy classes on client - one per interface in the IDL
client =

# make a RPC call
# in this example the server exposes a "Calculator" interface 
# that contains a "add" method.
puts client.Calculator.add(1, 5.1)


Note, there's no requirement to use Sinatra. Any web framework that provides access to the raw POST data is probably fair game.

Given this IDL:

// file: calc.idl
interface Calculator {
    add(a float, b float) float
    subtract(a float, b float) float

That you translate via:

barrister -t "Calculator Service" -j calc.json calc.idl

Then you could write this server:

require 'sinatra'
require 'barrister'

# Define a class that implements the functions in the interface
class Calculator

  def add(a, b)
    return a+b

  def subtract(a, b)
    return a-b


# Load the IDL JSON file and create a Server instance
contract = Barrister::contract_from_file("calc.json")
server   =

# Bind your class to the Calculator interface
# If your IDL has multiple interfaces, you would bind
# them all to the same server instance.

# Serve it up
post '/calc' do
  resp = server.handle_json(
  status 200
  headers "Content-Type" => "application/json"


Developed on MacOS with Ruby 1.9.3. CI tests run on Linux against Ruby 1.8.7.

Depends on the json gem.

More information


Distributed under the MIT license. See LICENSE file for details.

Release / Tag notes

Note to self on how to tag release

# Edit `barrister.gemspec`, bump version and date, then run:

make all
git add -u
git commit -m "bump gem v0.1.0"
git tag -a v0.1.0 -m "version 0.1.0"
git push --tags
make publish