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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9dcdd00664fa1b47134a36911b0d0319c98d8fdb3c012b54342f97a160f63424
4
- data.tar.gz: b85ac99ae90d9e5b5fd009227f2f07f39dea8ce8a3ba6854cb7cd524850c785a
3
+ metadata.gz: 14629ea70bc6ef083ef707b43a00dcf3b5cb1e8234ad91c202efd5a70b1e6dac
4
+ data.tar.gz: a7b8af30577d40b93c948e0ff726ac12236fee899ae5be8f9b165e1e934a93d0
5
5
  SHA512:
6
- metadata.gz: 845d3d1f0b96da3835a3ca7aec37dbdbaeac4a10d574277111f1642ccb55ff4b86abd420363a943f430efad68071bc34720d9fd03ba35cbcd12fd62332cb392b
7
- data.tar.gz: bf1f7889514902a82c72db708d030e789228abbc5237c94c3869d19bf5cee8a8888527d49f220c3f2d0afc12ce8d726dfaf9f00070f4bbc64c080bc79d155fd6
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:
@@ -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
- !v.match?(/\d/)
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
@@ -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
 
@@ -1,3 +1,3 @@
1
1
  module Determinator
2
- VERSION = '2.8.0'
2
+ VERSION = '2.9.2'
3
3
  end
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.8.0
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-01-25 00:00:00.000000000 Z
11
+ date: 2022-08-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday