Skip to content
Branch: master
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
LICENSE Create planout ruby gem Dec 21, 2014


Gem Version Build Status


This is a rough implementation of the Experiment / logging infrastructure for running PlanOut experiments, with all the random assignment operators available in Python. This port is nearly a line-by-line port, and produces assignments that are completely consistent with those produced by the Python reference implementation.


Add this line to your application's Gemfile:

gem 'planout'

And then execute:

$ bundle

Or install it yourself as:

$ gem install planout

How it works

This defines a simple experiment that randomly assigns three variables, foo, bar, and baz. foo and baz use userid as input, while bar uses a pair, namely userid combined with the value of foo from the prior step.

module PlanOut
  class VotingExperiment < SimpleExperiment
    # Experiment#assign takes params and an input array
    def assign(params, **inputs)
      userid = inputs[:userid]

      params[:button_color] ={
        choices: ['ff0000', '#00ff00'],
        unit: userid

      params[:button_text] ={
        choices: ["I'm voting", "I'm a voter"],
        unit: userid,

Then, we can examine the assignments produced for a few input userids. Note that since exposure logging is enabled by default, all of the experiments' inputs, configuration information, timestamp, and parameter assignments are pooped out via the Logger class.

my_exp = 14)
my_button_color = my_exp.get(:button_color)
button_text = my_exp.get(:button_text)
puts "button color is #{my_button_color} and button text is #{button_text}."

The output of the Ruby script looks something like this:

logged data: {"name":"PlanOut::VotingExperiment","time":1404944726,"salt":"PlanOut::VotingExperiment","inputs":{"userid":14},"params":{"button_color":"ff0000","button_text":"I'm a voter"},"event":"exposure"}

button color is ff0000 and button text is I'm a voter.


For examples please refer to the examples directory.

Running the tests

Make sure you're in the ruby implementation directory of PlanOut and run

rake or rake test

to run the entire test suite.

If you wish to run a specific test, run

rake test TEST=test/testname.rb or even better ruby test/testname.rb

You can’t perform that action at this time.