optimizely_server_side 1.0.1 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +10 -9
- data/lib/optimizely_server_side/experiment.rb +30 -30
- data/optimizely_server_side.gemspec +3 -3
- data/spec/spec_helper.rb +0 -3
- metadata +5 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 464c3bab3ece7513de4d17847c307ff5544938af
|
4
|
+
data.tar.gz: e81c2186d41ab2db87f7f5aaeb122a6b4d4691af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3458bffbfbea91734c3e84c4e41972c4830ee88892d3c00840dc573feca0ec90bc272810f9878df0504bdec114835231ee9a3e3134615d9c4dfb7043bab9158e
|
7
|
+
data.tar.gz: e76d1c4b232fcd04356fe7530de54393c91004efc806db0e00dda227b7965f423fdb2616bd515283aeb7f193ccf92f1b53b4a1cd27faa01301b1db79c7025cd6
|
data/Gemfile.lock
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
optimizely_server_side (1.0
|
4
|
+
optimizely_server_side (1.2.0)
|
5
5
|
activesupport (>= 4.2.6)
|
6
|
-
optimizely-sdk (~> 1.
|
6
|
+
optimizely-sdk (~> 1.4)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
activesupport (5.
|
11
|
+
activesupport (5.1.4)
|
12
12
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
13
13
|
i18n (~> 0.7)
|
14
14
|
minitest (~> 5.1)
|
@@ -23,16 +23,17 @@ GEM
|
|
23
23
|
diff-lcs (1.3)
|
24
24
|
docile (1.1.5)
|
25
25
|
hashdiff (0.3.2)
|
26
|
-
httparty (0.
|
26
|
+
httparty (0.15.6)
|
27
27
|
multi_xml (>= 0.5.2)
|
28
|
-
i18n (0.
|
28
|
+
i18n (0.9.0)
|
29
|
+
concurrent-ruby (~> 1.0)
|
29
30
|
json (2.1.0)
|
30
31
|
json-schema (2.8.0)
|
31
32
|
addressable (>= 2.4)
|
32
|
-
minitest (5.10.
|
33
|
+
minitest (5.10.3)
|
33
34
|
multi_xml (0.6.0)
|
34
35
|
murmurhash3 (0.1.6)
|
35
|
-
optimizely-sdk (1.
|
36
|
+
optimizely-sdk (1.4.0)
|
36
37
|
httparty (~> 0.11)
|
37
38
|
json-schema (~> 2.6)
|
38
39
|
murmurhash3 (~> 0.1)
|
@@ -57,7 +58,7 @@ GEM
|
|
57
58
|
simplecov-html (~> 0.10.0)
|
58
59
|
simplecov-html (0.10.0)
|
59
60
|
thread_safe (0.3.6)
|
60
|
-
tzinfo (1.2.
|
61
|
+
tzinfo (1.2.4)
|
61
62
|
thread_safe (~> 0.1)
|
62
63
|
webmock (2.3.2)
|
63
64
|
addressable (>= 2.3.6)
|
@@ -74,4 +75,4 @@ DEPENDENCIES
|
|
74
75
|
webmock (~> 2.1)
|
75
76
|
|
76
77
|
BUNDLED WITH
|
77
|
-
1.
|
78
|
+
1.15.4
|
@@ -51,38 +51,38 @@ module OptimizelyServerSide
|
|
51
51
|
# Selects and calls the variation which is applicable
|
52
52
|
# In case of running test the applicable variation key is present
|
53
53
|
# In case of fallback / paused test we pick the primary variation
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
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
|
63
63
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
64
|
+
# Primary variation is where primary: true
|
65
|
+
def primary_variation
|
66
|
+
@primary_variation ||= @variations.find(&:primary)
|
67
|
+
end
|
68
68
|
|
69
|
-
|
69
|
+
private
|
70
70
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
71
|
+
# Scope to query on selected variation
|
72
|
+
def variation_selector
|
73
|
+
->(variation) { variation.key == @selected_variation_key }
|
74
|
+
end
|
75
75
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
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
|
86
86
|
|
87
|
-
|
88
|
-
|
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 = '1.0
|
6
|
-
s.date = '2017-
|
5
|
+
s.version = '1.2.0'
|
6
|
+
s.date = '2017-11-01'
|
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"]
|
@@ -17,6 +17,6 @@ Gem::Specification.new do |s|
|
|
17
17
|
s.license = 'MIT'
|
18
18
|
s.add_development_dependency 'rspec', '~> 3.5'
|
19
19
|
s.add_development_dependency 'webmock', '~> 2.1'
|
20
|
-
s.add_runtime_dependency 'optimizely-sdk' , '~> 1.
|
20
|
+
s.add_runtime_dependency 'optimizely-sdk' , '~> 1.4'
|
21
21
|
s.add_runtime_dependency 'activesupport', '>= 4.2.6'
|
22
22
|
end
|
data/spec/spec_helper.rb
CHANGED
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: 1.0
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ankit Gupta
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-11-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -44,20 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '1.
|
48
|
-
- - ">="
|
49
|
-
- !ruby/object:Gem::Version
|
50
|
-
version: 1.1.2
|
47
|
+
version: '1.4'
|
51
48
|
type: :runtime
|
52
49
|
prerelease: false
|
53
50
|
version_requirements: !ruby/object:Gem::Requirement
|
54
51
|
requirements:
|
55
52
|
- - "~>"
|
56
53
|
- !ruby/object:Gem::Version
|
57
|
-
version: '1.
|
58
|
-
- - ">="
|
59
|
-
- !ruby/object:Gem::Version
|
60
|
-
version: 1.1.2
|
54
|
+
version: '1.4'
|
61
55
|
- !ruby/object:Gem::Dependency
|
62
56
|
name: activesupport
|
63
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -127,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
127
121
|
version: '0'
|
128
122
|
requirements: []
|
129
123
|
rubyforge_project:
|
130
|
-
rubygems_version: 2.6.
|
124
|
+
rubygems_version: 2.6.12
|
131
125
|
signing_key:
|
132
126
|
specification_version: 4
|
133
127
|
summary: Optimizely server side. A wrapper on top of optimizely's ruby sdk for easy
|