amplitude-experiment 1.1.1 → 1.1.2

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
2
  SHA256:
3
- metadata.gz: 1f1a1506a90fa83f40415c6524e7f298ed5173128ff646e11e414f108c8e2f17
4
- data.tar.gz: 869a2a9b4f6ff51d0bacf68539e2840d6d229dba821c04419edfe90e383cf638
3
+ metadata.gz: 53e7251a50e66bfd3145abbf399860592fec625dba57df40b84cd2f235a41fd3
4
+ data.tar.gz: 7405cf8193e72163cc9df7d216460e2eee5b3352ff255e97eed7ec7f5de7367a
5
5
  SHA512:
6
- metadata.gz: bb65907db678517994db78e505f511a9b1d757fe1a9da95a7aa1455e1aae3b830494be51b3b72076fc90d57654f33756c146efd5385a98c79e5b50944962c102
7
- data.tar.gz: b85101341b8edf212426689aaf23a2ebbed40fc17ab76ca419add6714c6c2a1019438fb05f203ed49037b0552e5e4b1b99cf433ed5ff655e567ffea84915b478
6
+ metadata.gz: cb9498e7a4bd0112e981732e136b2b6907fd34bc9c8bb645e41645c6074edcd891e95bee9919dc987bafdd4bd26969c07e6400884051375756dbb4524d83ba11
7
+ data.tar.gz: 990927832f1a67b211f982c4a350997d2a2cb91b0d2a62d605b412547e835404145b5546271f4af9dd75af4582b64fb887529f380c1ee4980ac9e81330e581c6
@@ -16,9 +16,10 @@ Gem::Specification.new do |spec|
16
16
  'amplitude-experiment.gemspec',
17
17
  'Gemfile',
18
18
  'lib/experiment/local/evaluation/lib/**/*']
19
- spec.require_paths = ["lib"]
19
+ spec.require_paths = ['lib']
20
20
  spec.extra_rdoc_files = ['README.md']
21
21
 
22
+ spec.add_development_dependency 'psych', '~> 4.0'
22
23
  spec.add_development_dependency 'rake', '~> 13.0'
23
24
  spec.add_development_dependency 'rdoc', '= 6.4'
24
25
  spec.add_development_dependency 'rspec', '~> 3.6'
@@ -26,7 +27,6 @@ Gem::Specification.new do |spec|
26
27
  spec.add_development_dependency 'simplecov', '~> 0.21'
27
28
  spec.add_development_dependency 'webmock', '~> 3.14'
28
29
  spec.add_development_dependency 'yard', '~> 0.9'
29
- spec.add_development_dependency 'psych', '~> 4.0'
30
30
  spec.metadata['rubygems_mfa_required'] = 'false'
31
31
  spec.add_runtime_dependency 'ffi', '~> 1.15.5'
32
32
  end
@@ -38,9 +38,9 @@ module AmplitudeExperiment
38
38
 
39
39
  user_str = user.to_json
40
40
  @logger.debug("[Experiment] Evaluate: User: #{user_str} - Rules: #{flags}") if @config.debug
41
- results_json = evaluation(flags, user_str)
42
- @logger.debug("[Experiment] evaluate - result: #{results_json}") if @config.debug
43
- parse_results_json(results_json, flag_keys)
41
+ result = evaluation(flags, user_str)
42
+ @logger.debug("[Experiment] evaluate - result: #{result}") if @config.debug
43
+ parse_results(result, flag_keys)
44
44
  end
45
45
 
46
46
  # Fetch initial flag configurations and start polling for updates.
@@ -61,8 +61,7 @@ module AmplitudeExperiment
61
61
 
62
62
  private
63
63
 
64
- def parse_results_json(results_json, flag_keys)
65
- result = JSON.parse(results_json)
64
+ def parse_results(result, flag_keys)
66
65
  variants = {}
67
66
  result.each do |key, value|
68
67
  next if value['isDefaultVariant'] || (flag_keys.empty? && flag_keys.include?(key))
@@ -1,5 +1,6 @@
1
1
  # rubocop:disable all
2
2
  require 'ffi'
3
+ require 'json'
3
4
 
4
5
  # The evaluation wrapper
5
6
  module EvaluationInterop
@@ -59,7 +60,13 @@ end
59
60
  def evaluation(rule_json, user_json)
60
61
  lib = EvaluationInterop.libevaluation_interop_symbols()
61
62
  fn = lib[:kotlin][:root][:evaluate]
62
- evaluation_result = fn.call(rule_json, user_json)
63
- evaluation_result.read_string
63
+ result_json = fn.call(rule_json, user_json).read_string
64
+ result = JSON.parse(result_json)
65
+ if result["error"] != nil
66
+ raise "#{result["error"]}"
67
+ elsif result["result"] == nil
68
+ raise "Evaluation result is nil."
69
+ end
70
+ result["result"]
64
71
  end
65
72
  # rubocop:disable all
@@ -1,3 +1,3 @@
1
1
  module AmplitudeExperiment
2
- VERSION = '1.1.1'.freeze
2
+ VERSION = '1.1.2'.freeze
3
3
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: amplitude-experiment
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Amplitude
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-05-22 00:00:00.000000000 Z
11
+ date: 2023-06-10 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: psych
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '4.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '4.0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: rake
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -108,20 +122,6 @@ dependencies:
108
122
  - - "~>"
109
123
  - !ruby/object:Gem::Version
110
124
  version: '0.9'
111
- - !ruby/object:Gem::Dependency
112
- name: psych
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - "~>"
116
- - !ruby/object:Gem::Version
117
- version: '4.0'
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - "~>"
123
- - !ruby/object:Gem::Version
124
- version: '4.0'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: ffi
127
127
  requirement: !ruby/object:Gem::Requirement