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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 471a0ef6f65df02f33a5e1bcedfbba8b7d395110
4
- data.tar.gz: 029bdde45f27ed77fbdb4b8876e0a59f90217b68
3
+ metadata.gz: 07c293753d7830d31252051706b746e4920a97cc
4
+ data.tar.gz: c803e602635e92e0a31dc2917f74b60b86b2c894
5
5
  SHA512:
6
- metadata.gz: e12908d7ff96309a561c0965bfbf559f8258e2ec8116efcb8ecd79ad28a98a24befa7481c6c7c8af6996da3f3e824006a341191ec4db86f93ce9d72bafe79afe
7
- data.tar.gz: c23388e6a0996abf4ef91b6f346640b5c81f9ce3afb46713da311c783e460118b5652473ce415cf6e37aa5bbf7713a2dade3a982109a779d4a3229c99285dc62
6
+ metadata.gz: 2909f6fd65c57619be708b6461b6349da786da69349bb077c81d05e0c3b6d165d1cab086d403fc7b45a2f3a4a58509bb23c9986e650b7a1d8227b01b8bb8a962
7
+ data.tar.gz: 70485129c8ecc62756e7c5691c08429f473c792c6dc544b067e920932c33b53d3c5c8bcffaa686b86dcbaad7d18bb1ba02dde30e098da76b7e25060743af29c1
data/CHANGELOG.md CHANGED
@@ -1,26 +1,29 @@
1
- # 0.5.0 (2017-08-18)
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
- # 0.4.2 (2017-08-18)
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
- # 0.4.1 (2017-08-18)
10
+ ## 0.4.1 (2017-08-18)
8
11
  - Provide helper to assign variant in rspec
9
12
 
10
- # 0.4.0 (2017-08-16)
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
- # 0.3.0 (2017-08-16)
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
- # 0.2.0 (2017-08-15)
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
- # 0.1.0
22
+ ## 0.1.0
20
23
  - Support winner
21
24
 
22
- # 0.0.3
25
+ ## 0.0.3
23
26
  - Add new API `all_participated_experiments` to list current user's all participated experiments
24
27
 
25
- # 0.0.1
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
 
@@ -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 = {})
@@ -1,3 +1,3 @@
1
1
  module EasyAb
2
- VERSION = '0.5.0'
2
+ VERSION = '0.5.1'
3
3
  end
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.0
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-18 00:00:00.000000000 Z
11
+ date: 2017-08-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec-core