easy_ab 0.1.0 → 0.2.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 +4 -4
- data/CHANGELOG.md +7 -1
- data/README.md +23 -5
- data/lib/easy_ab/experiment.rb +4 -2
- data/lib/easy_ab/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a1eeea1cbf4338159b42eb100e86cf1bae045b7a
|
4
|
+
data.tar.gz: dbdb41940f2da5113a705c30bc290934219666b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4b2465ffa608c615f52c9f2a3c153323848d2a5d5c8871a906e33492ba927da27a6890b6c1baf524f72e02045907d67906f2619d36e78559e3720af7900f939d
|
7
|
+
data.tar.gz: 00525589553175a0feac4fc7cf4f2b1c7936885792009f08e82393f988638723c9d593b31db63f9ef1ed27bdaecd3ed72266928beddd51ecc7275f280bd74c6a
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
|
+
# 0.2.0 (2017-08-15)
|
2
|
+
* **API change**: If all rules failed, `ab_test` returns nil, instead of the first variant.
|
3
|
+
|
1
4
|
# 0.1.0
|
2
5
|
* Support winner
|
3
6
|
|
4
7
|
# 0.0.3
|
5
|
-
* Add new API `all_participated_experiments` to list current user's all participated experiments
|
8
|
+
* Add new API `all_participated_experiments` to list current user's all participated experiments
|
9
|
+
|
10
|
+
# 0.0.1
|
11
|
+
* The first version :)
|
data/README.md
CHANGED
@@ -114,21 +114,39 @@ EasyAb.experiments do |experiment|
|
|
114
114
|
end
|
115
115
|
```
|
116
116
|
|
117
|
-
NOTICE: rules are executed in the order you defined in `config/initializers/easy_ab.rb`. If there
|
117
|
+
NOTICE: rules are executed in the order you defined in `config/initializers/easy_ab.rb`. If there exists logic overlap among your rules, the former rule will be applied. For example:
|
118
118
|
|
119
119
|
```ruby
|
120
|
+
# config/initializers/easy_ab.rb
|
120
121
|
EasyAb.experiments do |experiment|
|
121
122
|
experiment.define :extra_vip_duration,
|
122
123
|
variants: ['90', '30']
|
123
124
|
rules: [
|
124
|
-
-> {
|
125
|
-
-> {
|
125
|
+
-> { true },
|
126
|
+
-> { true }
|
126
127
|
]
|
127
128
|
|
128
|
-
#
|
129
|
+
# view
|
130
|
+
easy_ab(:extra_vip_duration) # => '90'
|
129
131
|
```
|
130
132
|
|
131
|
-
|
133
|
+
If all rules are not passed, returns nil:
|
134
|
+
|
135
|
+
```ruby
|
136
|
+
# config/initializers/easy_ab.rb
|
137
|
+
EasyAb.experiments do |experiment|
|
138
|
+
experiment.define :extra_vip_duration,
|
139
|
+
variants: ['90', '30']
|
140
|
+
rules: [
|
141
|
+
-> { false },
|
142
|
+
-> { false }
|
143
|
+
]
|
144
|
+
|
145
|
+
# view
|
146
|
+
ab_test(:extra_vip_duration) # => nil
|
147
|
+
```
|
148
|
+
|
149
|
+
Keep in mind that `ab_test()` helper always returns String (or nil). You have to handle the type conversion by yourself.
|
132
150
|
|
133
151
|
```ruby
|
134
152
|
# In controller
|
data/lib/easy_ab/experiment.rb
CHANGED
@@ -32,6 +32,7 @@ module EasyAb
|
|
32
32
|
grouping.variant = options[:variant].to_s
|
33
33
|
else
|
34
34
|
grouping.variant ||= flexible_variant(options[:contexted_rules])
|
35
|
+
return nil if grouping.variant.nil?
|
35
36
|
end
|
36
37
|
|
37
38
|
if grouping.changed? && !options[:skip_save]
|
@@ -94,8 +95,9 @@ module EasyAb
|
|
94
95
|
contexted_rules.each_with_index do |rule, i|
|
95
96
|
return variants[i] if rule.call
|
96
97
|
end
|
97
|
-
|
98
|
-
|
98
|
+
|
99
|
+
# If all rules not matched, return nil
|
100
|
+
nil
|
99
101
|
end
|
100
102
|
|
101
103
|
def weighted_variant
|
data/lib/easy_ab/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: easy_ab
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gary Chu
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-08-
|
11
|
+
date: 2017-08-15 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email: icarus4.chu@gmail.com
|