eppo-server-sdk 0.2.2 → 0.2.4
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/lib/{assignment_logger.rb → eppo_client/assignment_logger.rb} +1 -1
- data/lib/{client.rb → eppo_client/client.rb} +6 -6
- data/lib/{config.rb → eppo_client/config.rb} +2 -2
- data/lib/{configuration_requestor.rb → eppo_client/configuration_requestor.rb} +2 -2
- data/lib/{configuration_store.rb → eppo_client/configuration_store.rb} +1 -1
- data/lib/{http_client.rb → eppo_client/http_client.rb} +1 -1
- data/lib/{rules.rb → eppo_client/rules.rb} +34 -2
- data/lib/{validation.rb → eppo_client/validation.rb} +1 -1
- data/lib/eppo_client/version.rb +5 -0
- data/lib/eppo_client.rb +13 -16
- metadata +17 -36
- /data/lib/{constants.rb → eppo_client/constants.rb} +0 -0
- /data/lib/{custom_errors.rb → eppo_client/custom_errors.rb} +0 -0
- /data/lib/{lru_cache.rb → eppo_client/lru_cache.rb} +0 -0
- /data/lib/{poller.rb → eppo_client/poller.rb} +0 -0
- /data/lib/{shard.rb → eppo_client/shard.rb} +0 -0
- /data/lib/{variation_type.rb → eppo_client/variation_type.rb} +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 98acb6907559d59d41dabba40eff3cc95404c1d2283144f73a64e05dd94b4688
|
4
|
+
data.tar.gz: 86b21cbf7552a6641e34dafedb1c158812777d27821818ee3e067dd6ca1e6eff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 38d1f7c43ded991c029cd7ac3e3c3c71116862899008d7163d216be45dd585cc7a3ea00ba04870cba2f771aeb589a75b50835c2a4d4e792de3d886879bfda7bd
|
7
|
+
data.tar.gz: 2e2e690225134fb4d76d36d605f4d391aeddd3b8d0f831e5f12516ca3d9fab2f5d4267812158d266a243b4d0f53d86a0d752d14a8420e6ad8bc996ded7f13184
|
@@ -3,12 +3,12 @@
|
|
3
3
|
require 'singleton'
|
4
4
|
require 'time'
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
6
|
+
require_relative 'constants'
|
7
|
+
require_relative 'custom_errors'
|
8
|
+
require_relative 'rules'
|
9
|
+
require_relative 'shard'
|
10
|
+
require_relative 'validation'
|
11
|
+
require_relative 'variation_type'
|
12
12
|
|
13
13
|
module EppoClient
|
14
14
|
# The main client singleton
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'semver'
|
4
|
+
|
3
5
|
# The helper module for rules
|
4
6
|
module EppoClient
|
5
7
|
module OperatorType
|
@@ -60,7 +62,12 @@ module EppoClient
|
|
60
62
|
when OperatorType::NOT_ONE_OF
|
61
63
|
!condition.value.map(&:downcase).include?(subject_value.to_s.downcase)
|
62
64
|
else
|
63
|
-
|
65
|
+
# Numeric operator: value could be numeric or semver.
|
66
|
+
if subject_value.is_a?(Numeric)
|
67
|
+
evaluate_numeric_condition(subject_value, condition)
|
68
|
+
elsif valid_semver?(subject_value)
|
69
|
+
compare_semver(subject_value, condition.value, condition.operator)
|
70
|
+
end
|
64
71
|
end
|
65
72
|
end
|
66
73
|
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength
|
@@ -82,6 +89,31 @@ module EppoClient
|
|
82
89
|
end
|
83
90
|
# rubocop:enable Metrics/MethodLength
|
84
91
|
|
92
|
+
# rubocop:disable Metrics/MethodLength
|
93
|
+
def compare_semver(attribute_value, condition_value, operator)
|
94
|
+
unless valid_semver?(attribute_value) && valid_semver?(condition_value)
|
95
|
+
return false
|
96
|
+
end
|
97
|
+
|
98
|
+
case operator
|
99
|
+
when OperatorType::GT
|
100
|
+
SemVer.parse(attribute_value) > SemVer.parse(condition_value)
|
101
|
+
when OperatorType::GTE
|
102
|
+
SemVer.parse(attribute_value) >= SemVer.parse(condition_value)
|
103
|
+
when OperatorType::LT
|
104
|
+
SemVer.parse(attribute_value) < SemVer.parse(condition_value)
|
105
|
+
when OperatorType::LTE
|
106
|
+
SemVer.parse(attribute_value) <= SemVer.parse(condition_value)
|
107
|
+
else
|
108
|
+
false
|
109
|
+
end
|
110
|
+
end
|
111
|
+
# rubocop:enable Metrics/MethodLength
|
112
|
+
|
113
|
+
def valid_semver?(string)
|
114
|
+
!SemVer.parse(string).nil?
|
115
|
+
end
|
116
|
+
|
85
117
|
module_function :find_matching_rule, :matches_rule, :evaluate_condition,
|
86
|
-
:evaluate_numeric_condition
|
118
|
+
:evaluate_numeric_condition, :valid_semver?, :compare_semver
|
87
119
|
end
|
data/lib/eppo_client.rb
CHANGED
@@ -1,15 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
require 'configuration_store'
|
3
|
+
require_relative 'eppo_client/assignment_logger'
|
4
|
+
require_relative 'eppo_client/http_client'
|
5
|
+
require_relative 'eppo_client/poller'
|
6
|
+
require_relative 'eppo_client/config'
|
7
|
+
require_relative 'eppo_client/client'
|
8
|
+
require_relative 'eppo_client/constants'
|
9
|
+
require_relative 'eppo_client/configuration_requestor'
|
10
|
+
require_relative 'eppo_client/configuration_store'
|
11
|
+
require_relative 'eppo_client/version'
|
13
12
|
|
14
13
|
# This module scopes all the client SDK's classes and functions
|
15
14
|
module EppoClient
|
@@ -29,13 +28,11 @@ module EppoClient
|
|
29
28
|
end
|
30
29
|
# rubocop:enable Metrics/MethodLength
|
31
30
|
|
32
|
-
# rubocop:disable Metrics/MethodLength
|
31
|
+
# rubocop:disable Metrics/MethodLength
|
33
32
|
def init(config)
|
34
33
|
config.validate
|
35
|
-
|
36
|
-
|
37
|
-
).to_hash_object[:version]
|
38
|
-
sdk_params = EppoClient::SdkParams.new(config.api_key, 'ruby', sdk_version)
|
34
|
+
sdk_params = EppoClient::SdkParams.new(config.api_key, 'ruby',
|
35
|
+
EppoClient::VERSION)
|
39
36
|
http_client = EppoClient::HttpClient.new(config.base_url,
|
40
37
|
sdk_params.formatted)
|
41
38
|
config_store = EppoClient::ConfigurationStore.new(
|
@@ -50,7 +47,7 @@ module EppoClient
|
|
50
47
|
)
|
51
48
|
end
|
52
49
|
end
|
53
|
-
# rubocop:enable Metrics/MethodLength
|
50
|
+
# rubocop:enable Metrics/MethodLength
|
54
51
|
|
55
52
|
module_function :init, :initialize_client
|
56
53
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eppo-server-sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eppo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-03-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|
@@ -70,26 +70,6 @@ dependencies:
|
|
70
70
|
- - ">="
|
71
71
|
- !ruby/object:Gem::Version
|
72
72
|
version: 2.0.0
|
73
|
-
- !ruby/object:Gem::Dependency
|
74
|
-
name: parse_gemspec
|
75
|
-
requirement: !ruby/object:Gem::Requirement
|
76
|
-
requirements:
|
77
|
-
- - "~>"
|
78
|
-
- !ruby/object:Gem::Version
|
79
|
-
version: '1.0'
|
80
|
-
- - ">="
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: 1.0.0
|
83
|
-
type: :runtime
|
84
|
-
prerelease: false
|
85
|
-
version_requirements: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - "~>"
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '1.0'
|
90
|
-
- - ">="
|
91
|
-
- !ruby/object:Gem::Version
|
92
|
-
version: 1.0.0
|
93
73
|
- !ruby/object:Gem::Dependency
|
94
74
|
name: rake
|
95
75
|
requirement: !ruby/object:Gem::Requirement
|
@@ -170,21 +150,22 @@ executables: []
|
|
170
150
|
extensions: []
|
171
151
|
extra_rdoc_files: []
|
172
152
|
files:
|
173
|
-
- lib/assignment_logger.rb
|
174
|
-
- lib/client.rb
|
175
|
-
- lib/config.rb
|
176
|
-
- lib/configuration_requestor.rb
|
177
|
-
- lib/configuration_store.rb
|
178
|
-
- lib/constants.rb
|
179
|
-
- lib/custom_errors.rb
|
180
153
|
- lib/eppo_client.rb
|
181
|
-
- lib/
|
182
|
-
- lib/
|
183
|
-
- lib/
|
184
|
-
- lib/
|
185
|
-
- lib/
|
186
|
-
- lib/
|
187
|
-
- lib/
|
154
|
+
- lib/eppo_client/assignment_logger.rb
|
155
|
+
- lib/eppo_client/client.rb
|
156
|
+
- lib/eppo_client/config.rb
|
157
|
+
- lib/eppo_client/configuration_requestor.rb
|
158
|
+
- lib/eppo_client/configuration_store.rb
|
159
|
+
- lib/eppo_client/constants.rb
|
160
|
+
- lib/eppo_client/custom_errors.rb
|
161
|
+
- lib/eppo_client/http_client.rb
|
162
|
+
- lib/eppo_client/lru_cache.rb
|
163
|
+
- lib/eppo_client/poller.rb
|
164
|
+
- lib/eppo_client/rules.rb
|
165
|
+
- lib/eppo_client/shard.rb
|
166
|
+
- lib/eppo_client/validation.rb
|
167
|
+
- lib/eppo_client/variation_type.rb
|
168
|
+
- lib/eppo_client/version.rb
|
188
169
|
homepage: https://github.com/Eppo-exp/ruby-sdk
|
189
170
|
licenses:
|
190
171
|
- MIT
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|