simple_feature_flags 1.1.1 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +74 -0
- data/.gitignore +1 -0
- data/.rubocop.yml +14 -60
- data/.ruby-version +1 -1
- data/.vscode/settings.json +5 -1
- data/Gemfile +11 -1
- data/Gemfile.lock +80 -68
- data/README.md +53 -2
- data/Rakefile +5 -5
- data/bin/tapioca +27 -0
- data/bin/test +8 -0
- data/lib/example_files/config/initializers/simple_feature_flags.rb +4 -3
- data/lib/simple_feature_flags/base_storage.rb +296 -0
- data/lib/simple_feature_flags/cli/command/generate.rb +33 -6
- data/lib/simple_feature_flags/cli/command.rb +3 -1
- data/lib/simple_feature_flags/cli/options.rb +19 -3
- data/lib/simple_feature_flags/cli/runner.rb +13 -5
- data/lib/simple_feature_flags/cli.rb +3 -1
- data/lib/simple_feature_flags/configuration.rb +6 -0
- data/lib/simple_feature_flags/ram_storage.rb +275 -61
- data/lib/simple_feature_flags/redis_storage.rb +265 -44
- data/lib/simple_feature_flags/test_ram_storage.rb +7 -1
- data/lib/simple_feature_flags/version.rb +1 -1
- data/lib/simple_feature_flags.rb +22 -9
- data/simple_feature_flags.gemspec +17 -22
- metadata +19 -125
- data/.travis.yml +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a84d6f21fb85142181cf9396572ffb07ba4cb6d1573064c3ea984ab339371ddc
|
4
|
+
data.tar.gz: ca84facde85a613ceb6ecd54a88139a5ff9996838d8463d607e2e8ef93a1ce8e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f74fb3b884d0523845038311ce962c5d41e24715f78f7580d1e45889c74eba9df1acd02ce37a6d6ac4e51208fb1d0b6dca0d76a097d90ebf8b367dbb46296996
|
7
|
+
data.tar.gz: e554a51da1a596189a62857ac4a4bf18ffac37578fece7680f5455222380763e4d1c55a952107b262955533cdfac8ebc7a0211f2c2378dad49d8768c7170da23
|
@@ -0,0 +1,74 @@
|
|
1
|
+
name: CI Ruby
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [ 'main', 'develop' ]
|
6
|
+
pull_request:
|
7
|
+
branches: [ 'main', 'develop' ]
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
test:
|
11
|
+
runs-on: ubuntu-latest
|
12
|
+
services:
|
13
|
+
# Label used to access the service container
|
14
|
+
redis:
|
15
|
+
# Docker Hub image
|
16
|
+
image: redis
|
17
|
+
# Set health checks to wait until redis has started
|
18
|
+
options: >-
|
19
|
+
--health-cmd "redis-cli ping"
|
20
|
+
--health-interval 10s
|
21
|
+
--health-timeout 5s
|
22
|
+
--health-retries 5
|
23
|
+
ports:
|
24
|
+
# Maps port 6379 on service container to the host
|
25
|
+
- 6379:6379
|
26
|
+
env:
|
27
|
+
CI: true
|
28
|
+
# The hostname used to communicate with the Redis service container
|
29
|
+
REDIS_HOST: localhost
|
30
|
+
# The default Redis port
|
31
|
+
REDIS_PORT: 6379
|
32
|
+
strategy:
|
33
|
+
matrix:
|
34
|
+
ruby-version: ['3.1', '3.2', '3.3']
|
35
|
+
steps:
|
36
|
+
- name: Checkout code
|
37
|
+
uses: actions/checkout@v3
|
38
|
+
- name: Install Ruby and gems
|
39
|
+
uses: ruby/setup-ruby@v1
|
40
|
+
with:
|
41
|
+
ruby-version: ${{ matrix.ruby-version }}
|
42
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
43
|
+
- name: Run unit tests
|
44
|
+
run: bundle exec rake test
|
45
|
+
|
46
|
+
lint:
|
47
|
+
runs-on: ubuntu-latest
|
48
|
+
env:
|
49
|
+
CI: true
|
50
|
+
steps:
|
51
|
+
- name: Checkout code
|
52
|
+
uses: actions/checkout@v3
|
53
|
+
- name: Install Ruby and gems
|
54
|
+
uses: ruby/setup-ruby@v1
|
55
|
+
with:
|
56
|
+
ruby-version: '3.3'
|
57
|
+
bundler-cache: true
|
58
|
+
- name: Lint Ruby files
|
59
|
+
run: bundle exec rubocop --parallel
|
60
|
+
|
61
|
+
typecheck:
|
62
|
+
runs-on: ubuntu-latest
|
63
|
+
env:
|
64
|
+
CI: true
|
65
|
+
steps:
|
66
|
+
- name: Checkout code
|
67
|
+
uses: actions/checkout@v3
|
68
|
+
- name: Install Ruby and gems
|
69
|
+
uses: ruby/setup-ruby@v1
|
70
|
+
with:
|
71
|
+
ruby-version: '3.3'
|
72
|
+
bundler-cache: true
|
73
|
+
- name: Typecheck Ruby files
|
74
|
+
run: bundle exec srb tc
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -1,78 +1,32 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
Style/SingleArgumentDig:
|
5
|
-
Enabled: false
|
6
|
-
|
7
|
-
Layout/LineLength:
|
8
|
-
Enabled: false
|
1
|
+
inherit_gem:
|
2
|
+
rubocop-espago: sorbet.yml
|
9
3
|
|
10
|
-
|
4
|
+
Metrics/MethodLength:
|
11
5
|
Enabled: false
|
12
6
|
|
13
|
-
|
14
|
-
Enabled: false
|
15
|
-
|
16
|
-
Style/MethodCallWithArgsParentheses:
|
17
|
-
Enabled: false
|
18
|
-
|
19
|
-
Style/ModuleFunction:
|
20
|
-
EnforcedStyle: 'extend_self'
|
21
|
-
|
22
|
-
Style/MissingElse:
|
7
|
+
Sorbet/RedundantExtendTSig:
|
23
8
|
Enabled: false
|
24
9
|
|
25
|
-
|
10
|
+
Sorbet/HasSigil:
|
26
11
|
Enabled: false
|
27
12
|
|
28
|
-
|
13
|
+
Metrics/ClassLength:
|
29
14
|
Enabled: false
|
30
15
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
Enabled: false
|
36
|
-
|
37
|
-
Style/FormatString:
|
38
|
-
Enabled: false
|
39
|
-
|
40
|
-
Style/DocumentationMethod:
|
41
|
-
Enabled: false
|
42
|
-
|
43
|
-
Style/Copyright:
|
44
|
-
Enabled: false
|
45
|
-
|
46
|
-
Style/StringHashKeys:
|
47
|
-
Enabled: false
|
48
|
-
|
49
|
-
Style/InlineComment:
|
50
|
-
Enabled: false
|
51
|
-
|
52
|
-
Layout/FirstHashElementLineBreak:
|
53
|
-
Enabled: false
|
54
|
-
|
55
|
-
Layout/FirstMethodArgumentLineBreak:
|
56
|
-
Enabled: false
|
57
|
-
|
58
|
-
Style/ConstantVisibility:
|
59
|
-
Enabled: false
|
60
|
-
|
61
|
-
Layout/FirstArrayElementLineBreak:
|
62
|
-
Enabled: false
|
63
|
-
|
64
|
-
Layout/MultilineMethodArgumentLineBreaks:
|
65
|
-
Enabled: false
|
16
|
+
Sorbet/EnforceSignatures:
|
17
|
+
Exclude:
|
18
|
+
- 'bin/*'
|
19
|
+
- 'test/**/*'
|
66
20
|
|
67
|
-
|
21
|
+
Sorbet/ForbidTUnsafe:
|
68
22
|
Enabled: false
|
69
23
|
|
70
|
-
|
24
|
+
Naming/BlockForwarding:
|
71
25
|
Enabled: false
|
72
26
|
|
73
27
|
AllCops:
|
28
|
+
TargetRubyVersion: 3.1.0
|
74
29
|
EnabledByDefault: true
|
75
30
|
Exclude:
|
76
31
|
- 'bin/*'
|
77
|
-
- '
|
78
|
-
- 'test/**/*'
|
32
|
+
- 'sorbet/**/*'
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
3.3.6
|
data/.vscode/settings.json
CHANGED
data/Gemfile
CHANGED
@@ -1,6 +1,16 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
source
|
3
|
+
source 'https://rubygems.org'
|
4
4
|
|
5
5
|
# Specify your gem's dependencies in simple_feature_flags.gemspec
|
6
6
|
gemspec
|
7
|
+
|
8
|
+
gem 'byebug', '~> 11.1' # debugger
|
9
|
+
gem 'minitest', '~> 5.0' # test library
|
10
|
+
gem 'rake', '~> 13.0' # automation tasks
|
11
|
+
gem 'redis', '~> 5.3' # redis client
|
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
|
15
|
+
gem 'sorbet', '>= 0.5' # static typechecker
|
16
|
+
gem 'tapioca', '> 0.13' # RBI generator for sorbet
|
data/Gemfile.lock
CHANGED
@@ -1,89 +1,101 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
simple_feature_flags (1.
|
4
|
+
simple_feature_flags (1.3.0)
|
5
|
+
sorbet-runtime (> 0.5)
|
5
6
|
|
6
7
|
GEM
|
7
8
|
remote: https://rubygems.org/
|
8
9
|
specs:
|
9
10
|
ast (2.4.2)
|
10
|
-
backport (1.2.0)
|
11
|
-
benchmark (0.1.1)
|
12
|
-
bundler-audit (0.8.0)
|
13
|
-
bundler (>= 1.2.0, < 3)
|
14
|
-
thor (~> 1.0)
|
15
11
|
byebug (11.1.3)
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
minitest (5.14.4)
|
25
|
-
nokogiri (1.12.3)
|
26
|
-
mini_portile2 (~> 2.6.1)
|
27
|
-
racc (~> 1.4)
|
28
|
-
parallel (1.20.1)
|
29
|
-
parser (3.0.2.0)
|
12
|
+
connection_pool (2.4.1)
|
13
|
+
erubi (1.13.0)
|
14
|
+
json (2.8.2)
|
15
|
+
language_server-protocol (3.17.0.3)
|
16
|
+
minitest (5.25.1)
|
17
|
+
netrc (0.11.0)
|
18
|
+
parallel (1.26.3)
|
19
|
+
parser (3.3.6.0)
|
30
20
|
ast (~> 2.4.1)
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
21
|
+
racc
|
22
|
+
prism (1.2.0)
|
23
|
+
racc (1.8.1)
|
24
|
+
rainbow (3.1.1)
|
25
|
+
rake (13.2.1)
|
26
|
+
rbi (0.2.1)
|
27
|
+
prism (~> 1.0)
|
28
|
+
sorbet-runtime (>= 0.5.9204)
|
29
|
+
redis (5.3.0)
|
30
|
+
redis-client (>= 0.22.0)
|
31
|
+
redis-client (0.22.2)
|
32
|
+
connection_pool
|
33
|
+
redis-namespace (1.11.0)
|
34
|
+
redis (>= 4)
|
35
|
+
regexp_parser (2.9.2)
|
36
|
+
rubocop (1.68.0)
|
37
|
+
json (~> 2.3)
|
38
|
+
language_server-protocol (>= 3.17.0)
|
42
39
|
parallel (~> 1.10)
|
43
|
-
parser (>= 3.
|
40
|
+
parser (>= 3.3.0.2)
|
44
41
|
rainbow (>= 2.2.2, < 4.0)
|
45
|
-
regexp_parser (>=
|
46
|
-
|
47
|
-
rubocop-ast (>= 1.9.1, < 2.0)
|
42
|
+
regexp_parser (>= 2.4, < 3.0)
|
43
|
+
rubocop-ast (>= 1.32.2, < 2.0)
|
48
44
|
ruby-progressbar (~> 1.7)
|
49
|
-
unicode-display_width (>=
|
50
|
-
rubocop-ast (1.
|
51
|
-
parser (>= 3.
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
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)
|
49
|
+
rubocop
|
50
|
+
rubocop-sorbet (0.8.7)
|
51
|
+
rubocop (>= 1)
|
52
|
+
ruby-progressbar (1.13.0)
|
53
|
+
sorbet (0.5.11647)
|
54
|
+
sorbet-static (= 0.5.11647)
|
55
|
+
sorbet-runtime (0.5.11647)
|
56
|
+
sorbet-static (0.5.11647-aarch64-linux)
|
57
|
+
sorbet-static (0.5.11647-universal-darwin)
|
58
|
+
sorbet-static (0.5.11647-x86_64-linux)
|
59
|
+
sorbet-static-and-runtime (0.5.11647)
|
60
|
+
sorbet (= 0.5.11647)
|
61
|
+
sorbet-runtime (= 0.5.11647)
|
62
|
+
spoom (1.5.0)
|
63
|
+
erubi (>= 1.10.0)
|
64
|
+
prism (>= 0.28.0)
|
65
|
+
sorbet-static-and-runtime (>= 0.5.10187)
|
66
|
+
thor (>= 0.19.2)
|
67
|
+
tapioca (0.16.4)
|
68
|
+
bundler (>= 2.2.25)
|
69
|
+
netrc (>= 0.11.0)
|
70
|
+
parallel (>= 1.21.0)
|
71
|
+
rbi (~> 0.2)
|
72
|
+
sorbet-static-and-runtime (>= 0.5.11087)
|
73
|
+
spoom (>= 1.2.0)
|
74
|
+
thor (>= 1.2.0)
|
75
|
+
yard-sorbet
|
76
|
+
thor (1.3.2)
|
77
|
+
unicode-display_width (2.6.0)
|
78
|
+
yard (0.9.37)
|
79
|
+
yard-sorbet (0.9.0)
|
80
|
+
sorbet-runtime
|
81
|
+
yard
|
72
82
|
|
73
83
|
PLATFORMS
|
74
|
-
|
84
|
+
aarch64-linux
|
85
|
+
universal-darwin
|
86
|
+
x86_64-linux
|
75
87
|
|
76
88
|
DEPENDENCIES
|
77
|
-
|
78
|
-
bundler-audit
|
79
|
-
byebug
|
89
|
+
byebug (~> 11.1)
|
80
90
|
minitest (~> 5.0)
|
81
|
-
rake (~>
|
82
|
-
redis
|
83
|
-
redis-namespace
|
84
|
-
rubocop
|
91
|
+
rake (~> 13.0)
|
92
|
+
redis (~> 5.3)
|
93
|
+
redis-namespace (~> 1.11)
|
94
|
+
rubocop-espago (~> 1.0)
|
95
|
+
rubocop-sorbet (~> 0.8)
|
85
96
|
simple_feature_flags!
|
86
|
-
|
97
|
+
sorbet (>= 0.5)
|
98
|
+
tapioca (> 0.13)
|
87
99
|
|
88
100
|
BUNDLED WITH
|
89
|
-
2.
|
101
|
+
2.5.22
|
data/README.md
CHANGED
@@ -136,11 +136,19 @@ FEATURE_FLAGS.active?(:feature_name) #=> false
|
|
136
136
|
FEATURE_FLAGS.active_globally?(:feature_name) #=> false
|
137
137
|
FEATURE_FLAGS.active_partially?(:feature_name) #=> false
|
138
138
|
|
139
|
+
FEATURE_FLAGS.inactive?(:feature_name) #=> true
|
140
|
+
FEATURE_FLAGS.inactive_globally?(:feature_name) #=> true
|
141
|
+
FEATURE_FLAGS.inactive_partially?(:feature_name) #=> true
|
142
|
+
|
139
143
|
FEATURE_FLAGS.activate(:feature_name) # or FEATURE_FLAGS.activate_globally(:feature_name)
|
140
144
|
|
141
145
|
FEATURE_FLAGS.active?(:feature_name) #=> true
|
142
146
|
FEATURE_FLAGS.active_globally?(:feature_name) #=> true
|
143
147
|
FEATURE_FLAGS.active_partially?(:feature_name) #=> false
|
148
|
+
|
149
|
+
FEATURE_FLAGS.inactive?(:feature_name) #=> false
|
150
|
+
FEATURE_FLAGS.inactive_globally?(:feature_name) #=> false
|
151
|
+
FEATURE_FLAGS.inactive_partially?(:feature_name) #=> true
|
144
152
|
```
|
145
153
|
|
146
154
|
#### Deactivate a feature
|
@@ -149,10 +157,12 @@ Deactivates a feature in the global scope
|
|
149
157
|
|
150
158
|
```ruby
|
151
159
|
FEATURE_FLAGS.active?(:feature_name) #=> true
|
160
|
+
FEATURE_FLAGS.inactive?(:feature_name) #=> false
|
152
161
|
|
153
162
|
FEATURE_FLAGS.deactivate(:feature_name)
|
154
163
|
|
155
164
|
FEATURE_FLAGS.active?(:feature_name) #=> false
|
165
|
+
FEATURE_FLAGS.inactive?(:feature_name) #=> true
|
156
166
|
```
|
157
167
|
|
158
168
|
#### Activate a feature for a particular record/object
|
@@ -162,11 +172,19 @@ FEATURE_FLAGS.active_partially?(:feature_name) #=> true
|
|
162
172
|
FEATURE_FLAGS.active_for?(:feature_name, User.first) #=> false
|
163
173
|
FEATURE_FLAGS.active_for?(:feature_name, User.last) #=> false
|
164
174
|
|
175
|
+
FEATURE_FLAGS.inactive_partially?(:feature_name) #=> false
|
176
|
+
FEATURE_FLAGS.inactive_for?(:feature_name, User.first) #=> true
|
177
|
+
FEATURE_FLAGS.inactive_for?(:feature_name, User.last) #=> true
|
178
|
+
|
165
179
|
FEATURE_FLAGS.activate_for(:feature_name, User.first) #=> true
|
166
180
|
|
167
181
|
FEATURE_FLAGS.active_partially?(:feature_name) #=> true
|
168
182
|
FEATURE_FLAGS.active_for?(:feature_name, User.first) #=> true
|
169
183
|
FEATURE_FLAGS.active_for?(:feature_name, User.last) #=> false
|
184
|
+
|
185
|
+
FEATURE_FLAGS.inactive_partially?(:feature_name) #=> false
|
186
|
+
FEATURE_FLAGS.inactive_for?(:feature_name, User.first) #=> false
|
187
|
+
FEATURE_FLAGS.inactive_for?(:feature_name, User.last) #=> true
|
170
188
|
```
|
171
189
|
|
172
190
|
Note that the flag itself has to be active `partially` for any record/object specific settings to work.
|
@@ -299,6 +317,10 @@ if FEATURE_FLAGS.active?(:feature_name)
|
|
299
317
|
number += 1
|
300
318
|
end
|
301
319
|
|
320
|
+
if FEATURE_FLAGS.inactive?(:feature_name)
|
321
|
+
number += 1
|
322
|
+
end
|
323
|
+
|
302
324
|
# or using a block
|
303
325
|
|
304
326
|
# this code will run only when the :feature_name flag is active (either partially or globally)
|
@@ -306,27 +328,52 @@ FEATURE_FLAGS.when_active(:feature_name) do
|
|
306
328
|
number += 1
|
307
329
|
end
|
308
330
|
|
331
|
+
# the opposite
|
332
|
+
FEATURE_FLAGS.when_inactive(:feature_name) do
|
333
|
+
number += 1
|
334
|
+
end
|
335
|
+
|
309
336
|
# this code will run only when the :feature_name flag is active globally
|
310
337
|
FEATURE_FLAGS.when_active_globally(:feature_name) do
|
311
338
|
number += 1
|
312
339
|
end
|
313
340
|
|
341
|
+
# the opposite
|
342
|
+
FEATURE_FLAGS.when_inactive_globally(:feature_name) do
|
343
|
+
number += 1
|
344
|
+
end
|
345
|
+
|
314
346
|
# this code will run only when the :feature_name flag is active partially (only for specific records/users)
|
315
347
|
FEATURE_FLAGS.when_active_partially(:feature_name) do
|
316
348
|
number += 1
|
317
349
|
end
|
318
350
|
|
319
|
-
#
|
351
|
+
# the opposite
|
352
|
+
FEATURE_FLAGS.when_inactive_partially(:feature_name) do
|
353
|
+
number += 1
|
354
|
+
end
|
355
|
+
|
356
|
+
# this code will run only if the :feature_name flag is active for the first User
|
320
357
|
FEATURE_FLAGS.when_active_for(:feature_name, User.first) do
|
321
358
|
number += 1
|
322
359
|
end
|
323
360
|
|
361
|
+
# the opposite
|
362
|
+
FEATURE_FLAGS.when_inactive_for(:feature_name, User.first) do
|
363
|
+
number += 1
|
364
|
+
end
|
365
|
+
|
324
366
|
# feature flags that don't exist will return false
|
325
367
|
FEATURE_FLAGS.active?(:non_existant) #=> false
|
368
|
+
FEATURE_FLAGS.inactive?(:non_existant) #=> true
|
326
369
|
|
327
370
|
if FEATURE_FLAGS.active_for?(:feature_name, User.first)
|
328
371
|
number += 1
|
329
372
|
end
|
373
|
+
|
374
|
+
if FEATURE_FLAGS.inactive_for?(:feature_name, User.first)
|
375
|
+
number += 1
|
376
|
+
end
|
330
377
|
```
|
331
378
|
|
332
379
|
#### Adding feature flags
|
@@ -340,7 +387,7 @@ FEATURE_FLAGS.add(:feature_name, 'Description')
|
|
340
387
|
FEATURE_FLAGS.active?(:feature_name) #=> false
|
341
388
|
FEATURE_FLAGS.active_partially?(:feature_name) #=> false
|
342
389
|
FEATURE_FLAGS.active_globally?(:feature_name) #=> false
|
343
|
-
FEATURE_FLAGS.active_for?(:
|
390
|
+
FEATURE_FLAGS.active_for?(:feature_name, User.first) #=> false
|
344
391
|
|
345
392
|
# add a new globally active flag
|
346
393
|
FEATURE_FLAGS.add(:active_feature, 'Description', :globally)
|
@@ -370,6 +417,10 @@ FEATURE_FLAGS.remove(:feature_name)
|
|
370
417
|
FEATURE_FLAGS.active?(:feature_name) #=> false
|
371
418
|
FEATURE_FLAGS.active_partially?(:feature_name) #=> false
|
372
419
|
FEATURE_FLAGS.active_globally?(:feature_name) #=> false
|
420
|
+
|
421
|
+
FEATURE_FLAGS.inactive?(:feature_name) #=> true
|
422
|
+
FEATURE_FLAGS.inactive_partially?(:feature_name) #=> true
|
423
|
+
FEATURE_FLAGS.inactive_globally?(:feature_name) #=> true
|
373
424
|
```
|
374
425
|
|
375
426
|
|
data/Rakefile
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require 'bundler/gem_tasks'
|
4
|
+
require 'rake/testtask'
|
5
5
|
|
6
6
|
Rake::TestTask.new(:test) do |t|
|
7
|
-
t.libs <<
|
8
|
-
t.libs <<
|
9
|
-
t.test_files = FileList[
|
7
|
+
t.libs << 'test'
|
8
|
+
t.libs << 'lib'
|
9
|
+
t.test_files = FileList['test/**/*_test.rb']
|
10
10
|
end
|
11
11
|
|
12
12
|
task default: :test
|
data/bin/tapioca
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'tapioca' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
|
12
|
+
|
13
|
+
bundle_binstub = File.expand_path("bundle", __dir__)
|
14
|
+
|
15
|
+
if File.file?(bundle_binstub)
|
16
|
+
if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
|
17
|
+
load(bundle_binstub)
|
18
|
+
else
|
19
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
20
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
require "rubygems"
|
25
|
+
require "bundler/setup"
|
26
|
+
|
27
|
+
load Gem.bin_path("tapioca", "tapioca")
|
data/bin/test
ADDED
@@ -1,13 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
# Redis has 16 DBs (0 to 15)
|
3
4
|
|
4
5
|
FEATURE_FLAGS = if ::Rails.env.test?
|
5
6
|
# Use RamStorage in tests to make them faster
|
6
|
-
::SimpleFeatureFlags::RamStorage.new("#{::Rails.root
|
7
|
+
::SimpleFeatureFlags::RamStorage.new("#{::Rails.root}/config/simple_feature_flags.yml")
|
7
8
|
else
|
8
|
-
redis = ::Redis.new(host: '127.0.0.1', port: 6379, db: 0)
|
9
|
+
redis = ::Redis.new(host: '127.0.0.1', port: 6379, db: 0) # rubocop:disable Style/IpAddresses
|
9
10
|
# We recommend using the `redis-namespace` gem to avoid key conflicts with Sidekiq or Resque
|
10
11
|
# redis = ::Redis::Namespace.new(:simple_feature_flags, redis: redis)
|
11
12
|
|
12
|
-
::SimpleFeatureFlags::RedisStorage.new(redis, "#{::Rails.root
|
13
|
+
::SimpleFeatureFlags::RedisStorage.new(redis, "#{::Rails.root}/config/simple_feature_flags.yml")
|
13
14
|
end
|