README.mdown in split-0.6.2 vs README.mdown in split-0.6.3

- old
+ new

@@ -7,11 +7,12 @@ Split is designed to be hacker friendly, allowing for maximum customisation and extensibility. [![Gem Version](https://badge.fury.io/rb/split.png)](http://badge.fury.io/rb/split) [![Build Status](https://secure.travis-ci.org/andrew/split.png?branch=master)](http://travis-ci.org/andrew/split) [![Dependency Status](https://gemnasium.com/andrew/split.png)](https://gemnasium.com/andrew/split) -[![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/andrew/split) +[![Code Climate](https://codeclimate.com/github/andrew/split.png)](https://codeclimate.com/github/andrew/split) +[![Coverage Status](https://coveralls.io/repos/andrew/split/badge.png)](https://coveralls.io/r/andrew/split) ## Requirements Split uses redis as a datastore. @@ -215,10 +216,39 @@ Split.configure do |config| config.persistence = YourCustomAdapterClass end ``` +### Trial Event Hooks + +You can define methods that will be called at the same time as experiment +alternative participation and goal completion. + +For example: + +``` ruby +Split.configure do |config| + config.on_trial_choose = :log_trial_choice + config.on_trial_complete = :log_trial_complete +end +``` + +Set these attributes to a method name available in the same context as the +`ab_test` method. These methods should accept one argument, a `Trial` instance. + +``` ruby +def log_trial_choose(trial) + logger.info "experiment=%s alternative=%s user=%s" % + [ trial.experiment.name, trial.alternative, current_user.id ] +end + +def log_trial_complete(trial) + logger.info "experiment=%s alternative=%s user=%s complete=true" % + [ trial.experiment.name, trial.alternative, current_user.id ] +end +``` + ## Web Interface Split comes with a Sinatra-based front end to get an overview of how your experiments are doing. If you are running Rails 2: You can mount this inside your app using Rack::URLMap in your `config.ru` @@ -248,9 +278,20 @@ ```ruby Split::Dashboard.use Rack::Auth::Basic do |username, password| username == 'admin' && password == 'p4s5w0rd' end ``` + +You can even use Devise or any other Warden-based authentication method to authorize users. Just replace `mount Split::Dashboard, :at => 'split'` in `config/routes.rb` with the following: +```ruby +match "/split" => Split::Dashboard, :anchor => false, :constraints => lambda { |request| + request.env['warden'].authenticated? # are we authenticated? + request.env['warden'].authenticate! # authenticate if not already + # or even check any other condition such as request.env['warden'].user.is_admin? +} +``` + +More information on this [here](http://steve.dynedge.co.uk/2011/12/09/controlling-access-to-routes-and-rack-apps-in-rails-3-with-devise-and-warden/) ### Screenshot ![split_screenshot](https://f.cloud.github.com/assets/78887/306152/99c64650-9670-11e2-93f8-197f49495d02.png)