trailguide 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/trail_guide/experiment.rb +4 -4
- data/lib/trail_guide/helper.rb +3 -5
- data/lib/trail_guide/version.rb +1 -1
- data/lib/trailguide.rb +17 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5adb31d9a97b2a73b6ff57b91d7f3907d408c511821b72fe0f7b1f857873a794
|
4
|
+
data.tar.gz: 3e054cb7abcd176989b6a322f3f9b34e69d2b2b662824a2a84b4e2c3a6c1040a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eeefcc9c9b4e08bfe433b576ca5da9614e6295ae354a4858811af3fad1660cd5c3acdecd8afeaa61ed17edbff34d7eebc2bd797ae8c421c199096c4402bc8d83
|
7
|
+
data.tar.gz: 92d4106bff4e3ba5db67e4812b02029126ce3fb43790525c1be0a024fa5dae84cd4b44f4a75e361f4f1c605228bf8fb84e9fa371485ef77058bf3310b33042e2
|
@@ -265,10 +265,11 @@ module TrailGuide
|
|
265
265
|
@algorithm ||= self.class.algorithm.new(self)
|
266
266
|
end
|
267
267
|
|
268
|
-
def choose!(metadata: nil, **opts)
|
268
|
+
def choose!(override: nil, metadata: nil, **opts)
|
269
269
|
return control if TrailGuide.configuration.disabled
|
270
270
|
|
271
|
-
variant = choose_variant!(metadata: metadata, **opts)
|
271
|
+
variant = choose_variant!(override: override, metadata: metadata, **opts)
|
272
|
+
participant.participating!(variant) unless override.present? && !TrailGuide.configuration.store_override
|
272
273
|
run_callbacks(:on_use, variant, metadata)
|
273
274
|
variant
|
274
275
|
end
|
@@ -277,7 +278,7 @@ module TrailGuide
|
|
277
278
|
return control if TrailGuide.configuration.disabled
|
278
279
|
if override.present?
|
279
280
|
variant = variants.find { |var| var == override }
|
280
|
-
return variant unless TrailGuide.configuration.
|
281
|
+
return variant unless TrailGuide.configuration.track_override && started?
|
281
282
|
else
|
282
283
|
return winner if winner?
|
283
284
|
return control if excluded
|
@@ -289,7 +290,6 @@ module TrailGuide
|
|
289
290
|
variant = algorithm.choose!(metadata: metadata)
|
290
291
|
end
|
291
292
|
|
292
|
-
participant.participating!(variant)
|
293
293
|
variant.increment_participation!
|
294
294
|
run_callbacks(:on_choose, variant, metadata)
|
295
295
|
variant
|
data/lib/trail_guide/helper.rb
CHANGED
@@ -153,7 +153,7 @@ module TrailGuide
|
|
153
153
|
end
|
154
154
|
|
155
155
|
def is_filtered_user_agent?
|
156
|
-
return false if TrailGuide.configuration.filtered_user_agents.empty?
|
156
|
+
return false if TrailGuide.configuration.filtered_user_agents.nil? || TrailGuide.configuration.filtered_user_agents.empty?
|
157
157
|
return false unless context.respond_to?(:request, true)
|
158
158
|
request = context.send(:request)
|
159
159
|
return false unless request && request.user_agent
|
@@ -167,15 +167,13 @@ module TrailGuide
|
|
167
167
|
end
|
168
168
|
|
169
169
|
def is_filtered_ip_address?
|
170
|
-
|
171
|
-
filtered_ips = filtered_ips.call if filtered_ips.respond_to?(:call)
|
172
|
-
return false if filtered_ips.nil? || filtered_ips.empty?
|
170
|
+
return false if TrailGuide.configuration.filtered_ip_addresses.nil? || TrailGuide.configuration.filtered_ip_addresses.empty?
|
173
171
|
|
174
172
|
return false unless context.respond_to?(:request, true)
|
175
173
|
request = context.send(:request)
|
176
174
|
return false unless request && request.ip
|
177
175
|
|
178
|
-
|
176
|
+
TrailGuide.configuration.filtered_ip_addresses.each do |ip|
|
179
177
|
return true if ip.class == String && request.ip == ip
|
180
178
|
return true if ip.class == Regexp && request.ip =~ ip
|
181
179
|
return true if ip.class == Range && ip.first.class == IPAddr && ip.include?(IPAddr.new(request.ip))
|
data/lib/trail_guide/version.rb
CHANGED
data/lib/trailguide.rb
CHANGED
@@ -18,6 +18,7 @@ module TrailGuide
|
|
18
18
|
config.start_manually = true
|
19
19
|
config.reset_manually = true
|
20
20
|
config.store_override = false
|
21
|
+
config.track_override = false
|
21
22
|
config.override_parameter = :experiment
|
22
23
|
config.allow_multiple_experiments = true # false / :control
|
23
24
|
config.algorithm = :weighted
|
@@ -39,6 +40,22 @@ module TrailGuide
|
|
39
40
|
is_filtered_user_agent? ||
|
40
41
|
is_filtered_ip_address?
|
41
42
|
end
|
43
|
+
|
44
|
+
def filtered_user_agents
|
45
|
+
@filtered_user_agents ||= begin
|
46
|
+
uas = @state[:filtered_user_agents]
|
47
|
+
uas = uas.call if uas.respond_to?(:call)
|
48
|
+
uas
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def filtered_ip_addresses
|
53
|
+
@filtered_ip_addresses ||= begin
|
54
|
+
ips = @state[:filtered_ip_addresses]
|
55
|
+
ips = ips.call if ips.respond_to?(:call)
|
56
|
+
ips
|
57
|
+
end
|
58
|
+
end
|
42
59
|
end
|
43
60
|
|
44
61
|
def self.catalog
|
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.7
|
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-03-
|
11
|
+
date: 2019-03-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|