quonfig-openfeature 0.0.2 → 0.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f06d605c99762aee198d13fb3cc5c1e717af2c0d1868c8d9f621d00cd4eccace
4
- data.tar.gz: bad9becb07bc9965e47b053d5aeaa7ff8e94ca1b09c261d74dcd911306c727c7
3
+ metadata.gz: 6c1221d0ff74f947b7e5d54dfa126994f293cb2924411af33f23ecd5c821f864
4
+ data.tar.gz: bd7ca301c3723978a72fd88cc04f662544fab16c8a2b69729d20098921438e6d
5
5
  SHA512:
6
- metadata.gz: e3a473d41dbbbea5ceca03421fe2cd882284cfb10a47857707f0422bd66c04cc24fea0d87bd14f6ec2ce1f96770fcd0b2e7f387adcf4f365d07024a6b341dbaf
7
- data.tar.gz: dec998e3352b5ef04bec93f0637e846bc4cdfe3085da75baf995e4923fca4fc010e4dc6846c17f5660d12ba8b3303aa9a24a951e00d0b19cf682eb9cf90c5521
6
+ metadata.gz: 91fb7599243c068204364b9ae3b785146bbd61d0bed1ff40f9ec5c42001c1b18b1f981c5e05b5078dd73c2a16a60cc49434774fe678bc32116a6eda1ad079dc9
7
+ data.tar.gz: a9393d16f9722633b5e6ddbda84a3768600440fbc681e1cd29d179716bb7ac84c430e8dff5ff2cfda7d8a476cac67b3a5596b3737e0b1bef7da1f1a9f6354979
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.2
1
+ 0.0.4
@@ -97,27 +97,13 @@ module Quonfig
97
97
 
98
98
  def fetch_boolean_value(flag_key:, default_value:, evaluation_context: nil)
99
99
  evaluate(flag_key, default_value, evaluation_context) do |client, mapped_ctx|
100
- value = client.get_bool(flag_key, default: nil, context: mapped_ctx)
101
- if value.nil?
102
- ResolutionDetails.new(value: default_value, reason: Reason::ERROR,
103
- error_code: ErrorCode::FLAG_NOT_FOUND,
104
- error_message: "flag not found: #{flag_key}")
105
- else
106
- ResolutionDetails.new(value: value, reason: Reason::TARGETING_MATCH)
107
- end
100
+ to_resolution(client.get_bool_details(flag_key, context: mapped_ctx), default_value)
108
101
  end
109
102
  end
110
103
 
111
104
  def fetch_string_value(flag_key:, default_value:, evaluation_context: nil)
112
105
  evaluate(flag_key, default_value, evaluation_context) do |client, mapped_ctx|
113
- value = client.get_string(flag_key, default: nil, context: mapped_ctx)
114
- if value.nil?
115
- ResolutionDetails.new(value: default_value, reason: Reason::ERROR,
116
- error_code: ErrorCode::FLAG_NOT_FOUND,
117
- error_message: "flag not found: #{flag_key}")
118
- else
119
- ResolutionDetails.new(value: value, reason: Reason::TARGETING_MATCH)
120
- end
106
+ to_resolution(client.get_string_details(flag_key, context: mapped_ctx), default_value)
121
107
  end
122
108
  end
123
109
 
@@ -126,76 +112,81 @@ module Quonfig
126
112
  # first, fall back to float so we transparently handle both Quonfig
127
113
  # int and double configs.
128
114
  evaluate(flag_key, default_value, evaluation_context) do |client, mapped_ctx|
129
- value = nil
130
- begin
131
- value = client.get_int(flag_key, default: nil, context: mapped_ctx)
132
- rescue ::Quonfig::Errors::TypeMismatchError
133
- value = client.get_float(flag_key, default: nil, context: mapped_ctx)
134
- end
135
-
136
- if value.nil?
137
- ResolutionDetails.new(value: default_value, reason: Reason::ERROR,
138
- error_code: ErrorCode::FLAG_NOT_FOUND,
139
- error_message: "flag not found: #{flag_key}")
140
- else
141
- ResolutionDetails.new(value: value, reason: Reason::TARGETING_MATCH)
115
+ details = client.get_int_details(flag_key, context: mapped_ctx)
116
+ if details.error_code == ::Quonfig::EvaluationDetails::ERROR_TYPE_MISMATCH
117
+ details = client.get_float_details(flag_key, context: mapped_ctx)
142
118
  end
119
+ to_resolution(details, default_value)
143
120
  end
144
121
  end
145
122
 
146
123
  def fetch_integer_value(flag_key:, default_value:, evaluation_context: nil)
147
124
  evaluate(flag_key, default_value, evaluation_context) do |client, mapped_ctx|
148
- value = client.get_int(flag_key, default: nil, context: mapped_ctx)
149
- if value.nil?
150
- ResolutionDetails.new(value: default_value, reason: Reason::ERROR,
151
- error_code: ErrorCode::FLAG_NOT_FOUND,
152
- error_message: "flag not found: #{flag_key}")
153
- else
154
- ResolutionDetails.new(value: value, reason: Reason::TARGETING_MATCH)
155
- end
125
+ to_resolution(client.get_int_details(flag_key, context: mapped_ctx), default_value)
156
126
  end
157
127
  end
158
128
 
159
129
  def fetch_float_value(flag_key:, default_value:, evaluation_context: nil)
160
130
  evaluate(flag_key, default_value, evaluation_context) do |client, mapped_ctx|
161
- value = client.get_float(flag_key, default: nil, context: mapped_ctx)
162
- if value.nil?
163
- ResolutionDetails.new(value: default_value, reason: Reason::ERROR,
164
- error_code: ErrorCode::FLAG_NOT_FOUND,
165
- error_message: "flag not found: #{flag_key}")
166
- else
167
- ResolutionDetails.new(value: value, reason: Reason::TARGETING_MATCH)
168
- end
131
+ to_resolution(client.get_float_details(flag_key, context: mapped_ctx), default_value)
169
132
  end
170
133
  end
171
134
 
172
- # Object resolution tries +get_string_list+ first (so Quonfig
135
+ # Object resolution tries +get_string_list_details+ first (so Quonfig
173
136
  # +string_list+ configs surface as native arrays), then falls back to
174
- # +get_json+ for any other JSON-shaped config.
137
+ # +get_json_details+ for any other JSON-shaped config.
175
138
  def fetch_object_value(flag_key:, default_value:, evaluation_context: nil)
176
139
  evaluate(flag_key, default_value, evaluation_context) do |client, mapped_ctx|
177
- value = nil
178
- begin
179
- value = client.get_string_list(flag_key, default: nil, context: mapped_ctx)
180
- rescue ::Quonfig::Errors::TypeMismatchError
181
- value = nil
182
- end
183
- if value.nil?
184
- value = client.get_json(flag_key, default: nil, context: mapped_ctx)
185
- end
186
-
187
- if value.nil?
188
- ResolutionDetails.new(value: default_value, reason: Reason::ERROR,
189
- error_code: ErrorCode::FLAG_NOT_FOUND,
190
- error_message: "flag not found: #{flag_key}")
191
- else
192
- ResolutionDetails.new(value: value, reason: Reason::TARGETING_MATCH)
140
+ details = client.get_string_list_details(flag_key, context: mapped_ctx)
141
+ if details.error_code == ::Quonfig::EvaluationDetails::ERROR_TYPE_MISMATCH
142
+ details = client.get_json_details(flag_key, context: mapped_ctx)
193
143
  end
144
+ to_resolution(details, default_value)
194
145
  end
195
146
  end
196
147
 
197
148
  private
198
149
 
150
+ # Map a Quonfig::EvaluationDetails to the OpenFeature ResolutionDetails
151
+ # the SDK consumes. The Quonfig SDK's *_details methods don't raise, so
152
+ # this is a pure mapping layer.
153
+ def to_resolution(details, default_value)
154
+ case details.reason
155
+ when ::Quonfig::EvaluationDetails::REASON_STATIC
156
+ ResolutionDetails.new(value: details.value, reason: Reason::STATIC)
157
+ when ::Quonfig::EvaluationDetails::REASON_TARGETING_MATCH
158
+ ResolutionDetails.new(value: details.value, reason: Reason::TARGETING_MATCH)
159
+ when ::Quonfig::EvaluationDetails::REASON_SPLIT
160
+ ResolutionDetails.new(value: details.value, reason: Reason::SPLIT)
161
+ when ::Quonfig::EvaluationDetails::REASON_DEFAULT
162
+ ResolutionDetails.new(value: default_value, reason: Reason::DEFAULT)
163
+ when ::Quonfig::EvaluationDetails::REASON_ERROR
164
+ ResolutionDetails.new(
165
+ value: default_value,
166
+ reason: Reason::ERROR,
167
+ error_code: map_error_code(details.error_code),
168
+ error_message: details.error_message
169
+ )
170
+ else
171
+ # Defensive default: surface as ERROR so unknown reasons don't
172
+ # silently leak the SDK value back.
173
+ ResolutionDetails.new(
174
+ value: default_value,
175
+ reason: Reason::ERROR,
176
+ error_code: ErrorCode::GENERAL,
177
+ error_message: "unknown reason: #{details.reason.inspect}"
178
+ )
179
+ end
180
+ end
181
+
182
+ def map_error_code(error_code)
183
+ case error_code
184
+ when ::Quonfig::EvaluationDetails::ERROR_FLAG_NOT_FOUND then ErrorCode::FLAG_NOT_FOUND
185
+ when ::Quonfig::EvaluationDetails::ERROR_TYPE_MISMATCH then ErrorCode::TYPE_MISMATCH
186
+ else ErrorCode::GENERAL
187
+ end
188
+ end
189
+
199
190
  def evaluate(flag_key, default_value, evaluation_context)
200
191
  client = @client
201
192
  if client.nil?
@@ -209,14 +200,6 @@ module Quonfig
209
200
 
210
201
  mapped_ctx = Context.map_context(evaluation_context, @targeting_key_mapping)
211
202
  yield(client, mapped_ctx)
212
- rescue ::Quonfig::Errors::MissingDefaultError => e
213
- ResolutionDetails.new(value: default_value, reason: Reason::ERROR,
214
- error_code: ErrorCode::FLAG_NOT_FOUND,
215
- error_message: e.message)
216
- rescue ::Quonfig::Errors::TypeMismatchError => e
217
- ResolutionDetails.new(value: default_value, reason: Reason::ERROR,
218
- error_code: ErrorCode::TYPE_MISMATCH,
219
- error_message: e.message)
220
203
  rescue ::Quonfig::Errors::UninitializedError, ::Quonfig::Errors::InitializationTimeoutError => e
221
204
  ResolutionDetails.new(value: default_value, reason: Reason::ERROR,
222
205
  error_code: ErrorCode::PROVIDER_NOT_READY,
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quonfig-openfeature
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Dwyer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-04-27 00:00:00.000000000 Z
11
+ date: 2026-05-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: openfeature-sdk
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 0.0.8
33
+ version: 0.0.12
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: 0.0.8
40
+ version: 0.0.12
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: minitest
43
43
  requirement: !ruby/object:Gem::Requirement