trailguide 0.1.24 → 0.1.25
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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e49f646c2c6f0d1569668bb7d048c432015d016d3e966944473a3d707dade3fd
|
4
|
+
data.tar.gz: ffb7c2aceb3ab087b6d89ece4e7583f8cd9dbefa63ca87debb8001818f450ed1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 52116e5ead0d802542cf849a6a1f19c73a4e8ae9e2c515b8469891e1c6721bef456a4a272de7348e5db309d67e39b28448897731b1e828ffbd3108d89dcaea5b
|
7
|
+
data.tar.gz: b1a31d51d471e638fc1148f64725d94014d5f4b259cfd6c31796fb60f8d3b1af12837b7000c040f25705ee8f21164720191063701203a3f26d2682bd37a1b9fb
|
@@ -9,27 +9,27 @@ module TrailGuide
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def start
|
12
|
-
experiment.start!
|
12
|
+
experiment.start!(self)
|
13
13
|
redirect_to trail_guide_admin.experiments_path(anchor: experiment.experiment_name)
|
14
14
|
end
|
15
15
|
|
16
16
|
def stop
|
17
|
-
experiment.stop!
|
17
|
+
experiment.stop!(self)
|
18
18
|
redirect_to trail_guide_admin.experiments_path(anchor: experiment.experiment_name)
|
19
19
|
end
|
20
20
|
|
21
21
|
def reset
|
22
|
-
experiment.reset!
|
22
|
+
experiment.reset!(self)
|
23
23
|
redirect_to trail_guide_admin.experiments_path(anchor: experiment.experiment_name)
|
24
24
|
end
|
25
25
|
|
26
26
|
def resume
|
27
|
-
experiment.resume!
|
27
|
+
experiment.resume!(self)
|
28
28
|
redirect_to trail_guide_admin.experiments_path(anchor: experiment.experiment_name)
|
29
29
|
end
|
30
30
|
|
31
31
|
def restart
|
32
|
-
experiment.reset! && experiment.start!
|
32
|
+
experiment.reset!(self) && experiment.start!(self)
|
33
33
|
redirect_to trail_guide_admin.experiments_path(anchor: experiment.experiment_name)
|
34
34
|
end
|
35
35
|
|
@@ -47,7 +47,7 @@ module TrailGuide
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def winner
|
50
|
-
experiment.declare_winner!(params[:variant])
|
50
|
+
experiment.declare_winner!(params[:variant], self)
|
51
51
|
redirect_to trail_guide_admin.experiments_path(anchor: experiment.experiment_name)
|
52
52
|
end
|
53
53
|
|
@@ -191,27 +191,52 @@ TrailGuide::Experiment.configure do |config|
|
|
191
191
|
# automatically depending on config.start_manually, can be used for logging,
|
192
192
|
# tracking, etc.
|
193
193
|
#
|
194
|
-
#
|
194
|
+
# context may or may not be present depending on how you're triggering the
|
195
|
+
# action - if you're using the admin, this will be the admin controller
|
196
|
+
# context, if you're in a console you have the option to pass a context to
|
197
|
+
# `experiment.start!` or not
|
198
|
+
#
|
199
|
+
# config.on_start = -> (experiment, context) { ... }
|
195
200
|
|
196
201
|
# callback on experiment stop manually via UI/console, can be used for
|
197
202
|
# logging, tracking, etc.
|
198
203
|
#
|
199
|
-
#
|
204
|
+
# context may or may not be present depending on how you're triggering the
|
205
|
+
# action - if you're using the admin, this will be the admin controller
|
206
|
+
# context, if you're in a console you have the option to pass a context to
|
207
|
+
# `experiment.stop!` or not
|
208
|
+
#
|
209
|
+
# config.on_stop = -> (experiment, context) { ... }
|
200
210
|
|
201
211
|
# callback on experiment resume manually via UI/console, can be used for
|
202
212
|
# logging, tracking, etc.
|
203
213
|
#
|
204
|
-
#
|
214
|
+
# context may or may not be present depending on how you're triggering the
|
215
|
+
# action - if you're using the admin, this will be the admin controller
|
216
|
+
# context, if you're in a console you have the option to pass a context to
|
217
|
+
# `experiment.resume!` or not
|
218
|
+
#
|
219
|
+
# config.on_resume = -> (experiment, context) { ... }
|
205
220
|
|
206
221
|
# callback on experiment reset manually via UI/console, can be used for
|
207
222
|
# logging, tracking, etc.
|
208
223
|
#
|
209
|
-
#
|
224
|
+
# context may or may not be present depending on how you're triggering the
|
225
|
+
# action - if you're using the admin, this will be the admin controller
|
226
|
+
# context, if you're in a console you have the option to pass a context to
|
227
|
+
# `experiment.reset!` or not
|
228
|
+
#
|
229
|
+
# config.on_reset = -> (experiment, context) { ... }
|
210
230
|
|
211
231
|
# callback when a winner is selected manually via UI/console, can be used for
|
212
232
|
# logging, tracking, etc.
|
213
233
|
#
|
214
|
-
#
|
234
|
+
# context may or may not be present depending on how you're triggering the
|
235
|
+
# action - if you're using the admin, this will be the admin controller
|
236
|
+
# context, if you're in a console you have the option to pass a context to
|
237
|
+
# `experiment.declare_winner!` or not
|
238
|
+
#
|
239
|
+
# config.on_winner = -> (experiment, winner, context) { ... }
|
215
240
|
|
216
241
|
|
217
242
|
# callback when a participant is entered into a variant for the first time,
|
@@ -44,25 +44,25 @@ module TrailGuide
|
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
|
-
def start!
|
47
|
+
def start!(context=nil)
|
48
48
|
return false if started?
|
49
49
|
save! unless persisted?
|
50
50
|
started = TrailGuide.redis.hset(storage_key, 'started_at', Time.now.to_i)
|
51
|
-
run_callbacks(:on_start)
|
51
|
+
run_callbacks(:on_start, context)
|
52
52
|
started
|
53
53
|
end
|
54
54
|
|
55
|
-
def stop!
|
55
|
+
def stop!(context=nil)
|
56
56
|
return false unless running?
|
57
57
|
stopped = TrailGuide.redis.hset(storage_key, 'stopped_at', Time.now.to_i)
|
58
|
-
run_callbacks(:on_stop)
|
58
|
+
run_callbacks(:on_stop, context)
|
59
59
|
stopped
|
60
60
|
end
|
61
61
|
|
62
|
-
def resume!
|
62
|
+
def resume!(context=nil)
|
63
63
|
return false unless started? && stopped?
|
64
64
|
restarted = TrailGuide.redis.hdel(storage_key, 'stopped_at')
|
65
|
-
run_callbacks(:on_resume)
|
65
|
+
run_callbacks(:on_resume, context)
|
66
66
|
restarted
|
67
67
|
end
|
68
68
|
|
@@ -88,9 +88,9 @@ module TrailGuide
|
|
88
88
|
started? && !stopped?
|
89
89
|
end
|
90
90
|
|
91
|
-
def declare_winner!(variant)
|
91
|
+
def declare_winner!(variant, context=nil)
|
92
92
|
variant = variants.find { |var| var == variant } unless variant.is_a?(Variant)
|
93
|
-
run_callbacks(:on_winner, variant)
|
93
|
+
run_callbacks(:on_winner, variant, context)
|
94
94
|
TrailGuide.redis.hset(storage_key, 'winner', variant.name.to_s.underscore)
|
95
95
|
end
|
96
96
|
|
@@ -117,17 +117,17 @@ module TrailGuide
|
|
117
117
|
TrailGuide.redis.hsetnx(storage_key, 'name', experiment_name)
|
118
118
|
end
|
119
119
|
|
120
|
-
def delete!
|
120
|
+
def delete!(context=nil)
|
121
121
|
combined.each { |combo| TrailGuide.catalog.find(combo).delete! }
|
122
122
|
variants.each(&:delete!)
|
123
123
|
deleted = TrailGuide.redis.del(storage_key)
|
124
|
-
run_callbacks(:on_delete)
|
124
|
+
run_callbacks(:on_delete, context)
|
125
125
|
deleted
|
126
126
|
end
|
127
127
|
|
128
|
-
def reset!
|
128
|
+
def reset!(context=nil)
|
129
129
|
reset = (delete! && save!)
|
130
|
-
run_callbacks(:on_reset)
|
130
|
+
run_callbacks(:on_reset, context)
|
131
131
|
reset
|
132
132
|
end
|
133
133
|
|
data/lib/trail_guide/version.rb
CHANGED