split 0.4.3 → 0.4.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,14 @@
1
+ ## 0.4.4 (August 9, 2012)
2
+
3
+ Features:
4
+
5
+ - Allow parameter overrides, even without Redis. (@bhcarpenter, #62)
6
+
7
+ Bugfixes:
8
+
9
+ - Fixes version number always increasing when alternatives are changed (@philnash, #63)
10
+ - updated guard-rspec to version 1.2
11
+
1
12
  ## 0.4.3 (July 8, 2012)
2
13
 
3
14
  Features:
@@ -4,6 +4,7 @@ module Split
4
4
  attr_accessor :ignore_ip_addresses
5
5
  attr_accessor :db_failover
6
6
  attr_accessor :db_failover_on_db_error
7
+ attr_accessor :db_failover_allow_parameter_override
7
8
  attr_accessor :allow_multiple_experiments
8
9
  attr_accessor :enabled
9
10
 
@@ -12,8 +13,9 @@ module Split
12
13
  @ignore_ip_addresses = []
13
14
  @db_failover = false
14
15
  @db_failover_on_db_error = proc{|error|} # e.g. use Rails logger here
16
+ @db_failover_allow_parameter_override = false
15
17
  @allow_multiple_experiments = false
16
18
  @enabled = true
17
19
  end
18
20
  end
19
- end
21
+ end
@@ -98,6 +98,9 @@ module Split
98
98
  Split.redis.sadd(:experiments, name)
99
99
  Split.redis.hset(:experiment_start_times, @name, Time.now)
100
100
  @alternatives.reverse.each {|a| Split.redis.lpush(name, a.name) }
101
+ else
102
+ Split.redis.del(name)
103
+ @alternatives.reverse.each {|a| Split.redis.lpush(name, a.name) }
101
104
  end
102
105
  end
103
106
 
@@ -137,10 +140,11 @@ module Split
137
140
  alts = initialize_alternatives(alternatives, name)
138
141
 
139
142
  if Split.redis.exists(name)
140
- if load_alternatives_for(name) == alts.map(&:name)
143
+ existing_alternatives = load_alternatives_for(name)
144
+ if existing_alternatives == alts.map(&:name)
141
145
  experiment = self.new(name, *alternatives)
142
146
  else
143
- exp = self.new(name, *load_alternatives_for(name))
147
+ exp = self.new(name, *existing_alternatives)
144
148
  exp.reset
145
149
  exp.alternatives.each(&:delete)
146
150
  experiment = self.new(name, *alternatives)
@@ -118,7 +118,14 @@ module Split
118
118
  rescue => e
119
119
  raise unless Split.configuration.db_failover
120
120
  Split.configuration.db_failover_on_db_error.call(e)
121
- ret = control_variable(control)
121
+ if Split.configuration.db_failover_allow_parameter_override
122
+ all_alternatives = *([control] + alternatives)
123
+ alternative_names = all_alternatives.map{|a| a.is_a?(Hash) ? a.keys : a}.flatten
124
+ ret = override(experiment_name, alternative_names)
125
+ end
126
+ unless ret
127
+ ret = control_variable(control)
128
+ end
122
129
  end
123
130
  ret
124
131
  end
@@ -1,3 +1,3 @@
1
1
  module Split
2
- VERSION = "0.4.3"
2
+ VERSION = "0.4.4"
3
3
  end
@@ -176,6 +176,15 @@ describe Split::Experiment do
176
176
  new_blue = Split::Alternative.new('blue', 'link_color')
177
177
  new_blue.participant_count.should eql(0)
178
178
  end
179
+
180
+ it "should only reset once" do
181
+ experiment = Split::Experiment.find_or_create('link_color', 'blue', 'red', 'green')
182
+ experiment.version.should eql(0)
183
+ same_experiment = Split::Experiment.find_or_create('link_color', 'blue', 'yellow', 'orange')
184
+ same_experiment.version.should eql(1)
185
+ same_experiment_again = Split::Experiment.find_or_create('link_color', 'blue', 'yellow', 'orange')
186
+ same_experiment_again.version.should eql(1)
187
+ end
179
188
  end
180
189
 
181
190
  describe 'alternatives passed as non-strings' do
@@ -410,6 +410,27 @@ describe Split::Helper do
410
410
  "shared/#{alternative}"
411
411
  end.should eq('shared/blue')
412
412
  end
413
+
414
+ context 'and db_failover_allow_parameter_override config option is turned on' do
415
+ before(:each) do
416
+ Split.configure do |config|
417
+ config.db_failover_allow_parameter_override = true
418
+ end
419
+ end
420
+
421
+ context 'and given an override parameter' do
422
+ it 'should use given override instead of the first alternative' do
423
+ @params = {'link_color' => 'red'}
424
+ ab_test('link_color', 'blue', 'red').should eq('red')
425
+ ab_test('link_color', 'blue', 'red', 'green').should eq('red')
426
+ ab_test('link_color', {'blue' => 0.01}, 'red' => 0.2).should eq('red')
427
+ ab_test('link_color', {'blue' => 0.8}, {'red' => 20}).should eq('red')
428
+ ab_test('link_color', 'blue', 'red') do |alternative|
429
+ "shared/#{alternative}"
430
+ end.should eq('shared/red')
431
+ end
432
+ end
433
+ end
413
434
  end
414
435
 
415
436
  describe 'finished' do
@@ -26,5 +26,5 @@ Gem::Specification.new do |s|
26
26
  s.add_development_dependency 'bundler', '~> 1.0'
27
27
  s.add_development_dependency 'rspec', '~> 2.6'
28
28
  s.add_development_dependency 'rack-test', '~> 0.6'
29
- s.add_development_dependency 'guard-rspec', '~> 0.4'
29
+ s.add_development_dependency 'guard-rspec', '~> 1.2'
30
30
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: split
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.4.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-08 00:00:00.000000000 Z
12
+ date: 2012-08-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: redis
16
- requirement: &70320238811700 !ruby/object:Gem::Requirement
16
+ requirement: &70151613684420 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '2.1'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70320238811700
24
+ version_requirements: *70151613684420
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: redis-namespace
27
- requirement: &70320238804560 !ruby/object:Gem::Requirement
27
+ requirement: &70151613683840 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 1.1.0
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70320238804560
35
+ version_requirements: *70151613683840
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: sinatra
38
- requirement: &70320238803180 !ruby/object:Gem::Requirement
38
+ requirement: &70151613683320 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 1.2.6
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70320238803180
46
+ version_requirements: *70151613683320
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rake
49
- requirement: &70320238802020 !ruby/object:Gem::Requirement
49
+ requirement: &70151613682760 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70320238802020
57
+ version_requirements: *70151613682760
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: bundler
60
- requirement: &70320238800860 !ruby/object:Gem::Requirement
60
+ requirement: &70151613695660 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '1.0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70320238800860
68
+ version_requirements: *70151613695660
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec
71
- requirement: &70320238799240 !ruby/object:Gem::Requirement
71
+ requirement: &70151613695120 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ~>
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '2.6'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70320238799240
79
+ version_requirements: *70151613695120
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: rack-test
82
- requirement: &70320238798220 !ruby/object:Gem::Requirement
82
+ requirement: &70151613694660 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ~>
@@ -87,18 +87,18 @@ dependencies:
87
87
  version: '0.6'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *70320238798220
90
+ version_requirements: *70151613694660
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: guard-rspec
93
- requirement: &70320238797400 !ruby/object:Gem::Requirement
93
+ requirement: &70151613694080 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ~>
97
97
  - !ruby/object:Gem::Version
98
- version: '0.4'
98
+ version: '1.2'
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *70320238797400
101
+ version_requirements: *70151613694080
102
102
  description:
103
103
  email:
104
104
  - andrewnez@gmail.com