split 1.7.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 75e3f5edc1fef8a1131b615f82d5ec12cac72c29
4
- data.tar.gz: bd21bc8f80816d06b3e05532152525e81c54e018
3
+ metadata.gz: 979183911b308ee1272e4d98e1bd0b8c87be732d
4
+ data.tar.gz: 8a4e49e77326cd94165f551b5e2080eaff78f053
5
5
  SHA512:
6
- metadata.gz: 6c3dc4cf24791918469b0c7677b63ea04510ff216c3cb46de2fffe82ebb77110d8ec94269dff6ee32fe20c49ff256c9dee304b07933116166ba91746ca486737
7
- data.tar.gz: 51b7bceb61bb92b61abd0b35eae3f5b142f6e1b48341a4a9d1753a4853289fc998e1a60dc462c3b8bac53c71f231b050952ab3f89a69d175ec32e78f0e7f3e97
6
+ metadata.gz: a990656f1a7342d069565c5ed6723577b915f77df5000e2d2fd8623105f060d2e079af2ded60d9b3b46120316db35a2c2ed1d88a68218e68784797ae83c4b9e1
7
+ data.tar.gz: 8c8ce0354d575b9b212c997753200b00e22eb9d379617303e3b95e14717a118182d238bd4141c0a1c9e4411e3066f503174462bac5253a35c8e19960d408f120
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## 2.0.0 (July 17th, 2016)
2
+
3
+ Breaking changes:
4
+
5
+ - Removed deprecated `finished` and `begin_experiment` methods
6
+ - Namespaced override param to avoid potential clashes (@henrik, #398)
7
+
1
8
  ## 1.7.0 (June 28th, 2016)
2
9
 
3
10
  Features:
data/README.md CHANGED
@@ -136,7 +136,7 @@ You can do this by passing it as a parameter in the url.
136
136
 
137
137
  If you have an experiment called `button_color` with alternatives called `red` and `blue` used on your homepage, a url such as:
138
138
 
139
- http://myawesomesite.com?button_color=red
139
+ http://myawesomesite.com?ab_test[button_color]=red
140
140
 
141
141
  will always have red buttons. This won't be stored in your session or count towards to results, unless you set the `store_override` configuration option.
142
142
 
@@ -15,7 +15,7 @@ module Split
15
15
 
16
16
  class ContextShim
17
17
  include Split::Helper
18
- public :ab_test, :finished, :ab_finished
18
+ public :ab_test, :ab_finished
19
19
 
20
20
  def initialize(context)
21
21
  @context = context
@@ -43,11 +43,6 @@ module Split
43
43
  end
44
44
  end
45
45
 
46
- def ab_test_finished(*arguments)
47
- warn 'DEPRECATION WARNING: ab_test_finished is deprecated and will be removed from Split 2.0.0'
48
- split_context_shim.finished *arguments
49
- end
50
-
51
46
  private
52
47
 
53
48
  # instantiate and memoize a context shim in case of multiple ab_test* calls
data/lib/split/helper.rb CHANGED
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
  module Split
3
3
  module Helper
4
+ OVERRIDE_PARAM_NAME = "ab_test"
5
+
4
6
  module_function
5
7
 
6
8
  def ab_test(metric_descriptor, control = nil, *alternatives)
@@ -74,30 +76,18 @@ module Split
74
76
  Split.configuration.db_failover_on_db_error.call(e)
75
77
  end
76
78
 
77
- def finished(metric_descriptor, options = {:reset => true})
78
- warn 'DEPRECATION WARNING: finished method was renamed to ab_finished and will be removed in Split 2.0.0'
79
- ab_finished(metric_descriptor, options)
80
- end
81
-
82
79
  def override_present?(experiment_name)
83
- defined?(params) && params[experiment_name]
80
+ override_alternative(experiment_name)
84
81
  end
85
82
 
86
83
  def override_alternative(experiment_name)
87
- params[experiment_name] if override_present?(experiment_name)
84
+ defined?(params) && params[OVERRIDE_PARAM_NAME] && params[OVERRIDE_PARAM_NAME][experiment_name]
88
85
  end
89
86
 
90
87
  def split_generically_disabled?
91
88
  defined?(params) && params['SPLIT_DISABLE']
92
89
  end
93
90
 
94
- def begin_experiment(experiment, alternative_name = nil)
95
- warn 'DEPRECATION WARNING: begin_experiment is deprecated and will be removed from Split 2.0.0'
96
- alternative_name ||= experiment.control.name
97
- ab_user[experiment.key] = alternative_name
98
- alternative_name
99
- end
100
-
101
91
  def ab_user
102
92
  @ab_user ||= User.new(self)
103
93
  end
data/lib/split/version.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
  module Split
3
- MAJOR = 1
4
- MINOR = 7
3
+ MAJOR = 2
4
+ MINOR = 0
5
5
  PATCH = 0
6
6
  VERSION = [MAJOR, MINOR, PATCH].join('.')
7
7
  end
@@ -24,7 +24,7 @@ describe Split::GoalsCollection do
24
24
  describe "#validate!" do
25
25
  it "should't raise ArgumentError if @goals is nil?" do
26
26
  goals_collection = Split::GoalsCollection.new('experiment_name')
27
- expect { goals_collection.validate! }.not_to raise_error(ArgumentError)
27
+ expect { goals_collection.validate! }.not_to raise_error
28
28
  end
29
29
 
30
30
  it "should raise ArgumentError if @goals is not an Array" do
@@ -36,7 +36,7 @@ describe Split::GoalsCollection do
36
36
  it "should't raise ArgumentError if @goals is an array" do
37
37
  goals_collection = Split::GoalsCollection.
38
38
  new('experiment_name', ['an array'])
39
- expect { goals_collection.validate! }.not_to raise_error(ArgumentError)
39
+ expect { goals_collection.validate! }.not_to raise_error
40
40
  end
41
41
  end
42
42
 
data/spec/helper_spec.rb CHANGED
@@ -89,27 +89,33 @@ describe Split::Helper do
89
89
  expect(ab_test('link_color', 'blue', 'red')).to eq('orange')
90
90
  end
91
91
 
92
- it "should allow the alternative to be force by passing it in the params" do
93
- @params = {'link_color' => 'blue'}
92
+ it "should allow the alternative to be forced by passing it in the params" do
93
+ # ?ab_test[link_color]=blue
94
+ @params = { 'ab_test' => { 'link_color' => 'blue' } }
95
+
94
96
  alternative = ab_test('link_color', 'blue', 'red')
95
97
  expect(alternative).to eq('blue')
98
+
96
99
  alternative = ab_test('link_color', {'blue' => 1}, 'red' => 5)
97
100
  expect(alternative).to eq('blue')
98
- @params = {'link_color' => 'red'}
101
+
102
+ @params = { 'ab_test' => { 'link_color' => 'red' } }
103
+
99
104
  alternative = ab_test('link_color', 'blue', 'red')
100
105
  expect(alternative).to eq('red')
106
+
101
107
  alternative = ab_test('link_color', {'blue' => 5}, 'red' => 1)
102
108
  expect(alternative).to eq('red')
103
109
  end
104
110
 
105
111
  it "should not allow an arbitrary alternative" do
106
- @params = {'link_color' => 'pink'}
112
+ @params = { 'ab_test' => { 'link_color' => 'pink' } }
107
113
  alternative = ab_test('link_color', 'blue')
108
114
  expect(alternative).to eq('blue')
109
115
  end
110
116
 
111
117
  it "should not store the split when a param forced alternative" do
112
- @params = {'link_color' => 'blue'}
118
+ @params = { 'ab_test' => { 'link_color' => 'blue' } }
113
119
  expect(ab_user).not_to receive(:[]=)
114
120
  ab_test('link_color', 'blue', 'red')
115
121
  end
@@ -136,7 +142,7 @@ describe Split::Helper do
136
142
  before { Split.configuration.store_override = true }
137
143
 
138
144
  it "should store the forced alternative" do
139
- @params = {'link_color' => 'blue'}
145
+ @params = { 'ab_test' => { 'link_color' => 'blue' } }
140
146
  expect(ab_user).to receive(:[]=).with('link_color', 'blue')
141
147
  ab_test('link_color', 'blue', 'red')
142
148
  end
@@ -232,7 +238,7 @@ describe Split::Helper do
232
238
  end
233
239
 
234
240
  it 'should be passed to helper block' do
235
- @params = {'my_experiment' => 'one'}
241
+ @params = { 'ab_test' => { 'my_experiment' => 'one' } }
236
242
  expect(ab_test('my_experiment')).to eq 'one'
237
243
  expect(ab_test('my_experiment') do |alternative, meta|
238
244
  meta
@@ -790,7 +796,7 @@ describe Split::Helper do
790
796
 
791
797
  context 'and given an override parameter' do
792
798
  it 'should use given override instead of the first alternative' do
793
- @params = {'link_color' => 'red'}
799
+ @params = { 'ab_test' => { 'link_color' => 'red' } }
794
800
  expect(ab_test('link_color', 'blue', 'red')).to eq('red')
795
801
  expect(ab_test('link_color', 'blue', 'red', 'green')).to eq('red')
796
802
  expect(ab_test('link_color', {'blue' => 0.01}, 'red' => 0.2)).to eq('red')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: split
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Nesbitt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-28 00:00:00.000000000 Z
11
+ date: 2016-07-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis