featurehub-sdk 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -0
- data/CHANGELOG.md +3 -0
- data/Gemfile.lock +1 -1
- data/lib/feature_hub/sdk/context.rb +1 -1
- data/lib/feature_hub/sdk/impl/apply_features.rb +11 -7
- data/lib/feature_hub/sdk/version.rb +1 -1
- data/sig/feature_hub/featurehub.rbs +69 -15
- 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: c4621f1ab8e515ab8eec3b701bf3928d1eabfafbe21a955175729dfeb39ed31b
|
4
|
+
data.tar.gz: 3e57a7dc1e0e525e6da0dca8848d42fd09eea437a378162160b5e529422fa12c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 95899cd71c1c70756cddc97821c30173ef5381c0ba384d58e9be0b6c57664b59be85e4f748d55723677b84dfdda276df48526a8bb603165da911af1fc0344305
|
7
|
+
data.tar.gz: 8840b4aa7359fa5bbbc3247bac92df4fc96915c788737d08e3d4a0ccd92542536e05b527411875f17b4a5b94b7614f033303eaba93d349a88be200e010f8ccef
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.7.6
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -67,26 +67,30 @@ module FeatureHub
|
|
67
67
|
|
68
68
|
def match_attribute(context, rs_attr)
|
69
69
|
rs_attr.attributes.each do |attr|
|
70
|
-
|
71
|
-
if
|
70
|
+
supplied_values = context.get_attr(attr.field_name)
|
71
|
+
if supplied_values.empty? && attr.field_name.downcase == "now"
|
72
72
|
case attr.field_type
|
73
73
|
when "DATE"
|
74
|
-
|
74
|
+
supplied_values = [Time.new.utc.iso8601[0..9]]
|
75
75
|
when "DATETIME"
|
76
|
-
|
76
|
+
supplied_values = [Time.new.utc.iso8601]
|
77
77
|
end
|
78
78
|
end
|
79
79
|
|
80
|
-
if attr.values.nil? &&
|
80
|
+
if attr.values.nil? && supplied_values.empty?
|
81
81
|
return false unless attr.conditional.equals?
|
82
82
|
|
83
83
|
next
|
84
84
|
end
|
85
85
|
|
86
|
-
return false if attr.values.nil? ||
|
86
|
+
return false if attr.values.nil? || supplied_values.empty?
|
87
87
|
|
88
88
|
# this attribute has to match or we failed
|
89
|
-
|
89
|
+
match = supplied_values.any? do |supplied_value|
|
90
|
+
@matcher_repository.find_matcher(attr).match(supplied_value, attr)
|
91
|
+
end
|
92
|
+
|
93
|
+
return false unless match
|
90
94
|
end
|
91
95
|
|
92
96
|
true
|
@@ -1,6 +1,7 @@
|
|
1
1
|
module FeatureHub
|
2
2
|
module Sdk
|
3
3
|
VERSION: String
|
4
|
+
|
4
5
|
# See the writing guide of rbs: https://github.com/ruby/rbs#guides
|
5
6
|
#
|
6
7
|
|
@@ -11,13 +12,17 @@ module FeatureHub
|
|
11
12
|
feature_state: Hash[untyped, untyped]?, parent_state: FeatureState?, ctx: ClientContext?) -> void
|
12
13
|
|
13
14
|
def locked?: -> bool
|
15
|
+
|
14
16
|
def exists?: (top_feature: FeatureState?) -> bool
|
17
|
+
|
15
18
|
def id: -> String?
|
19
|
+
|
16
20
|
def feature_type: -> String?
|
17
21
|
|
18
22
|
def with_context: (ctx: ClientContext) -> FeatureState
|
19
23
|
|
20
24
|
def update_feature_state: (feature_state: Hash[untyped, untyped]) -> void
|
25
|
+
|
21
26
|
# this is the feature state of the top level, it always walks up
|
22
27
|
def feature_state: () -> Hash[untyped, untyped]
|
23
28
|
|
@@ -57,19 +62,20 @@ module FeatureHub
|
|
57
62
|
attr_reader matched: bool
|
58
63
|
attr_reader value: [bool? | String? | Float?]
|
59
64
|
|
60
|
-
def initialize:(matched: bool, value: [bool? | String? | Float?]) -> void
|
65
|
+
def initialize: (matched: bool, value: [bool? | String? | Float?]) -> void
|
61
66
|
end
|
62
67
|
|
63
68
|
class InterceptorValue
|
64
|
-
def initialize: (val: [bool? | String? | Float?
|
65
|
-
|
69
|
+
def initialize: (val: [bool? | String? | Float?]) -> void
|
70
|
+
|
71
|
+
def cast: (feature_type: String?) -> [bool? | String? | Float?]
|
66
72
|
end
|
67
73
|
|
68
74
|
class ValueInterceptor
|
69
75
|
def intercepted_value: (feature_key: Symbol) -> InterceptorValue?
|
70
76
|
end
|
71
77
|
|
72
|
-
class EnvironmentInterceptor <
|
78
|
+
class EnvironmentInterceptor < ValueInterceptor
|
73
79
|
end
|
74
80
|
|
75
81
|
class PercentageCalculator
|
@@ -78,17 +84,25 @@ module FeatureHub
|
|
78
84
|
|
79
85
|
class ApplyFeatures
|
80
86
|
def initialize: (percent_calculator: PercentageCalculator?, matcher_repository: MatcherRepository?) -> void
|
87
|
+
|
81
88
|
def apply: (strategies: Array[RolloutStrategy], key: String, feature_value_id: String, context: ClientContext) -> Applied
|
89
|
+
|
82
90
|
def match_attribute: (context: ClientContext, rs: RolloutStrategyAttribute) -> bool
|
91
|
+
|
83
92
|
def self.determine_percentage_key: (context: ClientContext, rsi: RolloutStrategy) -> String?
|
84
93
|
end
|
85
94
|
|
86
95
|
class InternalFeatureRepository
|
87
96
|
def feature: (key: String) -> FeatureState?
|
97
|
+
|
88
98
|
def find_interceptor: (feature_value: String) -> InterceptorValue?
|
99
|
+
|
89
100
|
def ready?: -> bool
|
101
|
+
|
90
102
|
def not_ready!: -> void
|
103
|
+
|
91
104
|
def apply: (strategies: Array[RolloutStrategy], key: String, feature_id: String, context: ClientContext) -> Applied
|
105
|
+
|
92
106
|
def notify: (status: String, data: Hash[untyped, untyped]) -> void
|
93
107
|
end
|
94
108
|
|
@@ -96,15 +110,20 @@ module FeatureHub
|
|
96
110
|
@features: Hash[String, FeatureState]
|
97
111
|
@ready: bool
|
98
112
|
|
99
|
-
def initialize: (apply_features: nil | ApplyFeatures
|
100
|
-
|
113
|
+
def initialize: (apply_features: nil | ApplyFeatures) -> void
|
114
|
+
|
115
|
+
def apply: (strategies: Array[RolloutStrategy], key: String, feature_id: String, context: ClientContext) -> Applied
|
101
116
|
|
102
117
|
def notify: (status: String, data: Hash[untyped, untyped]) -> void
|
118
|
+
|
103
119
|
def feature: (key: String) -> FeatureState
|
120
|
+
|
104
121
|
def register_interceptor: (interceptor: ValueInterceptor) -> void
|
105
122
|
|
106
123
|
def find_interceptor: (feature_value: String) -> InterceptorValue?
|
124
|
+
|
107
125
|
def ready?: -> bool
|
126
|
+
|
108
127
|
def not_ready!: -> void
|
109
128
|
|
110
129
|
def extract_feature_state: -> Array[Hash[untyped, untyped]]
|
@@ -114,37 +133,61 @@ module FeatureHub
|
|
114
133
|
attr_reader repo: InternalFeatureRepository
|
115
134
|
|
116
135
|
def initialize: (repository: InternalFeatureRepository) -> void
|
136
|
+
|
117
137
|
def user_key: (value: String) -> ClientContext
|
138
|
+
|
118
139
|
def session_key: (value: String) -> ClientContext
|
140
|
+
|
119
141
|
def version: (value: String) -> ClientContext
|
120
|
-
|
121
|
-
def
|
122
|
-
|
123
|
-
def
|
142
|
+
|
143
|
+
def country: (value: Symbol) -> ClientContext
|
144
|
+
|
145
|
+
def platform: (value: Symbol) -> ClientContext
|
146
|
+
|
147
|
+
def device: (value: Symbol) -> ClientContext
|
148
|
+
|
149
|
+
def attribute_value: (key: String, values: Array[String]) -> ClientContext
|
150
|
+
|
124
151
|
def clear: -> ClientContext
|
125
|
-
|
152
|
+
|
153
|
+
def get_attr: (key: String, default_val: String?) -> Array[String]
|
154
|
+
|
126
155
|
def default_percentage_key: -> String?
|
156
|
+
|
127
157
|
def enabled: (key: String) -> bool?
|
128
158
|
|
129
159
|
def feature: (key: String) -> FeatureState
|
160
|
+
|
130
161
|
def set?: (key: String) -> bool?
|
162
|
+
|
131
163
|
def number: (key: String) -> Float?
|
164
|
+
|
132
165
|
def string: (key: String) -> String?
|
166
|
+
|
133
167
|
def json: (key: String) -> Hash[untyped, untyped]?
|
168
|
+
|
134
169
|
def raw_json: (key: String) -> String?
|
170
|
+
|
135
171
|
def flag: (key: String) -> bool?
|
172
|
+
|
136
173
|
def boolean: (key: String) -> bool?
|
174
|
+
|
137
175
|
def exists?: (key: String) -> bool
|
138
176
|
|
139
177
|
def build: -> ClientContext
|
178
|
+
|
140
179
|
def build_sync: -> ClientContext
|
180
|
+
|
141
181
|
def close: -> ClientContext
|
142
182
|
end
|
143
183
|
|
144
184
|
class EdgeService
|
145
185
|
def initialize: (repository: InternalFeatureRepository, api_keys: Array[String], edge_url: String) -> void
|
186
|
+
|
146
187
|
def poll: -> void
|
188
|
+
|
147
189
|
def context_change: (new_header: String?) -> void
|
190
|
+
|
148
191
|
def close: -> void
|
149
192
|
end
|
150
193
|
|
@@ -189,15 +232,25 @@ module FeatureHub
|
|
189
232
|
|
190
233
|
class RolloutStrategyCondition
|
191
234
|
def equals?: -> bool
|
235
|
+
|
192
236
|
def ends_with?: -> bool
|
237
|
+
|
193
238
|
def starts_with?: -> bool
|
239
|
+
|
194
240
|
def greater?: -> bool
|
241
|
+
|
195
242
|
def greater_equals?: -> bool
|
243
|
+
|
196
244
|
def less?: -> bool
|
245
|
+
|
197
246
|
def less_equals?: -> bool
|
247
|
+
|
198
248
|
def not_equals?: -> bool
|
249
|
+
|
199
250
|
def includes?: -> bool
|
251
|
+
|
200
252
|
def excludes?: -> bool
|
253
|
+
|
201
254
|
def regex?: -> bool
|
202
255
|
end
|
203
256
|
|
@@ -209,6 +262,7 @@ module FeatureHub
|
|
209
262
|
attr_reader field_type: String
|
210
263
|
|
211
264
|
def float_values: -> Array[Float]
|
265
|
+
|
212
266
|
def str_values: -> Array[String]
|
213
267
|
end
|
214
268
|
|
@@ -221,15 +275,16 @@ module FeatureHub
|
|
221
275
|
attr_reader value: [bool? | String? | Float?]
|
222
276
|
|
223
277
|
def percentage_attributes?: -> bool
|
278
|
+
|
224
279
|
def attributes?: -> bool
|
225
280
|
end
|
226
281
|
|
227
282
|
class StrategyMatcher
|
228
|
-
def match: (supplied_value: String, attr: RolloutStrategyAttribute
|
283
|
+
def match: (supplied_value: String, attr: RolloutStrategyAttribute) -> bool
|
229
284
|
end
|
230
285
|
|
231
286
|
class BooleanMatcher < StrategyMatcher
|
232
|
-
def match: (supplied_value: String, attr: RolloutStrategyAttribute
|
287
|
+
def match: (supplied_value: String, attr: RolloutStrategyAttribute) -> bool
|
233
288
|
end
|
234
289
|
|
235
290
|
class StringMatcher < StrategyMatcher
|
@@ -250,7 +305,6 @@ module FeatureHub
|
|
250
305
|
|
251
306
|
class MatcherRegistry < MatcherRepository
|
252
307
|
end
|
253
|
-
end
|
308
|
+
end
|
254
309
|
|
255
310
|
end
|
256
|
-
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: featurehub-sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Vowles
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2022-
|
12
|
+
date: 2022-10-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: concurrent-ruby
|
@@ -90,6 +90,7 @@ extra_rdoc_files: []
|
|
90
90
|
files:
|
91
91
|
- ".rspec"
|
92
92
|
- ".rubocop.yml"
|
93
|
+
- ".ruby-version"
|
93
94
|
- CHANGELOG.md
|
94
95
|
- CODE_OF_CONDUCT.md
|
95
96
|
- Gemfile
|