featureflip 2.13.0 → 2.13.1
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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c4c086d9a3b50763d562f2a79ef07aa449ddbdb1b88446d8fee98948d7c3933c
|
|
4
|
+
data.tar.gz: bf96d5faeb953a5219f1de18d5ff85d404b5fbf3daa783550b3b64837b0c72bc
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2a2a87d48a71704a9b2885885a55c74f664497be27703bb4dcb83463756347f771803cfa6608f2c2512b8cff19a982a21ab72d76c52ec53a45fd3d5187f02f45
|
|
7
|
+
data.tar.gz: be23805658d9ce4f0ba3c4a49f0fde25ea8e2e05e0da8497ab4ec94b557ee9d554b1ed870782acf6df2cbe8476bc5691ae8728eb4438a1259b304c09d91fc4fa
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
require_relative "context_attribute"
|
|
1
2
|
require "time"
|
|
2
3
|
|
|
3
4
|
module Featureflip
|
|
@@ -10,7 +11,7 @@ module Featureflip
|
|
|
10
11
|
REGEX_TIMEOUT_SECONDS = 0.1
|
|
11
12
|
|
|
12
13
|
def evaluate_condition(condition, context)
|
|
13
|
-
attr_value = context
|
|
14
|
+
attr_value = ContextAttribute.resolve(context, condition.attribute)
|
|
14
15
|
|
|
15
16
|
return condition.negate if attr_value.nil?
|
|
16
17
|
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
module Featureflip
|
|
2
|
+
module Evaluation
|
|
3
|
+
# Looks an attribute up in an evaluation context hash.
|
|
4
|
+
#
|
|
5
|
+
# "user_id" is the canonical spelling of the user identifier and "userId" is
|
|
6
|
+
# accepted as an alias (#4518). A lookup of exactly one of the two returns
|
|
7
|
+
# "user_id" when it is non-nil, else "userId" when it is non-nil, else nil.
|
|
8
|
+
# An empty string is a value and does not fall through. Every other key,
|
|
9
|
+
# including other casings, is an ordinary attribute.
|
|
10
|
+
module ContextAttribute
|
|
11
|
+
module_function
|
|
12
|
+
|
|
13
|
+
def resolve(context, attribute)
|
|
14
|
+
if attribute == "user_id" || attribute == "userId"
|
|
15
|
+
value = context["user_id"]
|
|
16
|
+
value = context["userId"] if value.nil?
|
|
17
|
+
value
|
|
18
|
+
else
|
|
19
|
+
context[attribute]
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
require_relative "context_attribute"
|
|
1
2
|
require_relative "condition_evaluator"
|
|
2
3
|
require_relative "bucketing"
|
|
3
4
|
require_relative "canonical_number"
|
|
@@ -164,7 +165,7 @@ module Featureflip
|
|
|
164
165
|
end
|
|
165
166
|
|
|
166
167
|
def warn_unbucketable(flag, rule_id, serve)
|
|
167
|
-
UnbucketableWarnings.warn(@logger, flag.key, rule_id, serve.bucket_by || "
|
|
168
|
+
UnbucketableWarnings.warn(@logger, flag.key, rule_id, serve.bucket_by || "user_id")
|
|
168
169
|
end
|
|
169
170
|
|
|
170
171
|
# Returns the variation key to serve, or nil when a Rollout serve can't bucket
|
|
@@ -178,13 +179,13 @@ module Featureflip
|
|
|
178
179
|
end
|
|
179
180
|
|
|
180
181
|
def resolve_rollout(serve, context)
|
|
181
|
-
bucket_by = serve.bucket_by || "
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
bucket_value = context["user_id"] if bucket_value.nil? && bucket_by == "userId"
|
|
185
|
-
bucket_value = context["userId"] if bucket_value.nil? && bucket_by == "user_id"
|
|
182
|
+
bucket_by = serve.bucket_by || "user_id"
|
|
183
|
+
# "user_id" and "userId" resolve the same identity (user_id first).
|
|
184
|
+
bucket_value = ContextAttribute.resolve(context, bucket_by)
|
|
186
185
|
bucket_value_str =
|
|
187
|
-
|
|
186
|
+
# An Array or Hash (a JSON array or object, empty or not) has no spelling every
|
|
187
|
+
# SDK shares, so it can't be bucketed, like a missing value (#4572).
|
|
188
|
+
if bucket_value.nil? || bucket_value.is_a?(Array) || bucket_value.is_a?(Hash) then ""
|
|
188
189
|
elsif bucket_value.is_a?(Float) then CanonicalNumber.format(bucket_value)
|
|
189
190
|
elsif defined?(::BigDecimal) && bucket_value.is_a?(::BigDecimal) then CanonicalNumber.format_big_decimal(bucket_value)
|
|
190
191
|
else bucket_value.to_s
|
|
@@ -196,7 +197,7 @@ module Featureflip
|
|
|
196
197
|
# empty key. Mirrors the engine + C#/Java SDK evaluators.
|
|
197
198
|
return serve.variation || "" if (serve.variations || []).empty?
|
|
198
199
|
|
|
199
|
-
# A missing, nil or
|
|
200
|
+
# A missing, nil, empty or non-scalar bucket value can't be bucketed: return nil so the caller
|
|
200
201
|
# skips the rule (or serves the fallthrough's variation) instead of hashing the empty
|
|
201
202
|
# string into an arbitrary bucket. Whitespace, "0", 0 and false bucket normally (#4236).
|
|
202
203
|
return nil if bucket_value_str == ""
|
data/lib/featureflip/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: featureflip
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.13.
|
|
4
|
+
version: 2.13.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Featureflip
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-10-
|
|
11
|
+
date: 2026-10-30 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: logger
|
|
@@ -81,6 +81,7 @@ files:
|
|
|
81
81
|
- lib/featureflip/evaluation/bucketing.rb
|
|
82
82
|
- lib/featureflip/evaluation/canonical_number.rb
|
|
83
83
|
- lib/featureflip/evaluation/condition_evaluator.rb
|
|
84
|
+
- lib/featureflip/evaluation/context_attribute.rb
|
|
84
85
|
- lib/featureflip/evaluation/evaluator.rb
|
|
85
86
|
- lib/featureflip/evaluation/unbucketable_warnings.rb
|
|
86
87
|
- lib/featureflip/events/event.rb
|