eppo-server-sdk 0.2.2 → 0.2.4

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: 5fd8f3093395da766b70f3e7cba84b6fc712f58c05092b3594ab53cb0d0f827d
4
- data.tar.gz: f773c3f04448a9a63c2e495c07099d952df7579b87472f9cf281e22d69698127
3
+ metadata.gz: 98acb6907559d59d41dabba40eff3cc95404c1d2283144f73a64e05dd94b4688
4
+ data.tar.gz: 86b21cbf7552a6641e34dafedb1c158812777d27821818ee3e067dd6ca1e6eff
5
5
  SHA512:
6
- metadata.gz: bdf91e318a7a4ef6e8eeb90650b94f6ce712ca58b35fdf99e08e60a71c79ef91c769e0798e709c1b59da8c060bffcb765ff8e9afc06d58330ceab2155d71d26a
7
- data.tar.gz: 22f8876c55dd41194a25bd9b31174f3cb84e8a760507afe72f5eb8a9f9859e8d32d4938b1a6c82147fafd011bcfd1df1f848bea818bd9d927bbd2051db657dd5
6
+ metadata.gz: 38d1f7c43ded991c029cd7ac3e3c3c71116862899008d7163d216be45dd585cc7a3ea00ba04870cba2f771aeb589a75b50835c2a4d4e792de3d886879bfda7bd
7
+ data.tar.gz: 2e2e690225134fb4d76d36d605f4d391aeddd3b8d0f831e5f12516ca3d9fab2f5d4267812158d266a243b4d0f53d86a0d752d14a8420e6ad8bc996ded7f13184
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'custom_errors'
3
+ require_relative 'custom_errors'
4
4
 
5
5
  module EppoClient
6
6
  # The base assignment logger class to override
@@ -3,12 +3,12 @@
3
3
  require 'singleton'
4
4
  require 'time'
5
5
 
6
- require 'constants'
7
- require 'custom_errors'
8
- require 'rules'
9
- require 'shard'
10
- require 'validation'
11
- require 'variation_type'
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,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'validation'
4
- require 'assignment_logger'
3
+ require_relative 'validation'
4
+ require_relative 'assignment_logger'
5
5
 
6
6
  module EppoClient
7
7
  # The class for configuring the Eppo client singleton
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'custom_errors'
4
- require 'constants'
3
+ require_relative 'custom_errors'
4
+ require_relative 'constants'
5
5
 
6
6
  module EppoClient
7
7
  # A class for the variation object
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'concurrent/atomic/read_write_lock'
4
4
 
5
- require 'lru_cache'
5
+ require_relative 'lru_cache'
6
6
 
7
7
  module EppoClient
8
8
  # A thread safe store for the configurations to ensure that retrievals pull from a single source of truth
@@ -3,7 +3,7 @@
3
3
  require 'faraday'
4
4
  require 'faraday/retry'
5
5
 
6
- require 'custom_errors'
6
+ require_relative 'custom_errors'
7
7
 
8
8
  REQUEST_TIMEOUT_SECONDS = 2
9
9
  # This applies only to failed DNS lookups and connection timeouts,
@@ -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
- subject_value.is_a?(Numeric) && evaluate_numeric_condition(subject_value, condition)
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
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'custom_errors'
3
+ require_relative 'custom_errors'
4
4
 
5
5
  # The helper module to validate keys
6
6
  module EppoClient
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EppoClient
4
+ VERSION = '0.2.4'
5
+ end
data/lib/eppo_client.rb CHANGED
@@ -1,15 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'parse_gemspec'
4
-
5
- require 'assignment_logger'
6
- require 'http_client'
7
- require 'poller'
8
- require 'config'
9
- require 'client'
10
- require 'constants'
11
- require 'configuration_requestor'
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, Metrics/AbcSize
31
+ # rubocop:disable Metrics/MethodLength
33
32
  def init(config)
34
33
  config.validate
35
- sdk_version = ParseGemspec::Specification.load(
36
- 'eppo-server-sdk.gemspec'
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, Metrics/AbcSize
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.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: 2023-10-26 00:00:00.000000000 Z
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/http_client.rb
182
- - lib/lru_cache.rb
183
- - lib/poller.rb
184
- - lib/rules.rb
185
- - lib/shard.rb
186
- - lib/validation.rb
187
- - lib/variation_type.rb
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