determinator 2.8.0 → 2.9.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +15 -0
- data/lib/determinator/control.rb +26 -2
- data/lib/determinator/feature.rb +2 -2
- data/lib/determinator/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 14629ea70bc6ef083ef707b43a00dcf3b5cb1e8234ad91c202efd5a70b1e6dac
|
4
|
+
data.tar.gz: a7b8af30577d40b93c948e0ff726ac12236fee899ae5be8f9b165e1e934a93d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4daeb35cd313579c5916e1a88300062e99b4185d6dab9fa5e825e1de56d65d8d2028ba37d22da398b730103f9d6f7ca3725d331b42b90e204d2c016eacce43ae
|
7
|
+
data.tar.gz: 6fc1b952241c2a8d58a94cdc0fe5f7c9255d41ed1e1228f5b35da4a16bebd94539388b1b1f4b0f7bec4ec17f1e17569006443e0ba787df5d9a54e822db68759e
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,18 @@
|
|
1
|
+
# 2.9.2
|
2
|
+
|
3
|
+
Bug fix:
|
4
|
+
- Fix parsing fixed determinations when the variant is an empty string
|
5
|
+
|
6
|
+
# 2.9.1
|
7
|
+
|
8
|
+
Feature:
|
9
|
+
- Add `callback` argument to Control, allowing custom logic to notice the determination.
|
10
|
+
|
11
|
+
# 2.9.0
|
12
|
+
|
13
|
+
Feature:
|
14
|
+
- When an app_version does not comply with semantic versioning specifications (e.g.: 2021.11.05 with a trailing zero instead of the correct 2021.11.5), return false.
|
15
|
+
|
1
16
|
# 2.8.0
|
2
17
|
|
3
18
|
Feature:
|
data/lib/determinator/control.rb
CHANGED
@@ -72,6 +72,20 @@ module Determinator
|
|
72
72
|
'#<Determinator::Control>'
|
73
73
|
end
|
74
74
|
|
75
|
+
# Defines code that should execute when a determination is completed. This is particularly
|
76
|
+
# helpful for comparing determinations made by this control with other mechanisms.
|
77
|
+
#
|
78
|
+
# Please note that this block will be executed _synchronously_ before delivering the determination to the callsite.
|
79
|
+
#
|
80
|
+
# @yield [name, arguments, determination] Will be called when a determination was requested for the
|
81
|
+
# specified feature with `name`, with the given keyword arguments.
|
82
|
+
# @yieldparam name [String, nil] The name of the feature
|
83
|
+
# @yieldparam args [Hash] The keyword arguments passed to the determination method. This includes :id, :guid, :properties.
|
84
|
+
# @yieldparam determination [String,Boolean] The result of the determination
|
85
|
+
def on_determination(&block)
|
86
|
+
@determination_callback = block
|
87
|
+
end
|
88
|
+
|
75
89
|
private
|
76
90
|
|
77
91
|
Indicators = Struct.new(:rollout, :variant)
|
@@ -81,12 +95,15 @@ module Determinator
|
|
81
95
|
|
82
96
|
if feature.nil? || feature.is_a?(ErrorResponse) || feature.is_a?(MissingResponse)
|
83
97
|
Determinator.notice_missing_feature(name)
|
98
|
+
run_determination_callback(name, {id: id, guid: guid, properties: properties}, false)
|
84
99
|
return false
|
85
100
|
end
|
86
101
|
|
87
|
-
determinate(feature, id: id, guid: guid, properties: properties).tap do |determination|
|
102
|
+
result = determinate(feature, id: id, guid: guid, properties: properties).tap do |determination|
|
88
103
|
Determinator.notice_determination(id, guid, feature, determination)
|
89
104
|
end
|
105
|
+
run_determination_callback(name, {id: id, guid: guid, properties: properties}, result)
|
106
|
+
result
|
90
107
|
end
|
91
108
|
|
92
109
|
def determinate(feature, id:, guid:, properties:)
|
@@ -241,7 +258,9 @@ module Determinator
|
|
241
258
|
!v.match?(Semantic::Version::SemVerRegexp)
|
242
259
|
end
|
243
260
|
invalid_groups = required.flatten.select do |v|
|
244
|
-
|
261
|
+
version_sections = v.split(/(\d(.+)?)/, 2)
|
262
|
+
without_operator = version_sections[1]&.strip || ''
|
263
|
+
!without_operator.match?(Semantic::Version::SemVerRegexp)
|
245
264
|
end
|
246
265
|
|
247
266
|
return false if (invalid_properties + invalid_groups).any?
|
@@ -318,5 +337,10 @@ module Determinator
|
|
318
337
|
hash[name.to_s] = [*values].map(&:to_s)
|
319
338
|
end
|
320
339
|
end
|
340
|
+
|
341
|
+
def run_determination_callback(name, args, determination)
|
342
|
+
return unless @determination_callback
|
343
|
+
@determination_callback.call(name, args, determination)
|
344
|
+
end
|
321
345
|
end
|
322
346
|
end
|
data/lib/determinator/feature.rb
CHANGED
@@ -100,10 +100,10 @@ module Determinator
|
|
100
100
|
return fixed_determination if fixed_determination.is_a? FixedDetermination
|
101
101
|
|
102
102
|
variant = fixed_determination['variant']
|
103
|
-
return nil if variant && !variants.keys.include?(variant)
|
103
|
+
return nil if variant.present? && !variants.keys.include?(variant)
|
104
104
|
|
105
105
|
# if a variant is present the fixed determination should always be on
|
106
|
-
return nil if variant && !fixed_determination['feature_on']
|
106
|
+
return nil if variant.present? && !fixed_determination['feature_on']
|
107
107
|
|
108
108
|
constraints = fixed_determination['constraints'].to_h
|
109
109
|
|
data/lib/determinator/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: determinator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.9.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- JP Hastings-Spital
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-08-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|