determinator 2.7.1 → 2.9.1

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: 54342b4c971ac191030bf2aa264c419e0afc3f8dc1b2558f140ad99b021dbb7c
4
- data.tar.gz: '049f2d041afbaa2556f08f636c6ff43397f0625c910a2a05ee95b57875882d14'
3
+ metadata.gz: 227a75590dfa088f7096c65a51ab2d2950f9605ed3f29c7d62119df86e2c3721
4
+ data.tar.gz: 77c7e9ae41428c7e898f3dca7464d6987210379723bd8bc73906a8c73cbd62d2
5
5
  SHA512:
6
- metadata.gz: 381afb82fb6f1e0085aaa20ad681562f2ced69c4196bee3d3ac7fb96e186df748a73f462d73711a0e36e520031ca20d91c7a5ec7d9b61d13d8bf76464629a51c
7
- data.tar.gz: e6676ae384f5d61b2af9f5f248e55d88ffd6dff680672e353cab4d380d2564f5c9947ad59f0e483e3ffbe30de6e7cbba029ba8ead4feb660f874d93867c24eae
6
+ metadata.gz: 59fcec1ac83528e76f9ccdfb5985732d336fc6bb177055a4d5c02a4929f20c98b1a6052c96fa3397430c40d40733b4b8fb2fb801db041a3a125db64bd68276cf
7
+ data.tar.gz: dc73504e3e55e79d10a0939e3a32f16525523b8e480da280aae2a0400b578b3e04cb893ef593967767ffab88370ef118310d37b7df906cc48ea547dcb8570e91
data/CHANGELOG.md CHANGED
@@ -1,3 +1,18 @@
1
+ # 2.9.1
2
+
3
+ Feature:
4
+ - Add `callback` argument to Control, allowing custom logic to notice the determination.
5
+
6
+ # 2.9.0
7
+
8
+ Feature:
9
+ - 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.
10
+
11
+ # 2.8.0
12
+
13
+ Feature:
14
+ - When a GUID bucketed feature is misconfigured, handle the error and return false.
15
+
1
16
  # 2.7.1
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:)
@@ -124,13 +141,9 @@ module Determinator
124
141
  # require_variant_determination?
125
142
  return true unless require_variant_determination?(feature)
126
143
 
127
-
128
-
129
144
  explainer.log(:chosen_variant) {
130
145
  variant_for(feature, indicators.variant)
131
146
  }
132
- rescue ArgumentError
133
- raise
134
147
 
135
148
  rescue => e
136
149
  Determinator.notice_error(e)
@@ -245,7 +258,9 @@ module Determinator
245
258
  !v.match?(Semantic::Version::SemVerRegexp)
246
259
  end
247
260
  invalid_groups = required.flatten.select do |v|
248
- !v.match?(/\d/)
261
+ version_sections = v.split(/(\d(.+)?)/, 2)
262
+ without_operator = version_sections[1]&.strip || ''
263
+ !without_operator.match?(Semantic::Version::SemVerRegexp)
249
264
  end
250
265
 
251
266
  return false if (invalid_properties + invalid_groups).any?
@@ -322,5 +337,10 @@ module Determinator
322
337
  hash[name.to_s] = [*values].map(&:to_s)
323
338
  end
324
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
325
345
  end
326
346
  end
@@ -1,3 +1,3 @@
1
1
  module Determinator
2
- VERSION = '2.7.1'
2
+ VERSION = '2.9.1'
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.7.1
4
+ version: 2.9.1
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: 2021-12-13 00:00:00.000000000 Z
11
+ date: 2022-07-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday