optimizely_server_side 1.2.2 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 3ff9896cc993d49c83c6eab111a00a8194a8d49f
4
- data.tar.gz: c330d40407ee0e8d136c4b328486a0cb74f8fa1c
2
+ SHA256:
3
+ metadata.gz: 495e3100088096055c65af170d0f206ff2860fa8bc7283c1850814a03fb2574f
4
+ data.tar.gz: ae71ecf19eefced00297911b1d9ea441f7d96dc168e51b863192e77ee7c76e57
5
5
  SHA512:
6
- metadata.gz: dc122cbd2e182a396000460abfa759f9cbc56af94b80fb0c8d73a8458c895cedbd5a4a1646035e469a691ad6032accecda7471ba42ab153cc7856d26b760313d
7
- data.tar.gz: 79b6589481f2b63335e3dee19367c0b98afa4b72dd1390175675a83ff6047ab1e775f716920b0fcbf91053f6051abb15363b5f1baae4a500c576c94677129831
6
+ metadata.gz: 9f9c0ded26d5de9feb2603ba7626b7a794276145d51e4ab56be22259488d888b04064de17c0c6d82cfd66fe630aebc44da9e9f875a7553386623fbec29b24205
7
+ data.tar.gz: 154826914c621ccfcabe0e39abacf1a8922b5e379b82e928e385b70224adea028c995adb4dd96e9e599a55d8e318f1b53b89440a6b463ca71b270ed9a0d326a2
@@ -1,3 +1,7 @@
1
+ # 2.0.0
2
+
3
+ Expose the feature flag APIs to run Feature Tests
4
+
1
5
  # 0.0.16
2
6
 
3
7
  Updated the tracking tag.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- optimizely_server_side (1.2.2)
4
+ optimizely_server_side (2.0.0)
5
5
  activesupport (>= 4.2.6)
6
6
  optimizely-sdk (~> 2.0)
7
7
 
@@ -33,7 +33,7 @@ GEM
33
33
  minitest (5.11.3)
34
34
  multi_xml (0.6.0)
35
35
  murmurhash3 (0.1.6)
36
- optimizely-sdk (2.0.1)
36
+ optimizely-sdk (2.1.1)
37
37
  httparty (~> 0.11)
38
38
  json-schema (~> 2.6)
39
39
  murmurhash3 (~> 0.1)
@@ -24,17 +24,43 @@ module OptimizelyServerSide
24
24
  def experiment(experiment_key, options = {}, &blk)
25
25
  # Merge any other options to user attributes
26
26
  OptimizelyServerSide.configuration.user_attributes.merge!(options.stringify_keys)
27
- variation_key = optimizely_sdk_project_instance(experiment_key)
27
+ variation_key = optimizely_sdk_project_instance(experiment_key, "experiment")
28
28
  OptimizelyServerSide::Experiment.new(experiment_key, variation_key).start(&blk)
29
29
  end
30
30
  alias_method :feature_flip, :experiment
31
31
 
32
- def optimizely_sdk_project_instance(experiment_key)
32
+ def optimizely_sdk_project_instance(experiment_key, type)
33
+ case type
34
+ when "experiment"
35
+ get_optimizely_instance.activate(experiment_key, visitor_id, user_attributes)
36
+ when "feature"
37
+ get_optimizely_instance.is_feature_enabled(experiment_key, visitor_id, user_attributes)
38
+ end
39
+ end
40
+
41
+ def feature_test(experiment_key, options = {})
42
+ OptimizelyServerSide.configuration.user_attributes.merge!(options.stringify_keys)
43
+ optimizely_sdk_project_instance(experiment_key, "feature")
44
+ end
45
+
46
+ [:string, :boolean, :integer, :double].each do |type|
47
+ define_method :"get_feature_variable_#{type}" do |experiment, variable_name |
48
+ method = get_optimizely_instance.method("get_feature_variable_#{type}")
49
+ method.call(experiment, variable_name, visitor_id )
50
+ end
51
+ end
52
+
53
+ def visitor_id
54
+ OptimizelyServerSide.configuration.user_attributes['visitor_id']
55
+ end
56
+
57
+ def user_attributes
58
+ OptimizelyServerSide.configuration.user_attributes.reject { |k,v| k == 'visitor_id'}
59
+ end
60
+
61
+ def get_optimizely_instance
33
62
  OptimizelyServerSide::OptimizelySdk
34
63
  .project_instance(event_dispatcher: OptimizelyServerSide.configuration.event_dispatcher)
35
- .activate(experiment_key,
36
- OptimizelyServerSide.configuration.user_attributes['visitor_id'],
37
- OptimizelyServerSide.configuration.user_attributes.reject { |k,v| k == 'visitor_id'})
38
64
  end
39
65
 
40
66
  end
@@ -2,8 +2,7 @@ $:.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.2.2'
6
- s.date = '2018-05-22'
5
+ s.version = '2.0.0'
7
6
  s.summary = "Optimizely server side. A wrapper on top of optimizely's ruby sdk for easy caching of server side config "
8
7
  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
8
  s.authors = ["Ankit Gupta"]
@@ -19,4 +18,4 @@ Gem::Specification.new do |s|
19
18
  s.add_development_dependency 'webmock', '~> 2.1'
20
19
  s.add_runtime_dependency 'optimizely-sdk' , '~> 2.0'
21
20
  s.add_runtime_dependency 'activesupport', '>= 4.2.6'
22
- end
21
+ 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: 1.2.2
4
+ version: 2.0.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: 2018-05-22 00:00:00.000000000 Z
11
+ date: 2019-01-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -121,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
121
121
  version: '0'
122
122
  requirements: []
123
123
  rubyforge_project:
124
- rubygems_version: 2.6.14
124
+ rubygems_version: 2.7.7
125
125
  signing_key:
126
126
  specification_version: 4
127
127
  summary: Optimizely server side. A wrapper on top of optimizely's ruby sdk for easy