easy_ab 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -9
- data/README.md +4 -0
- data/lib/easy_ab/helpers.rb +14 -0
- 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: 07c293753d7830d31252051706b746e4920a97cc
|
4
|
+
data.tar.gz: c803e602635e92e0a31dc2917f74b60b86b2c894
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2909f6fd65c57619be708b6461b6349da786da69349bb077c81d05e0c3b6d165d1cab086d403fc7b45a2f3a4a58509bb23c9986e650b7a1d8227b01b8bb8a962
|
7
|
+
data.tar.gz: 70485129c8ecc62756e7c5691c08429f473c792c6dc544b067e920932c33b53d3c5c8bcffaa686b86dcbaad7d18bb1ba02dde30e098da76b7e25060743af29c1
|
data/CHANGELOG.md
CHANGED
@@ -1,26 +1,29 @@
|
|
1
|
-
|
1
|
+
## 0.5.1 (2017-08-25)
|
2
|
+
- Add new API (`easy_ab_test`) for internal use.
|
3
|
+
|
4
|
+
## 0.5.0 (2017-08-18)
|
2
5
|
- Add new API (`find_easy_ab_variant`) to retrieve specified user's variant
|
3
6
|
|
4
|
-
|
7
|
+
## 0.4.2 (2017-08-18)
|
5
8
|
- Specify URL parameter to assign variant works for all user instead of admin only in development environment now. In production and test, admin is still required for assigning variant by URL paramenter.
|
6
9
|
|
7
|
-
|
10
|
+
## 0.4.1 (2017-08-18)
|
8
11
|
- Provide helper to assign variant in rspec
|
9
12
|
|
10
|
-
|
13
|
+
## 0.4.0 (2017-08-16)
|
11
14
|
- You can specify user in `ab_test()` This useful when requests do not contain current_user. A well-known example is controllers which handle payment results by listening requests from 3rd party payment gateway.
|
12
15
|
|
13
|
-
|
16
|
+
## 0.3.0 (2017-08-16)
|
14
17
|
- Supports scope in config to define whether a user can join an experiment or not.
|
15
18
|
|
16
|
-
|
19
|
+
## 0.2.0 (2017-08-15)
|
17
20
|
- **API change**: If all rules failed, `ab_test` returns nil, instead of the first variant.
|
18
21
|
|
19
|
-
|
22
|
+
## 0.1.0
|
20
23
|
- Support winner
|
21
24
|
|
22
|
-
|
25
|
+
## 0.0.3
|
23
26
|
- Add new API `all_participated_experiments` to list current user's all participated experiments
|
24
27
|
|
25
|
-
|
28
|
+
## 0.0.1
|
26
29
|
- The first version :)
|
data/README.md
CHANGED
@@ -190,6 +190,10 @@ The return format of `all_participated_experiments`:
|
|
190
190
|
# RSpec
|
191
191
|
You can easily assign variant to a user in your RSpec tests:
|
192
192
|
```ruby
|
193
|
+
# Add to your rails_helper
|
194
|
+
require 'easy_ab/rspec'
|
195
|
+
|
196
|
+
# In your test, you can assign variant by this way:
|
193
197
|
assign_variant(user, :button_color, 'red')
|
194
198
|
```
|
195
199
|
|
data/lib/easy_ab/helpers.rb
CHANGED
@@ -63,6 +63,20 @@ module EasyAb
|
|
63
63
|
experiments
|
64
64
|
end
|
65
65
|
|
66
|
+
# Internal use for statementdog.com
|
67
|
+
# Only supports weighting-based experiments without scope.
|
68
|
+
# Never use this API with rule-based experiments or any experiments with scope.
|
69
|
+
def ab_test_user(experiment_name, user:, **options)
|
70
|
+
experiment_name = experiment_name.to_s
|
71
|
+
user_recognition = { user_id: user.id }
|
72
|
+
|
73
|
+
experiment = EasyAb::Experiment.find_by_name!(experiment_name)
|
74
|
+
@ab_test_user_cache ||= {}
|
75
|
+
@ab_test_user_cache[experiment_name] ||= experiment.assign_variant(user_recognition, options)
|
76
|
+
variant = @ab_test_user_cache[experiment_name]
|
77
|
+
block_given? ? yield(variant) : variant
|
78
|
+
end
|
79
|
+
|
66
80
|
private
|
67
81
|
|
68
82
|
def find_ab_test_user_recognition(options = {})
|
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.5.
|
4
|
+
version: 0.5.1
|
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-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec-core
|