gitlab-experiment 0.3.0 → 0.3.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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4bb028b4495b7ab210c13769433a8b6ec7b8a3fc459a2c33f0e9bc650cf23916
|
4
|
+
data.tar.gz: '0387ed9d7e722c4ba6bce42aed1b71720b6df23b6687100b02186f57b6f125c9'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d27ae9c243b447d994060bc2250ade8be78351312c01fa591e67441f913fd67f9e2caed1de77caac454b0a6b84702ff865e6a58c796c8e014ba2cf530dd5df9b
|
7
|
+
data.tar.gz: 2a3dcfef0dbfeb7e9e35d3ca56ede0bc7d1feeeafa9774a0f9184eeb89dfe49a49e6fbc93f594332cda1d8c87b374069a0ab1c053ab51183d8fdf47af4769845
|
data/README.md
CHANGED
@@ -27,7 +27,7 @@ gem 'gitlab-experiment'
|
|
27
27
|
If you're using Rails, you can install the initializer. It provides basic configuration and documentation.
|
28
28
|
|
29
29
|
```shell
|
30
|
-
$ rails generate
|
30
|
+
$ rails generate gitlab_experiment:install
|
31
31
|
```
|
32
32
|
|
33
33
|
## Implementing an experiment
|
@@ -5,7 +5,7 @@ Gitlab::Experiment.configure do |config|
|
|
5
5
|
config.name_prefix = nil
|
6
6
|
|
7
7
|
# The logger is used to log various details of the experiments.
|
8
|
-
config.logger = Logger.new(
|
8
|
+
config.logger = Logger.new($stdout)
|
9
9
|
|
10
10
|
# The caching layer is expected to respond to fetch, like Rails.cache.
|
11
11
|
config.cache = nil
|
data/lib/gitlab/experiment.rb
CHANGED
@@ -22,11 +22,17 @@ module Gitlab
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def run(name, variant_name = nil, **context, &block)
|
25
|
-
instance = new(name, variant_name, **context, &block)
|
25
|
+
instance = constantize(name).new(name, variant_name, **context, &block)
|
26
26
|
return instance unless block_given?
|
27
27
|
|
28
28
|
instance.context.frozen? ? instance.run : instance.tap(&:run)
|
29
29
|
end
|
30
|
+
|
31
|
+
def constantize(name)
|
32
|
+
name = "#{name}_experiment"
|
33
|
+
klass = name.respond_to?(:classify) ? name.classify.safe_constantize : nil
|
34
|
+
klass || self
|
35
|
+
end
|
30
36
|
end
|
31
37
|
|
32
38
|
def initialize(name, variant_name = nil, **context)
|
@@ -98,6 +104,15 @@ module Gitlab
|
|
98
104
|
@excluded.any? { |exclude| exclude.call(self) }
|
99
105
|
end
|
100
106
|
|
107
|
+
def id
|
108
|
+
"#{name}:#{signature[:key]}"
|
109
|
+
end
|
110
|
+
alias_method :session_id, :id
|
111
|
+
|
112
|
+
def flipper_id
|
113
|
+
"Experiment;#{id}"
|
114
|
+
end
|
115
|
+
|
101
116
|
protected
|
102
117
|
|
103
118
|
def generate_result(variant_name)
|
@@ -13,7 +13,7 @@ module Gitlab
|
|
13
13
|
@name_prefix = nil
|
14
14
|
|
15
15
|
# The logger is used to log various details of the experiments.
|
16
|
-
@logger = Logger.new(
|
16
|
+
@logger = Logger.new($stdout)
|
17
17
|
|
18
18
|
# Cache layer. Expected to respond to fetch, like Rails.cache.
|
19
19
|
@cache = nil
|
@@ -41,8 +41,15 @@ module Gitlab
|
|
41
41
|
end
|
42
42
|
|
43
43
|
class << self
|
44
|
-
attr_accessor
|
45
|
-
|
44
|
+
attr_accessor(
|
45
|
+
:name_prefix,
|
46
|
+
:logger,
|
47
|
+
:cache,
|
48
|
+
:variant_resolver,
|
49
|
+
:tracking_behavior,
|
50
|
+
:publishing_behavior,
|
51
|
+
:context_hash_strategy
|
52
|
+
)
|
46
53
|
end
|
47
54
|
end
|
48
55
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gitlab-experiment
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GitLab
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-10
|
11
|
+
date: 2020-11-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: scientist
|