optimizely_server_side 0.0.15 → 0.0.16
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/Changelog.md +4 -0
- data/Gemfile.lock +1 -1
- data/lib/optimizely_server_side/experiment.rb +34 -31
- data/optimizely_server_side.gemspec +2 -2
- data/spec/optimizely_server_side/experiment_spec.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0a7fc6e25fdfc8553b5fff5cceedbbdd3dd8e370
|
4
|
+
data.tar.gz: f71fd7a2326133b7da816ad4ad03ebfa7fc8fb9e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1a7662d270eafcd8554c735f4caad460c25b8a69dea3b97b51798c9412c7009c950f57b8ec9f63a28df1a782b391d60e0dca4ea8013f286cfc5daf2dd65341b5
|
7
|
+
data.tar.gz: 970fe6afc3f367f9d3c2057fd57b5d25e92d853b5fbcac6bd558e4defd59b58f59e1a63bb7a235c71d5c2c066584f5bda3cd32d456fdd8e0a34fbb906afe8085
|
data/Changelog.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -14,7 +14,10 @@ module OptimizelyServerSide
|
|
14
14
|
# Hidden omniture tag for HTML tracking
|
15
15
|
def omniture_tag(evar: nil)
|
16
16
|
if @selected_variation_key
|
17
|
-
"<input type='hidden' data-optimizely=#{@experiment_key}:#{@selected_variation_key} data-optimizely-evar=#{evar}></input>".html_safe
|
17
|
+
#"<input type='hidden' data-optimizely=#{@experiment_key}:#{@selected_variation_key} data-optimizely-evar=#{evar}></input>".html_safe
|
18
|
+
#{}"<input type='hidden' data-optimizely=#{@experiment_key}:#{@selected_variation_key} data-optimizely-evar=#{evar}></input>".html_safe
|
19
|
+
key = "#{@experiment_key}:#{@selected_variation_key}"
|
20
|
+
%Q(<input type="hidden" name="ab_#{key}" id="ab_id_#{key}" value="" data-optimizely="#{key}" data-optimizely-evar="#{evar}"/>).html_safe
|
18
21
|
end
|
19
22
|
end
|
20
23
|
|
@@ -48,38 +51,38 @@ module OptimizelyServerSide
|
|
48
51
|
# Selects and calls the variation which is applicable
|
49
52
|
# In case of running test the applicable variation key is present
|
50
53
|
# In case of fallback / paused test we pick the primary variation
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
54
|
+
def applicable_variation
|
55
|
+
ActiveSupport::Notifications.instrument "oss.variation", variation: @selected_variation_key, experiment: @experiment_key, visitor_id: OptimizelyServerSide.configuration.user_attributes['visitor_id'] do
|
56
|
+
if @variations.any?(&variation_selector)
|
57
|
+
@variations.find(&variation_selector).call
|
58
|
+
else
|
59
|
+
primary_variation.call if primary_variation
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
60
63
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
64
|
+
# Primary variation is where primary: true
|
65
|
+
def primary_variation
|
66
|
+
@primary_variation ||= @variations.find(&:primary)
|
67
|
+
end
|
65
68
|
|
66
|
-
|
69
|
+
private
|
67
70
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
71
|
+
# Scope to query on selected variation
|
72
|
+
def variation_selector
|
73
|
+
->(variation) { variation.key == @selected_variation_key }
|
74
|
+
end
|
72
75
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
76
|
+
# Add all the variation to the variations collection
|
77
|
+
def add_variation(key, opts = {}, &blk)
|
78
|
+
Variation.new(
|
79
|
+
key: key,
|
80
|
+
primary: opts[:primary] || false,
|
81
|
+
content: blk
|
82
|
+
).tap do |variation_instance|
|
83
|
+
@variations << variation_instance
|
84
|
+
end
|
85
|
+
end
|
83
86
|
|
84
|
-
|
85
|
-
end
|
87
|
+
end
|
88
|
+
end
|
@@ -2,8 +2,8 @@ $:.push File.expand_path("../lib", __FILE__)
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = 'optimizely_server_side'
|
5
|
-
s.version = '0.0.
|
6
|
-
s.date = '2016-09-
|
5
|
+
s.version = '0.0.16'
|
6
|
+
s.date = '2016-09-19'
|
7
7
|
s.summary = "Optimizely server side. A wrapper on top of optimizely's ruby sdk for easy caching of server side config "
|
8
8
|
s.description = "Optimizely server side. A A/B test wrapper on top of optimizely's ruby sdk for easy caching of server side config and exposing few more utility helpers. Handling of fallbacks and marking primary experiments. "
|
9
9
|
s.authors = ["Ankit Gupta"]
|
@@ -357,7 +357,7 @@ RSpec.describe OptimizelyServerSide::Experiment do
|
|
357
357
|
context 'when experiment and selected variation is present' do
|
358
358
|
|
359
359
|
it 'should have omniture_tag' do
|
360
|
-
expect(subject.omniture_tag(evar: '11')).to eq("<input type
|
360
|
+
expect(subject.omniture_tag(evar: '11')).to eq("<input type=\"hidden\" name=\"ab_foo:variation_key_a\" id=\"ab_id_foo:variation_key_a\" value=\"\" data-optimizely=\"foo:variation_key_a\" data-optimizely-evar=\"11\"/>")
|
361
361
|
end
|
362
362
|
|
363
363
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: optimizely_server_side
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ankit Gupta
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-09-
|
11
|
+
date: 2016-09-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|