flipper 0.20.2 → 0.20.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Changelog.md +6 -0
- data/lib/flipper/adapters/memory.rb +20 -94
- data/lib/flipper/version.rb +1 -1
- data/spec/flipper/adapters/memory_spec.rb +21 -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: 6fcb4dd7f20ac1164f7c3add8fc0bee2480926618b312dbb207375a9be171bf7
|
4
|
+
data.tar.gz: a81b1fb51952ab430d26ca52975dad38122643198b8ef1a874f8fe3c2cbaf0fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2bf630be6690b4570443cefd44ac81ab801522e5b1be35f2357c45fa85c7503f1feb99abd4e01749d0fef1b1c941d53f91f0fc97ab38994a0c453533a00f7183
|
7
|
+
data.tar.gz: 536bad899391a69ac8380933fe151a1ede241e0ffaa43992cc42367394ad7f0adf51d8434740e9db31cd4c1fdc61debd5d0a5c7188a4f21a71aee4a27d31f5ac
|
data/Changelog.md
CHANGED
@@ -20,58 +20,57 @@ module Flipper
|
|
20
20
|
|
21
21
|
# Public: The set of known features.
|
22
22
|
def features
|
23
|
-
|
23
|
+
@source.keys.to_set
|
24
24
|
end
|
25
25
|
|
26
26
|
# Public: Adds a feature to the set of known features.
|
27
27
|
def add(feature)
|
28
|
-
|
28
|
+
@source[feature.key] ||= default_config
|
29
29
|
true
|
30
30
|
end
|
31
31
|
|
32
32
|
# Public: Removes a feature from the set of known features and clears
|
33
33
|
# all the values for the feature.
|
34
34
|
def remove(feature)
|
35
|
-
|
36
|
-
clear(feature)
|
35
|
+
@source.delete(feature.key)
|
37
36
|
true
|
38
37
|
end
|
39
38
|
|
40
39
|
# Public: Clears all the gate values for a feature.
|
41
40
|
def clear(feature)
|
42
|
-
feature.
|
43
|
-
delete key(feature, gate)
|
44
|
-
end
|
41
|
+
@source[feature.key] = default_config
|
45
42
|
true
|
46
43
|
end
|
47
44
|
|
48
45
|
# Public
|
49
46
|
def get(feature)
|
50
|
-
|
47
|
+
@source[feature.key] || default_config
|
51
48
|
end
|
52
49
|
|
53
50
|
def get_multi(features)
|
54
|
-
|
51
|
+
result = {}
|
52
|
+
features.each do |feature|
|
53
|
+
result[feature.key] = @source[feature.key] || default_config
|
54
|
+
end
|
55
|
+
result
|
55
56
|
end
|
56
57
|
|
57
58
|
def get_all
|
58
|
-
|
59
|
-
Flipper::Feature.new(key, self)
|
60
|
-
end
|
61
|
-
|
62
|
-
read_many_features(features)
|
59
|
+
@source
|
63
60
|
end
|
64
61
|
|
65
62
|
# Public
|
66
63
|
def enable(feature, gate, thing)
|
64
|
+
@source[feature.key] ||= default_config
|
65
|
+
|
67
66
|
case gate.data_type
|
68
67
|
when :boolean
|
69
68
|
clear(feature)
|
70
|
-
|
69
|
+
@source[feature.key][gate.key] = thing.value.to_s
|
71
70
|
when :integer
|
72
|
-
|
71
|
+
@source[feature.key][gate.key] = thing.value.to_s
|
73
72
|
when :set
|
74
|
-
|
73
|
+
@source[feature.key][gate.key] << thing.value.to_s
|
75
74
|
else
|
76
75
|
raise "#{gate} is not supported by this adapter yet"
|
77
76
|
end
|
@@ -81,13 +80,15 @@ module Flipper
|
|
81
80
|
|
82
81
|
# Public
|
83
82
|
def disable(feature, gate, thing)
|
83
|
+
@source[feature.key] ||= default_config
|
84
|
+
|
84
85
|
case gate.data_type
|
85
86
|
when :boolean
|
86
87
|
clear(feature)
|
87
88
|
when :integer
|
88
|
-
|
89
|
+
@source[feature.key][gate.key] = thing.value.to_s
|
89
90
|
when :set
|
90
|
-
|
91
|
+
@source[feature.key][gate.key].delete thing.value.to_s
|
91
92
|
else
|
92
93
|
raise "#{gate} is not supported by this adapter yet"
|
93
94
|
end
|
@@ -103,81 +104,6 @@ module Flipper
|
|
103
104
|
]
|
104
105
|
"#<#{self.class.name}:#{object_id} #{attributes.join(', ')}>"
|
105
106
|
end
|
106
|
-
|
107
|
-
private
|
108
|
-
|
109
|
-
def read_feature_keys
|
110
|
-
set_members(FeaturesKey)
|
111
|
-
end
|
112
|
-
|
113
|
-
# Private
|
114
|
-
def key(feature, gate)
|
115
|
-
"feature/#{feature.key}/#{gate.key}"
|
116
|
-
end
|
117
|
-
|
118
|
-
def read_many_features(features)
|
119
|
-
result = {}
|
120
|
-
features.each do |feature|
|
121
|
-
result[feature.key] = read_feature(feature)
|
122
|
-
end
|
123
|
-
result
|
124
|
-
end
|
125
|
-
|
126
|
-
def read_feature(feature)
|
127
|
-
result = {}
|
128
|
-
|
129
|
-
feature.gates.each do |gate|
|
130
|
-
result[gate.key] =
|
131
|
-
case gate.data_type
|
132
|
-
when :boolean, :integer
|
133
|
-
read key(feature, gate)
|
134
|
-
when :set
|
135
|
-
set_members key(feature, gate)
|
136
|
-
else
|
137
|
-
raise "#{gate} is not supported by this adapter yet"
|
138
|
-
end
|
139
|
-
end
|
140
|
-
|
141
|
-
result
|
142
|
-
end
|
143
|
-
|
144
|
-
# Private
|
145
|
-
def read(key)
|
146
|
-
@source[key.to_s]
|
147
|
-
end
|
148
|
-
|
149
|
-
# Private
|
150
|
-
def write(key, value)
|
151
|
-
@source[key.to_s] = value.to_s
|
152
|
-
end
|
153
|
-
|
154
|
-
# Private
|
155
|
-
def delete(key)
|
156
|
-
@source.delete(key.to_s)
|
157
|
-
end
|
158
|
-
|
159
|
-
# Private
|
160
|
-
def set_add(key, value)
|
161
|
-
ensure_set_initialized(key)
|
162
|
-
@source[key.to_s].add(value.to_s)
|
163
|
-
end
|
164
|
-
|
165
|
-
# Private
|
166
|
-
def set_delete(key, value)
|
167
|
-
ensure_set_initialized(key)
|
168
|
-
@source[key.to_s].delete(value.to_s)
|
169
|
-
end
|
170
|
-
|
171
|
-
# Private
|
172
|
-
def set_members(key)
|
173
|
-
ensure_set_initialized(key)
|
174
|
-
@source[key.to_s]
|
175
|
-
end
|
176
|
-
|
177
|
-
# Private
|
178
|
-
def ensure_set_initialized(key)
|
179
|
-
@source[key.to_s] ||= Set.new
|
180
|
-
end
|
181
107
|
end
|
182
108
|
end
|
183
109
|
end
|
data/lib/flipper/version.rb
CHANGED
@@ -2,7 +2,27 @@ require 'helper'
|
|
2
2
|
require 'flipper/spec/shared_adapter_specs'
|
3
3
|
|
4
4
|
RSpec.describe Flipper::Adapters::Memory do
|
5
|
-
|
5
|
+
let(:source) { {} }
|
6
|
+
subject { described_class.new(source) }
|
6
7
|
|
7
8
|
it_should_behave_like 'a flipper adapter'
|
9
|
+
|
10
|
+
it "can initialize from big hash" do
|
11
|
+
flipper = Flipper.new(subject)
|
12
|
+
flipper.enable :subscriptions
|
13
|
+
flipper.disable :search
|
14
|
+
flipper.enable_percentage_of_actors :pro_deal, 20
|
15
|
+
flipper.enable_percentage_of_time :logging, 30
|
16
|
+
flipper.enable_actor :following, Flipper::Actor.new('1')
|
17
|
+
flipper.enable_actor :following, Flipper::Actor.new('3')
|
18
|
+
flipper.enable_group :following, Flipper::Types::Group.new(:staff)
|
19
|
+
|
20
|
+
expect(source).to eq({
|
21
|
+
"subscriptions" => subject.default_config.merge(boolean: "true"),
|
22
|
+
"search" => subject.default_config,
|
23
|
+
"logging" => subject.default_config.merge(:percentage_of_time => "30"),
|
24
|
+
"pro_deal" => subject.default_config.merge(:percentage_of_actors => "20"),
|
25
|
+
"following" => subject.default_config.merge(actors: Set["1", "3"], groups: Set["staff"]),
|
26
|
+
})
|
27
|
+
end
|
8
28
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flipper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.20.
|
4
|
+
version: 0.20.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Nunemaker
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-01-
|
11
|
+
date: 2021-01-10 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|