this_feature 0.10.0 → 0.11.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/.github/dependabot.yml +13 -0
- data/.github/workflows/linter-rubocop.yml +1 -1
- data/Gemfile.lock +3 -3
- data/docs/memory.md +4 -0
- data/lib/this_feature/adapters/memory.rb +19 -1
- data/lib/this_feature/configuration.rb +5 -1
- data/lib/this_feature/version.rb +1 -1
- data/lib/this_feature.rb +14 -1
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4f8b9d3709cdadcd289f916ccaabf17d6163daa087a2952f08e6cb800769685b
|
|
4
|
+
data.tar.gz: ff11aeed6a2deba49bd5d1ca4517f73dce29d3238fceff6bee6f1a7735dedce6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fcdd8e883cf7ac9abf17d00b2051a3d23aebe1b84bff45d58ea730621f4a629f07a2bf649f8107f7e38544e9c0edb266e632681c7dea069378342f8f205032ca
|
|
7
|
+
data.tar.gz: 41e40d6517de30f310414987c16b91807271a69fa41c4a14204107cda7f3a94e85696ace92b968f0e5c8063af5dc2f739230b6dbeb9d6009d263e56a133da143
|
data/Gemfile.lock
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
this_feature (0.
|
|
5
|
-
this_feature-adapters-flipper (0.
|
|
4
|
+
this_feature (0.11.0)
|
|
5
|
+
this_feature-adapters-flipper (0.11.0)
|
|
6
6
|
flipper
|
|
7
7
|
flipper-active_record
|
|
8
8
|
this_feature
|
|
9
|
-
this_feature-adapters-split_io (0.
|
|
9
|
+
this_feature-adapters-split_io (0.11.0)
|
|
10
10
|
splitclient-rb
|
|
11
11
|
this_feature
|
|
12
12
|
|
data/docs/memory.md
CHANGED
|
@@ -34,6 +34,25 @@ class ThisFeature
|
|
|
34
34
|
!present?(flag_name)
|
|
35
35
|
end
|
|
36
36
|
|
|
37
|
+
def treatment_config(flag_name, context: nil, data: {}, record: nil)
|
|
38
|
+
return if !present?(flag_name) || context.nil?
|
|
39
|
+
|
|
40
|
+
flag_data = storage[flag_name][:config_contexts]
|
|
41
|
+
context_registered = flag_data&.key?(context_key(context))
|
|
42
|
+
|
|
43
|
+
return if !flag_data || !context_registered
|
|
44
|
+
|
|
45
|
+
flag_data[context_key(context)]
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def enable_config!(flag_name, config: nil, context: nil)
|
|
49
|
+
return false if config.nil? || flag_name.nil? || context.nil?
|
|
50
|
+
|
|
51
|
+
storage[flag_name] ||= {}
|
|
52
|
+
storage[flag_name][:config_contexts] ||= {}
|
|
53
|
+
storage[flag_name][:config_contexts][context_key(context)] = config
|
|
54
|
+
end
|
|
55
|
+
|
|
37
56
|
def treatment_value(flag_name, context: nil, data: {}, record: nil)
|
|
38
57
|
return 'control' if !present?(flag_name) || context.nil?
|
|
39
58
|
|
|
@@ -42,7 +61,6 @@ class ThisFeature
|
|
|
42
61
|
|
|
43
62
|
return 'control' if !flag_data || !context_registered
|
|
44
63
|
|
|
45
|
-
flag_data ||= {}
|
|
46
64
|
flag_data[context_key(context)]
|
|
47
65
|
end
|
|
48
66
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
class ThisFeature
|
|
2
2
|
class Configuration
|
|
3
|
-
attr_writer :adapters, :default_adapter, :test_adapter, :base_data_lambda
|
|
3
|
+
attr_writer :adapters, :default_adapter, :test_adapter, :base_data_lambda, :on_nil_context
|
|
4
4
|
|
|
5
5
|
def init
|
|
6
6
|
validate_adapters!
|
|
@@ -29,5 +29,9 @@ class ThisFeature
|
|
|
29
29
|
def base_data_lambda
|
|
30
30
|
@base_data_lambda ||= ->(_record) { {} }
|
|
31
31
|
end
|
|
32
|
+
|
|
33
|
+
def on_nil_context
|
|
34
|
+
@on_nil_context ||= ->(_flag_name, _caller_location) {}
|
|
35
|
+
end
|
|
32
36
|
end
|
|
33
37
|
end
|
data/lib/this_feature/version.rb
CHANGED
data/lib/this_feature.rb
CHANGED
|
@@ -5,7 +5,20 @@ require 'this_feature/configuration'
|
|
|
5
5
|
require 'this_feature/flag'
|
|
6
6
|
|
|
7
7
|
class ThisFeature
|
|
8
|
-
|
|
8
|
+
OMITTED_CONTEXT = Object.new.freeze
|
|
9
|
+
private_constant :OMITTED_CONTEXT
|
|
10
|
+
|
|
11
|
+
def self.flag(flag_name, context: OMITTED_CONTEXT, data: {}, record: nil)
|
|
12
|
+
if context.nil?
|
|
13
|
+
begin
|
|
14
|
+
configuration.on_nil_context.call(flag_name, caller_locations(1, 1)&.first)
|
|
15
|
+
rescue StandardError => e
|
|
16
|
+
warn("ThisFeature on_nil_context callback failed: #{e.class}: #{e.message}")
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
# OMITTED_CONTEXT used to distinguish omission from passing nil; restore nil for the rest of the gem.
|
|
20
|
+
context = nil if context.equal?(OMITTED_CONTEXT)
|
|
21
|
+
|
|
9
22
|
adapter = adapter_for(flag_name)
|
|
10
23
|
|
|
11
24
|
Flag.new(flag_name, adapter: adapter, context: context, data: data, record: record)
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: this_feature
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.11.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Max Pleaner
|
|
@@ -11,7 +11,7 @@ authors:
|
|
|
11
11
|
autorequire:
|
|
12
12
|
bindir: exe
|
|
13
13
|
cert_chain: []
|
|
14
|
-
date:
|
|
14
|
+
date: 2026-05-05 00:00:00.000000000 Z
|
|
15
15
|
dependencies: []
|
|
16
16
|
description: ''
|
|
17
17
|
email:
|
|
@@ -23,6 +23,7 @@ executables: []
|
|
|
23
23
|
extensions: []
|
|
24
24
|
extra_rdoc_files: []
|
|
25
25
|
files:
|
|
26
|
+
- ".github/dependabot.yml"
|
|
26
27
|
- ".github/workflows/linter-rubocop.yml"
|
|
27
28
|
- ".github/workflows/test.yml"
|
|
28
29
|
- ".gitignore"
|