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.
@@ -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)
@@ -2,7 +2,7 @@ module TrailGuide
2
2
  module Version
3
3
  MAJOR = 0
4
4
  MINOR = 1
5
- PATCH = 30
5
+ PATCH = 31
6
6
  VERSION = "#{MAJOR}.#{MINOR}.#{PATCH}"
7
7
 
8
8
  class << self
data/lib/trailguide.rb CHANGED
@@ -19,6 +19,6 @@ module TrailGuide
19
19
  @@configuration = TrailGuide::Config.new
20
20
 
21
21
  class << self
22
- delegate :redis, to: :configuration
22
+ delegate :logger, :redis, to: :configuration
23
23
  end
24
24
  end
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.30
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-01 00:00:00.000000000 Z
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