simple_feature_flags 1.3.0 → 1.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a84d6f21fb85142181cf9396572ffb07ba4cb6d1573064c3ea984ab339371ddc
4
- data.tar.gz: ca84facde85a613ceb6ecd54a88139a5ff9996838d8463d607e2e8ef93a1ce8e
3
+ metadata.gz: 4ec2b8373585148b5a35440da4b652b80939c9a206e8fcd9a77d352d4c73a291
4
+ data.tar.gz: 62ee0f5e72b494c7d9e8af4edace2d46bc7345bcc1dc7988e4f576b0b7d16e8a
5
5
  SHA512:
6
- metadata.gz: f74fb3b884d0523845038311ce962c5d41e24715f78f7580d1e45889c74eba9df1acd02ce37a6d6ac4e51208fb1d0b6dca0d76a097d90ebf8b367dbb46296996
7
- data.tar.gz: e554a51da1a596189a62857ac4a4bf18ffac37578fece7680f5455222380763e4d1c55a952107b262955533cdfac8ebc7a0211f2c2378dad49d8768c7170da23
6
+ metadata.gz: fa1df864803d24acba2331e3dc1d8da16dca764c3d321208f712cc9d34291be9f1742ec200d7ab4f4e87b7a0e2d035a79573189319b34867053c98332c1b1df0
7
+ data.tar.gz: 92400c60aef05bf3ad039123dd830af4e3b0c00a34e01d7d8ef72b905f67dc7fa0fd8e30b215c563a656a7ac545b0df0be0ea59233c3d6d3373677a72f5ae7d0
@@ -31,7 +31,7 @@ jobs:
31
31
  REDIS_PORT: 6379
32
32
  strategy:
33
33
  matrix:
34
- ruby-version: ['3.1', '3.2', '3.3']
34
+ ruby-version: ['3.2', '3.3', '3.4']
35
35
  steps:
36
36
  - name: Checkout code
37
37
  uses: actions/checkout@v3
data/.rubocop.yml CHANGED
@@ -24,8 +24,11 @@ Sorbet/ForbidTUnsafe:
24
24
  Naming/BlockForwarding:
25
25
  Enabled: false
26
26
 
27
+ Sorbet/ForbidSig:
28
+ Enabled: false
29
+
27
30
  AllCops:
28
- TargetRubyVersion: 3.1.0
31
+ TargetRubyVersion: 3.2.0
29
32
  EnabledByDefault: true
30
33
  Exclude:
31
34
  - 'bin/*'
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 3.3.6
1
+ 3.4.3
data/Gemfile CHANGED
@@ -10,7 +10,7 @@ gem 'minitest', '~> 5.0' # test library
10
10
  gem 'rake', '~> 13.0' # automation tasks
11
11
  gem 'redis', '~> 5.3' # redis client
12
12
  gem 'redis-namespace', '~> 1.11' # namespaces for redis
13
- gem 'rubocop-espago', '~> 1.0' # ruby linter
14
- gem 'rubocop-sorbet', '~> 0.8' # rubocop for sorbet
13
+ gem 'rubocop-espago', '~> 1.1' # ruby linter
14
+ gem 'rubocop-sorbet', '~> 0.10' # rubocop for sorbet
15
15
  gem 'sorbet', '>= 0.5' # static typechecker
16
16
  gem 'tapioca', '> 0.13' # RBI generator for sorbet
data/Gemfile.lock CHANGED
@@ -1,22 +1,23 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- simple_feature_flags (1.3.0)
4
+ simple_feature_flags (1.4.0)
5
5
  sorbet-runtime (> 0.5)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- ast (2.4.2)
10
+ ast (2.4.3)
11
11
  byebug (11.1.3)
12
12
  connection_pool (2.4.1)
13
13
  erubi (1.13.0)
14
- json (2.8.2)
15
- language_server-protocol (3.17.0.3)
14
+ json (2.10.2)
15
+ language_server-protocol (3.17.0.4)
16
+ lint_roller (1.1.0)
16
17
  minitest (5.25.1)
17
18
  netrc (0.11.0)
18
- parallel (1.26.3)
19
- parser (3.3.6.0)
19
+ parallel (1.27.0)
20
+ parser (3.3.8.0)
20
21
  ast (~> 2.4.1)
21
22
  racc
22
23
  prism (1.2.0)
@@ -32,22 +33,23 @@ GEM
32
33
  connection_pool
33
34
  redis-namespace (1.11.0)
34
35
  redis (>= 4)
35
- regexp_parser (2.9.2)
36
- rubocop (1.68.0)
36
+ regexp_parser (2.10.0)
37
+ rubocop (1.74.0)
37
38
  json (~> 2.3)
38
- language_server-protocol (>= 3.17.0)
39
+ language_server-protocol (~> 3.17.0.2)
40
+ lint_roller (~> 1.1.0)
39
41
  parallel (~> 1.10)
40
42
  parser (>= 3.3.0.2)
41
43
  rainbow (>= 2.2.2, < 4.0)
42
- regexp_parser (>= 2.4, < 3.0)
43
- rubocop-ast (>= 1.32.2, < 2.0)
44
+ regexp_parser (>= 2.9.3, < 3.0)
45
+ rubocop-ast (>= 1.38.0, < 2.0)
44
46
  ruby-progressbar (~> 1.7)
45
- unicode-display_width (>= 2.4.0, < 3.0)
46
- rubocop-ast (1.36.1)
47
- parser (>= 3.3.1.0)
48
- rubocop-espago (1.1.5)
47
+ unicode-display_width (>= 2.4.0, < 4.0)
48
+ rubocop-ast (1.42.0)
49
+ parser (>= 3.3.7.2)
50
+ rubocop-espago (1.1.8)
49
51
  rubocop
50
- rubocop-sorbet (0.8.7)
52
+ rubocop-sorbet (0.10.0)
51
53
  rubocop (>= 1)
52
54
  ruby-progressbar (1.13.0)
53
55
  sorbet (0.5.11647)
@@ -74,7 +76,9 @@ GEM
74
76
  thor (>= 1.2.0)
75
77
  yard-sorbet
76
78
  thor (1.3.2)
77
- unicode-display_width (2.6.0)
79
+ unicode-display_width (3.1.4)
80
+ unicode-emoji (~> 4.0, >= 4.0.4)
81
+ unicode-emoji (4.0.4)
78
82
  yard (0.9.37)
79
83
  yard-sorbet (0.9.0)
80
84
  sorbet-runtime
@@ -91,11 +95,11 @@ DEPENDENCIES
91
95
  rake (~> 13.0)
92
96
  redis (~> 5.3)
93
97
  redis-namespace (~> 1.11)
94
- rubocop-espago (~> 1.0)
95
- rubocop-sorbet (~> 0.8)
98
+ rubocop-espago (~> 1.1)
99
+ rubocop-sorbet (~> 0.10)
96
100
  simple_feature_flags!
97
101
  sorbet (>= 0.5)
98
102
  tapioca (> 0.13)
99
103
 
100
104
  BUNDLED WITH
101
- 2.5.22
105
+ 2.6.8
@@ -166,14 +166,50 @@ module SimpleFeatureFlags
166
166
  sig { abstract.params(feature: T.any(Symbol, String)).returns(T::Boolean) }
167
167
  def activate(feature); end
168
168
 
169
+ # Activates the flag, calls the block and restores the previous state of the flag.
170
+ sig do
171
+ abstract
172
+ .type_parameters(:R)
173
+ .params(
174
+ feature: T.any(Symbol, String),
175
+ block: T.proc.returns(T.type_parameter(:R)),
176
+ )
177
+ .returns(T.type_parameter(:R))
178
+ end
179
+ def do_activate(feature, &block); end
180
+
169
181
  # Activates the given flag globally. Returns `false` if it does not exist.
170
182
  sig { abstract.params(feature: T.any(Symbol, String)).returns(T::Boolean) }
171
183
  def activate_globally(feature); end
172
184
 
185
+ # Activates the flag globally, calls the block and restores the previous state of the flag.
186
+ sig do
187
+ abstract
188
+ .type_parameters(:R)
189
+ .params(
190
+ feature: T.any(Symbol, String),
191
+ block: T.proc.returns(T.type_parameter(:R)),
192
+ )
193
+ .returns(T.type_parameter(:R))
194
+ end
195
+ def do_activate_globally(feature, &block); end
196
+
173
197
  # Activates the given flag partially. Returns `false` if it does not exist.
174
198
  sig { abstract.params(feature: T.any(Symbol, String)).returns(T::Boolean) }
175
199
  def activate_partially(feature); end
176
200
 
201
+ # Activates the flag partially, calls the block and restores the previous state of the flag.
202
+ sig do
203
+ abstract
204
+ .type_parameters(:R)
205
+ .params(
206
+ feature: T.any(Symbol, String),
207
+ block: T.proc.returns(T.type_parameter(:R)),
208
+ )
209
+ .returns(T.type_parameter(:R))
210
+ end
211
+ def do_activate_partially(feature, &block); end
212
+
177
213
  # Activates the given flag for the given objects. Returns `false` if it does not exist.
178
214
  sig do
179
215
  abstract
@@ -252,7 +288,7 @@ module SimpleFeatureFlags
252
288
  active: T.any(String, Symbol, T::Boolean, NilClass),
253
289
  ).returns(T.nilable(T::Hash[String, T.anything]))
254
290
  end
255
- def add(feature, description, active = 'false'); end
291
+ def add(feature, description = '', active = 'false'); end
256
292
 
257
293
  # Removes the given feature flag.
258
294
  # Returns its data or nil if it does not exist.
@@ -256,6 +256,26 @@ module SimpleFeatureFlags
256
256
 
257
257
  alias activate_globally activate
258
258
 
259
+ sig do
260
+ override
261
+ .type_parameters(:R)
262
+ .params(
263
+ feature: T.any(Symbol, String),
264
+ block: T.proc.returns(T.type_parameter(:R)),
265
+ )
266
+ .returns(T.type_parameter(:R))
267
+ end
268
+ def do_activate(feature, &block)
269
+ feature = feature.to_sym
270
+ prev_value = flags.dig(feature, 'active')
271
+ activate(feature)
272
+ block.call
273
+ ensure
274
+ T.unsafe(flags)[feature]['active'] = prev_value
275
+ end
276
+
277
+ alias do_activate_globally do_activate
278
+
259
279
  # Activates the given flag partially. Returns `false` if it does not exist.
260
280
  sig { override.params(feature: T.any(Symbol, String)).returns(T::Boolean) }
261
281
  def activate_partially(feature)
@@ -267,6 +287,24 @@ module SimpleFeatureFlags
267
287
  true
268
288
  end
269
289
 
290
+ sig do
291
+ override
292
+ .type_parameters(:R)
293
+ .params(
294
+ feature: T.any(Symbol, String),
295
+ block: T.proc.returns(T.type_parameter(:R)),
296
+ )
297
+ .returns(T.type_parameter(:R))
298
+ end
299
+ def do_activate_partially(feature, &block)
300
+ feature = feature.to_sym
301
+ prev_value = flags.dig(feature, 'active')
302
+ activate_partially(feature)
303
+ block.call
304
+ ensure
305
+ T.unsafe(flags)[feature]['active'] = prev_value
306
+ end
307
+
270
308
  # Activates the given flag for the given objects. Returns `false` if it does not exist.
271
309
  sig do
272
310
  override
@@ -407,7 +445,7 @@ module SimpleFeatureFlags
407
445
  active: T.any(String, Symbol, T::Boolean, NilClass),
408
446
  ).returns(T.nilable(T::Hash[String, T.anything]))
409
447
  end
410
- def add(feature, description, active = 'false')
448
+ def add(feature, description = '', active = 'false')
411
449
  return if exists?(feature)
412
450
 
413
451
  active = if ACTIVE_GLOBALLY.include?(active)
@@ -253,6 +253,26 @@ module SimpleFeatureFlags
253
253
  true
254
254
  end
255
255
 
256
+ sig do
257
+ override
258
+ .type_parameters(:R)
259
+ .params(
260
+ feature: T.any(Symbol, String),
261
+ block: T.proc.returns(T.type_parameter(:R)),
262
+ )
263
+ .returns(T.type_parameter(:R))
264
+ end
265
+ def do_activate(feature, &block)
266
+ feature = feature.to_s
267
+ prev_value = redis.hget(feature, 'active')
268
+ activate(feature)
269
+ block.call
270
+ ensure
271
+ redis.hset(feature, 'active', prev_value)
272
+ end
273
+
274
+ alias do_activate_globally do_activate
275
+
256
276
  alias activate_globally activate
257
277
 
258
278
  # Activates the given flag partially. Returns `false` if it does not exist.
@@ -265,6 +285,24 @@ module SimpleFeatureFlags
265
285
  true
266
286
  end
267
287
 
288
+ sig do
289
+ override
290
+ .type_parameters(:R)
291
+ .params(
292
+ feature: T.any(Symbol, String),
293
+ block: T.proc.returns(T.type_parameter(:R)),
294
+ )
295
+ .returns(T.type_parameter(:R))
296
+ end
297
+ def do_activate_partially(feature, &block)
298
+ feature = feature.to_s
299
+ prev_value = redis.hget(feature, 'active')
300
+ activate_partially(feature)
301
+ block.call
302
+ ensure
303
+ redis.hset(feature, 'active', prev_value)
304
+ end
305
+
268
306
  # Activates the given flag for the given objects. Returns `false` if it does not exist.
269
307
  sig do
270
308
  override
@@ -408,7 +446,7 @@ module SimpleFeatureFlags
408
446
  active: T.any(String, Symbol, T::Boolean, NilClass),
409
447
  ).returns(T.nilable(T::Hash[String, T.anything]))
410
448
  end
411
- def add(feature, description, active = 'false')
449
+ def add(feature, description = '', active = 'false')
412
450
  return if exists?(feature)
413
451
 
414
452
  active = if ACTIVE_GLOBALLY.include?(active)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SimpleFeatureFlags
4
- VERSION = '1.3.0'
4
+ VERSION = '1.4.0'
5
5
  end
@@ -2,7 +2,6 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require 'json'
5
- require 'set'
6
5
  require 'sorbet-runtime'
7
6
 
8
7
  Dir[File.expand_path('simple_feature_flags/*.rb', __dir__)].each { |file| require file }
@@ -12,13 +11,18 @@ module SimpleFeatureFlags
12
11
  extend T::Sig
13
12
 
14
13
  NOT_PRESENT = ::Object.new.freeze
15
- UI_GEM = T.let('simple_feature_flags-ui', String)
16
- UI_CLASS_NAME = T.let('::SimpleFeatureFlags::Ui', String)
17
- WEB_UI_CLASS_NAME = T.let('::SimpleFeatureFlags::Ui::Web', String)
18
-
19
- ACTIVE_GLOBALLY = T.let(::Set['globally', :globally, 'true', true].freeze,
20
- T::Set[T.any(String, Symbol, T::Boolean, NilClass)],)
21
- ACTIVE_PARTIALLY = T.let(::Set['partially', :partially].freeze, T::Set[T.any(String, Symbol, T::Boolean, NilClass)])
14
+ UI_GEM = 'simple_feature_flags-ui'
15
+ UI_CLASS_NAME = '::SimpleFeatureFlags::Ui'
16
+ WEB_UI_CLASS_NAME = '::SimpleFeatureFlags::Ui::Web'
17
+
18
+ ACTIVE_GLOBALLY = T.let(
19
+ ::Set['globally', :globally, 'true', true].freeze,
20
+ T::Set[T.any(String, Symbol, T::Boolean, NilClass)],
21
+ )
22
+ ACTIVE_PARTIALLY = T.let(
23
+ ::Set['partially', :partially].freeze,
24
+ T::Set[T.any(String, Symbol, T::Boolean, NilClass)],
25
+ )
22
26
 
23
27
  class NoSuchCommandError < StandardError; end
24
28
 
@@ -14,7 +14,7 @@ require_relative 'lib/simple_feature_flags/version'
14
14
  DESC
15
15
  spec.homepage = 'https://github.com/espago/simple_feature_flags'
16
16
  spec.license = 'MIT'
17
- spec.required_ruby_version = '>= 3.1.0'
17
+ spec.required_ruby_version = '>= 3.2.0'
18
18
 
19
19
  spec.metadata['homepage_uri'] = spec.homepage
20
20
  spec.metadata['source_code_uri'] = 'https://github.com/espago/simple_feature_flags'
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_feature_flags
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Espago
8
8
  - Mateusz Drewniak
9
- autorequire:
10
9
  bindir: exe
11
10
  cert_chain: []
12
- date: 2024-11-15 00:00:00.000000000 Z
11
+ date: 1980-01-02 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: sorbet-runtime
@@ -75,7 +74,6 @@ metadata:
75
74
  homepage_uri: https://github.com/espago/simple_feature_flags
76
75
  source_code_uri: https://github.com/espago/simple_feature_flags
77
76
  rubygems_mfa_required: 'true'
78
- post_install_message:
79
77
  rdoc_options: []
80
78
  require_paths:
81
79
  - lib
@@ -83,15 +81,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
83
81
  requirements:
84
82
  - - ">="
85
83
  - !ruby/object:Gem::Version
86
- version: 3.1.0
84
+ version: 3.2.0
87
85
  required_rubygems_version: !ruby/object:Gem::Requirement
88
86
  requirements:
89
87
  - - ">="
90
88
  - !ruby/object:Gem::Version
91
89
  version: '0'
92
90
  requirements: []
93
- rubygems_version: 3.5.22
94
- signing_key:
91
+ rubygems_version: 3.6.7
95
92
  specification_version: 4
96
93
  summary: Simple feature flag functionality for your Ruby/Rails/Sinatra app!
97
94
  test_files: []