trailguide 0.1.30 → 0.1.31
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/README.md +676 -23
- data/app/controllers/trail_guide/admin/application_controller.rb +3 -3
- data/app/controllers/trail_guide/admin/experiments_controller.rb +21 -5
- data/app/views/layouts/trail_guide/admin/_header.erb +31 -3
- data/app/views/trail_guide/admin/experiments/_combined_experiment.html.erb +29 -7
- data/app/views/trail_guide/admin/experiments/_experiment.html.erb +29 -7
- data/app/views/trail_guide/admin/experiments/index.html.erb +1 -1
- data/config/initializers/trailguide.rb +33 -3
- data/config/routes/admin.rb +22 -0
- data/config/routes/engine.rb +13 -0
- data/config/routes.rb +5 -31
- data/lib/trail_guide/adapters/participants/multi.rb +2 -1
- data/lib/trail_guide/adapters/participants/redis.rb +4 -1
- data/lib/trail_guide/catalog.rb +12 -0
- data/lib/trail_guide/combined_experiment.rb +9 -1
- data/lib/trail_guide/config.rb +4 -4
- data/lib/trail_guide/experiments/base.rb +21 -5
- data/lib/trail_guide/experiments/config.rb +13 -4
- data/lib/trail_guide/helper.rb +48 -0
- data/lib/trail_guide/version.rb +1 -1
- data/lib/trailguide.rb +1 -1
- metadata +4 -2
data/lib/trail_guide/helper.rb
CHANGED
@@ -77,19 +77,37 @@ module TrailGuide
|
|
77
77
|
def choose!(metric, **opts, &block)
|
78
78
|
new(metric).choose!(**opts, &block)
|
79
79
|
end
|
80
|
+
alias_method :enroll!, :choose!
|
81
|
+
|
82
|
+
def choose(metric, **opts, &block)
|
83
|
+
new(metric).choose(**opts, &block)
|
84
|
+
end
|
85
|
+
alias_method :enroll, :choose
|
80
86
|
|
81
87
|
def run!(metric, **opts)
|
82
88
|
new(metric).run!(**opts)
|
83
89
|
end
|
84
90
|
|
91
|
+
def run(metric, **opts)
|
92
|
+
new(metric).run(**opts)
|
93
|
+
end
|
94
|
+
|
85
95
|
def render!(metric, **opts)
|
86
96
|
new(metric).render!(**opts)
|
87
97
|
end
|
88
98
|
|
99
|
+
def render(metric, **opts)
|
100
|
+
new(metric).render(**opts)
|
101
|
+
end
|
102
|
+
|
89
103
|
def convert!(metric, checkpoint=nil, **opts, &block)
|
90
104
|
new(metric).convert!(checkpoint, **opts, &block)
|
91
105
|
end
|
92
106
|
|
107
|
+
def convert(metric, checkpoint=nil, **opts, &block)
|
108
|
+
new(metric).convert(checkpoint, **opts, &block)
|
109
|
+
end
|
110
|
+
|
93
111
|
def participant
|
94
112
|
@participant ||= context.send(:trailguide_participant)
|
95
113
|
end
|
@@ -122,6 +140,15 @@ module TrailGuide
|
|
122
140
|
variant
|
123
141
|
end
|
124
142
|
end
|
143
|
+
alias_method :enroll!, :choose!
|
144
|
+
|
145
|
+
def choose(**opts, &block)
|
146
|
+
choose!(**opts, &block)
|
147
|
+
rescue => e
|
148
|
+
TrailGuide.logger.error e
|
149
|
+
experiment.control
|
150
|
+
end
|
151
|
+
alias_method :enroll, :choose
|
125
152
|
|
126
153
|
def run!(methods: nil, **opts)
|
127
154
|
choose!(**opts) do |variant, metadata|
|
@@ -152,6 +179,13 @@ module TrailGuide
|
|
152
179
|
end
|
153
180
|
end
|
154
181
|
|
182
|
+
def run(methods: nil, **opts)
|
183
|
+
run!(methods: methods, **opts)
|
184
|
+
rescue => e
|
185
|
+
TrailGuide.logger.error e
|
186
|
+
false
|
187
|
+
end
|
188
|
+
|
155
189
|
def render!(prefix: nil, templates: nil, locals: {}, **opts)
|
156
190
|
raise UnsupportedContextError, "The current context (#{context}) does not support rendering. Rendering is only available in controllers and views." unless context.respond_to?(:render, true)
|
157
191
|
choose!(**opts) do |variant, metadata|
|
@@ -166,6 +200,13 @@ module TrailGuide
|
|
166
200
|
end
|
167
201
|
end
|
168
202
|
|
203
|
+
def render(prefix: nil, templates: nil, locals: {}, **opts)
|
204
|
+
render!(prefix: prefix, templates: templates, locals: locals, **opts)
|
205
|
+
rescue => e
|
206
|
+
TrailGuide.logger.error e
|
207
|
+
false
|
208
|
+
end
|
209
|
+
|
169
210
|
def convert!(checkpoint=nil, **opts, &block)
|
170
211
|
checkpoints = experiments.map { |experiment| experiment.convert!(checkpoint, **opts) }
|
171
212
|
return false unless checkpoints.any?
|
@@ -176,6 +217,13 @@ module TrailGuide
|
|
176
217
|
end
|
177
218
|
end
|
178
219
|
|
220
|
+
def convert(checkpoint=nil, **opts, &block)
|
221
|
+
convert!(checkpoint, **opts, &block)
|
222
|
+
rescue => e
|
223
|
+
TrailGuide.logger.error e
|
224
|
+
false
|
225
|
+
end
|
226
|
+
|
179
227
|
def experiments
|
180
228
|
@experiments ||= TrailGuide.catalog.select(metric).map do |experiment|
|
181
229
|
experiment.new(participant)
|
data/lib/trail_guide/version.rb
CHANGED
data/lib/trailguide.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trailguide
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.31
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Rebec
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-04-
|
11
|
+
date: 2019-04-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -135,6 +135,8 @@ files:
|
|
135
135
|
- config/initializers/assets.rb
|
136
136
|
- config/initializers/trailguide.rb
|
137
137
|
- config/routes.rb
|
138
|
+
- config/routes/admin.rb
|
139
|
+
- config/routes/engine.rb
|
138
140
|
- lib/trail_guide/adapters.rb
|
139
141
|
- lib/trail_guide/adapters/participants.rb
|
140
142
|
- lib/trail_guide/adapters/participants/anonymous.rb
|