Skip to content

Commit d97fb57

Browse files
committed
Renamed the project to Split
1 parent a36f935 commit d97fb57

16 files changed

Lines changed: 119 additions & 117 deletions

‎Gemfile‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
source "http://rubygems.org"
22

3-
# Specify your gem's dependencies in multivariate.gemspec
43
gemspec

‎README.mdown‎

Lines changed: 34 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
# Multivariate
2-
## Rack based multivariate testing framework
1+
# Split
2+
## Rack based split testing framework
33

4-
Multivariate is a rack based ab testing framework designed to work with Rails, Sinatra or any other rack based app.
4+
Split is a rack based ab testing framework designed to work with Rails, Sinatra or any other rack based app.
55

6-
Multivariate is heavily inspired by the Abingo and Vanity rails ab testing plugins and Resque in its use of Redis.
6+
Split is heavily inspired by the Abingo and Vanity rails ab testing plugins and Resque in its use of Redis.
77

88
## Requirements
99

10-
Multivariate uses redis as a datastore.
10+
Split uses redis as a datastore.
1111

1212
If you're on OS X, Homebrew is the simplest way to install Redis:
1313

@@ -18,33 +18,33 @@ You now have a Redis daemon running on 6379.
1818

1919
## Setup
2020

21-
If you are using bundler add multivariate to your Gemfile:
21+
If you are using bundler add split to your Gemfile:
2222

23-
gem 'multivariate'
23+
gem 'split'
2424

2525
Then run:
2626

2727
bundle install
2828

2929
Otherwise install the gem:
3030

31-
gem install multivariate
31+
gem install split
3232

3333
and require it in your project:
3434

35-
require 'multivariate'
35+
require 'split'
3636

3737
### Rails
3838

39-
Multivariate is autoloaded when rails starts up, as long as you've configured redis it will 'just work'.
39+
Split is autoloaded when rails starts up, as long as you've configured redis it will 'just work'.
4040

4141
### Sinatra
4242

43-
To configure sinatra with Multivariate you need to enable sessions and mix in the helper methods. Add the following lines at the top of your sinatra app:
43+
To configure sinatra with Split you need to enable sessions and mix in the helper methods. Add the following lines at the top of your sinatra app:
4444

4545
class MySinatraApp < Sinatra::Base
4646
enable :sessions
47-
helpers Multivariate::Helper
47+
helpers Split::Helper
4848

4949
get '/' do
5050
...
@@ -86,40 +86,40 @@ Example: Conversion tracking (in a view)
8686

8787
## Web Interface
8888

89-
Multivariate comes with a Sinatra-based front end to get an overview of how your experiments are doing.
89+
Split comes with a Sinatra-based front end to get an overview of how your experiments are doing.
9090

9191
You can mount this inside your app using Rack::URLMap in your `config.ru`
9292

93-
require 'multivariate/dashboard'
93+
require 'split/dashboard'
9494

9595
run Rack::URLMap.new \
9696
"/" => Your::App.new,
97-
"/multivariate" => Multivariate::Dashboard.new
97+
"/split" => Split::Dashboard.new
9898

9999
You may want to password protect that page, you can do so with `Rack::Auth::Basic`
100100

101-
Multivariate::Dashboard.use Rack::Auth::Basic do |username, password|
101+
Split::Dashboard.use Rack::Auth::Basic do |username, password|
102102
username == 'admin' && password == 'p4s5w0rd'
103103
end
104104

105105
## Configuration
106106

107-
You may want to change the Redis host and port Multivariate connects to, or
107+
You may want to change the Redis host and port Split connects to, or
108108
set various other options at startup.
109109

110-
Multivariate has a `redis` setter which can be given a string or a Redis
111-
object. This means if you're already using Redis in your app, Multivariate
110+
Split has a `redis` setter which can be given a string or a Redis
111+
object. This means if you're already using Redis in your app, Split
112112
can re-use the existing connection.
113113

114-
String: `Multivariate.redis = 'localhost:6379'`
114+
String: `Split.redis = 'localhost:6379'`
115115

116-
Redis: `Multivariate.redis = $redis`
116+
Redis: `Split.redis = $redis`
117117

118-
For our rails app we have a `config/initializers/multivariate.rb` file where
119-
we load `config/multivariate.yml` by hand and set the Redis information
118+
For our rails app we have a `config/initializers/split.rb` file where
119+
we load `config/split.yml` by hand and set the Redis information
120120
appropriately.
121121

122-
Here's our `config/multivariate.yml`:
122+
Here's our `config/split.yml`:
123123

124124
development: localhost:6379
125125
test: localhost:6379
@@ -132,22 +132,22 @@ And our initializer:
132132
rails_root = ENV['RAILS_ROOT'] || File.dirname(__FILE__) + '/../..'
133133
rails_env = ENV['RAILS_ENV'] || 'development'
134134

135-
multivariate_config = YAML.load_file(rails_root + '/config/multivariate.yml')
136-
Multivariate.redis = multivariate_config[rails_env]
135+
split_config = YAML.load_file(rails_root + '/config/split.yml')
136+
Split.redis = split_config[rails_env]
137137

138138
## Namespaces
139139

140-
If you're running multiple, separate instances of Multivariate you may want
140+
If you're running multiple, separate instances of Split you may want
141141
to namespace the keyspaces so they do not overlap. This is not unlike
142142
the approach taken by many memcached clients.
143143

144144
This feature is provided by the [redis-namespace][rs] library, which
145-
Multivariate uses by default to separate the keys it manages from other keys
145+
Split uses by default to separate the keys it manages from other keys
146146
in your Redis server.
147147

148-
Simply use the `Multivariate.redis.namespace` accessor:
148+
Simply use the `Split.redis.namespace` accessor:
149149

150-
Multivariate.redis.namespace = "resque:GitHub"
150+
Split.redis.namespace = "resque:GitHub"
151151

152152
We recommend sticking this in your initializer somewhere after Redis
153153
is configured.
@@ -171,4 +171,7 @@ Special thanks to the following people for submitting patches:
171171

172172
## Copyright
173173

174-
Copyright (c) 2011 Andrew Nesbitt. See LICENSE for details.
174+
Copyright (c) 2011 Andrew Nesbitt. See LICENSE for details.
175+
176+
177+
n.b don't pass the same alternative twice!
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
require 'rubygems'
2-
require 'multivariate/experiment'
3-
require 'multivariate/alternative'
4-
require 'multivariate/helper'
2+
require 'split/experiment'
3+
require 'split/alternative'
4+
require 'split/helper'
55
require 'redis/namespace'
66

7-
module Multivariate
7+
module Split
88
extend self
99
# Accepts:
1010
# 1. A 'hostname:port' string
@@ -23,13 +23,13 @@ def redis=(server)
2323
redis = Redis.new(:host => host, :port => port,
2424
:thread_safe => true, :db => db)
2525
end
26-
namespace ||= :multivariate
26+
namespace ||= :split
2727

2828
@redis = Redis::Namespace.new(namespace, :redis => redis)
2929
elsif server.respond_to? :namespace=
3030
@redis = server
3131
else
32-
@redis = Redis::Namespace.new(:multivariate, :redis => server)
32+
@redis = Redis::Namespace.new(:split, :redis => server)
3333
end
3434
end
3535

@@ -44,7 +44,7 @@ def redis
4444

4545
if defined?(Rails)
4646
class ActionController::Base
47-
ActionController::Base.send :include, Multivariate::Helper
48-
ActionController::Base.helper Multivariate::Helper
47+
ActionController::Base.send :include, Split::Helper
48+
ActionController::Base.helper Split::Helper
4949
end
5050
end
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module Multivariate
1+
module Split
22
class Alternative
33
attr_accessor :name
44
attr_accessor :participant_count
@@ -33,7 +33,7 @@ def z_score
3333
# E = the number of impressions within the experiment split
3434
# C = the number of impressions within the control split
3535

36-
experiment = Multivariate::Experiment.find(@experiment_name)
36+
experiment = Split::Experiment.find(@experiment_name)
3737
control = experiment.alternatives[0]
3838
alternative = self
3939

@@ -51,16 +51,16 @@ def z_score
5151
end
5252

5353
def save
54-
if Multivariate.redis.hgetall("#{experiment_name}:#{name}")
55-
Multivariate.redis.hset "#{experiment_name}:#{name}", 'participant_count', @participant_count
56-
Multivariate.redis.hset "#{experiment_name}:#{name}", 'completed_count', @completed_count
54+
if Split.redis.hgetall("#{experiment_name}:#{name}")
55+
Split.redis.hset "#{experiment_name}:#{name}", 'participant_count', @participant_count
56+
Split.redis.hset "#{experiment_name}:#{name}", 'completed_count', @completed_count
5757
else
58-
Multivariate.redis.hmset "#{experiment_name}:#{name}", 'participant_count', 'completed_count', @participant_count, @completed_count
58+
Split.redis.hmset "#{experiment_name}:#{name}", 'participant_count', 'completed_count', @participant_count, @completed_count
5959
end
6060
end
6161

6262
def self.find(name, experiment_name)
63-
counters = Multivariate.redis.hgetall "#{experiment_name}:#{name}"
63+
counters = Split.redis.hgetall "#{experiment_name}:#{name}"
6464
self.new(name, experiment_name, counters)
6565
end
6666

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
require 'sinatra/base'
2-
require 'multivariate'
2+
require 'split'
33

4-
module Multivariate
4+
module Split
55
class Dashboard < Sinatra::Base
66
dir = File.dirname(File.expand_path(__FILE__))
77

@@ -20,13 +20,13 @@ def path_prefix
2020
end
2121

2222
get '/' do
23-
@experiments = Multivariate::Experiment.all
23+
@experiments = Split::Experiment.all
2424
erb :index
2525
end
2626

2727
post '/:experiment' do
28-
@experiment = Multivariate::Experiment.find(params[:experiment])
29-
@alternative = Multivariate::Alternative.find(params[:alternative], params[:experiment])
28+
@experiment = Split::Experiment.find(params[:experiment])
29+
@alternative = Split::Alternative.find(params[:alternative], params[:experiment])
3030
@experiment.winner = @alternative.name
3131
@experiment.save
3232
redirect url('/')
File renamed without changes.
File renamed without changes.

lib/multivariate/dashboard/views/index.erb renamed to lib/split/dashboard/views/index.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<h1>Multivariate Dashboard</h1>
1+
<h1>Split Dashboard</h1>
22
<p class="intro">The list below contains all the registered experiments along with the number of test participants, completed and conversion rate currently in the system.</p>
33

44
<% @experiments.each do |experiment| %>

lib/multivariate/dashboard/views/layout.erb renamed to lib/split/dashboard/views/layout.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<link href="<%= url 'reset.css' %>" media="screen" rel="stylesheet" type="text/css">
66
<link href="<%= url 'style.css' %>" media="screen" rel="stylesheet" type="text/css">
77

8-
<title>Multivariate</title>
8+
<title>Split</title>
99

1010
</head>
1111
<body>
@@ -16,7 +16,7 @@
1616
</div>
1717

1818
<div id="footer">
19-
<p>Powered by <a href="http://github.com/andrew/multivariate">Multivariate</a> v<%=Multivariate::VERSION %></p>
19+
<p>Powered by <a href="http://github.com/andrew/split">Split</a> v<%=Split::VERSION %></p>
2020
</div>
2121
</body>
2222
</html>
Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module Multivariate
1+
module Split
22
class Experiment
33
attr_accessor :name
44
attr_accessor :alternatives
@@ -10,45 +10,45 @@ def initialize(name, *alternatives)
1010
end
1111

1212
def winner
13-
if w = Multivariate.redis.hget(:experiment_winner, name)
14-
return Multivariate::Alternative.find(w, name)
13+
if w = Split.redis.hget(:experiment_winner, name)
14+
return Split::Alternative.find(w, name)
1515
else
1616
nil
1717
end
1818
end
1919

2020
def winner=(winner_name)
21-
Multivariate.redis.hset(:experiment_winner, name, winner_name.to_s)
21+
Split.redis.hset(:experiment_winner, name, winner_name.to_s)
2222
end
2323

2424
def alternatives
25-
@alternatives.map {|a| Multivariate::Alternative.find_or_create(a, name)}
25+
@alternatives.map {|a| Split::Alternative.find_or_create(a, name)}
2626
end
2727

2828
def next_alternative
2929
winner || alternatives.sort_by{|a| a.participant_count + rand}.first
3030
end
3131

3232
def save
33-
Multivariate.redis.sadd(:experiments, name)
34-
@alternatives.each {|a| Multivariate.redis.sadd(name, a) }
33+
Split.redis.sadd(:experiments, name)
34+
@alternatives.each {|a| Split.redis.sadd(name, a) }
3535
end
3636

3737
def self.all
38-
Array(Multivariate.redis.smembers(:experiments)).map {|e| find(e)}
38+
Array(Split.redis.smembers(:experiments)).map {|e| find(e)}
3939
end
4040

4141
def self.find(name)
42-
if Multivariate.redis.exists(name)
43-
self.new(name, *Multivariate.redis.smembers(name))
42+
if Split.redis.exists(name)
43+
self.new(name, *Split.redis.smembers(name))
4444
else
4545
raise 'Experiment not found'
4646
end
4747
end
4848

4949
def self.find_or_create(name, *alternatives)
50-
if Multivariate.redis.exists(name)
51-
return self.new(name, *Multivariate.redis.smembers(name))
50+
if Split.redis.exists(name)
51+
return self.new(name, *Split.redis.smembers(name))
5252
else
5353
experiment = self.new(name, *alternatives)
5454
experiment.save

0 commit comments

Comments
 (0)