statsig 1.6.0 → 1.6.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: a1985e842f0301387596fbd3d8db298ce485c013a502c09a1aff00916882afc0
4
- data.tar.gz: 9cf814e0def7dc3fefd2db9d80f102ec318a41703e6638f66b8a8d844c751959
3
+ metadata.gz: 8dfdb320cf540cd81046ba96aae19d9d3f947ec557ad7fb7b405a35065eb67fa
4
+ data.tar.gz: 0e8d15d9c3f9aa0245c2e834e55394479775d2a9de23208e54dfb41be89e0326
5
5
  SHA512:
6
- metadata.gz: ba2661bcd29ca31b3c458f8046add904029b03ecc0eeeb0c358760467389e58c5f48b5bc39456df1ea2e30051df951359a37e1045283a5d77f911291b0f7bfcd
7
- data.tar.gz: 2631c284b8b792101558e90689353c79aa043a22cbf2f995f045efc4333f74d3d80fcca639ece7f11d734cc4a39b459edd08ce14f6603f86f09ad57afadf2c08
6
+ metadata.gz: e7a479f8ed9b2cbf49f4b567bdf16000b5ba23a88015593cec6e9806477419011a13b5ed64fd578208cec5f6633101c881e3fa0b98b0474a2faebc91aaf8be1e
7
+ data.tar.gz: d731197be16b7ef43d6c9060f00254b3db3a205bef736243a326a382e9fca1aa72b1335102612ab13c044a03f4dc247e0b3443badfad147dffdd8be8391a038d
@@ -6,19 +6,11 @@ module EvaluationHelpers
6
6
  func.call(a.to_f, b.to_f) rescue false
7
7
  end
8
8
 
9
- # returns true if array contains value, ignoring case when comparing strings
10
- def self.array_contains(array, value, ignore_case)
11
- return false unless array.is_a?(Array) && !value.nil?
12
- if value.is_a?(String) && match_string_in_array(array, value, ignore_case, ->(a, b) { a == b })
13
- return true
14
- end
15
- return array.include?(value)
16
- end
17
-
18
9
  # returns true if array has any element that evaluates to true with value using func lambda, ignoring case
19
10
  def self.match_string_in_array(array, value, ignore_case, func)
20
- return false unless array.is_a?(Array) && value.is_a?(String)
21
- array.any?{ |s| s.is_a?(String) && ((ignore_case && func.call(value.downcase, s.downcase)) || func.call(value, s)) } rescue false
11
+ return false unless array.is_a?(Array) && !value.nil?
12
+ str_value = value.to_s
13
+ array.any?{ |s| !s.nil? && ((ignore_case && func.call(str_value.downcase, s.to_s.downcase)) || func.call(str_value, s.to_s)) } rescue false
22
14
  end
23
15
 
24
16
  def self.compare_times(a, b, func)
data/lib/evaluator.rb CHANGED
@@ -138,13 +138,13 @@ class Evaluator
138
138
 
139
139
  # array operations
140
140
  when 'any'
141
- return EvaluationHelpers::array_contains(target, value, true)
141
+ return EvaluationHelpers::match_string_in_array(target, value, true, ->(a, b) { a == b })
142
142
  when 'none'
143
- return !EvaluationHelpers::array_contains(target, value, true)
143
+ return !EvaluationHelpers::match_string_in_array(target, value, true, ->(a, b) { a == b })
144
144
  when 'any_case_sensitive'
145
- return EvaluationHelpers::array_contains(target, value, false)
145
+ return EvaluationHelpers::match_string_in_array(target, value, false, ->(a, b) { a == b })
146
146
  when 'none_case_sensitive'
147
- return !EvaluationHelpers::array_contains(target, value, false)
147
+ return !EvaluationHelpers::match_string_in_array(target, value, false, ->(a, b) { a == b })
148
148
 
149
149
  #string
150
150
  when 'str_starts_with_any'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: statsig
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0
4
+ version: 1.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Statsig, Inc
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-09 00:00:00.000000000 Z
11
+ date: 2021-09-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler