statsig 1.31.1 → 1.32.0
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/api_config.rb +128 -0
- data/lib/client_initialize_helpers.rb +78 -88
- data/lib/config_result.rb +17 -32
- data/lib/constants.rb +60 -0
- data/lib/diagnostics.rb +1 -38
- data/lib/dynamic_config.rb +1 -24
- data/lib/error_boundary.rb +0 -5
- data/lib/evaluation_details.rb +4 -1
- data/lib/evaluation_helpers.rb +35 -3
- data/lib/evaluator.rb +332 -327
- data/lib/feature_gate.rb +0 -24
- data/lib/id_list.rb +1 -1
- data/lib/interfaces/data_store.rb +1 -1
- data/lib/interfaces/user_persistent_storage.rb +1 -1
- data/lib/layer.rb +1 -20
- data/lib/network.rb +6 -33
- data/lib/spec_store.rb +86 -74
- data/lib/statsig.rb +72 -97
- data/lib/statsig_driver.rb +63 -70
- data/lib/statsig_errors.rb +1 -1
- data/lib/statsig_event.rb +8 -8
- data/lib/statsig_logger.rb +21 -21
- data/lib/statsig_options.rb +0 -50
- data/lib/statsig_user.rb +27 -68
- data/lib/ua_parser.rb +1 -1
- data/lib/uri_helper.rb +1 -9
- data/lib/user_persistent_storage_utils.rb +0 -17
- metadata +8 -6
data/lib/evaluation_helpers.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
# typed: true
|
2
1
|
require 'time'
|
3
2
|
|
4
3
|
module EvaluationHelpers
|
@@ -9,9 +8,41 @@ module EvaluationHelpers
|
|
9
8
|
|
10
9
|
# returns true if array has any element that evaluates to true with value using func lambda, ignoring case
|
11
10
|
def self.match_string_in_array(array, value, ignore_case, func)
|
12
|
-
return false unless array.is_a?(Array) && !value.nil?
|
13
11
|
str_value = value.to_s
|
14
|
-
|
12
|
+
str_value_downcased = nil
|
13
|
+
|
14
|
+
return false if array.nil?
|
15
|
+
|
16
|
+
return array.any? do |item|
|
17
|
+
next false if item.nil?
|
18
|
+
item_str = item.to_s
|
19
|
+
|
20
|
+
return true if func.call(str_value, item_str)
|
21
|
+
next false unless ignore_case
|
22
|
+
|
23
|
+
str_value_downcased ||= str_value.downcase
|
24
|
+
func.call(str_value_downcased, item_str.downcase)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.equal_string_in_array(array, value, ignore_case)
|
29
|
+
str_value = value.to_s
|
30
|
+
str_value_downcased = nil
|
31
|
+
|
32
|
+
return false if array.nil?
|
33
|
+
|
34
|
+
return array.any? do |item|
|
35
|
+
next false if item.nil?
|
36
|
+
item_str = item.to_s
|
37
|
+
|
38
|
+
next false unless item_str.length == str_value.length
|
39
|
+
|
40
|
+
return true if item_str == str_value
|
41
|
+
next false unless ignore_case
|
42
|
+
|
43
|
+
str_value_downcased ||= str_value.downcase
|
44
|
+
item_str.downcase == str_value_downcased
|
45
|
+
end
|
15
46
|
end
|
16
47
|
|
17
48
|
def self.compare_times(a, b, func)
|
@@ -27,6 +58,7 @@ module EvaluationHelpers
|
|
27
58
|
private
|
28
59
|
|
29
60
|
def self.is_numeric(v)
|
61
|
+
return true if v.is_a?(Numeric)
|
30
62
|
!(v.to_s =~ /\A[-+]?\d*\.?\d+\z/).nil?
|
31
63
|
end
|
32
64
|
|