unleash 4.4.1 → 4.4.2
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/workflows/pull_request.yml +1 -0
- data/.rubocop.yml +1 -0
- data/README.md +16 -0
- data/lib/unleash/client.rb +11 -0
- data/lib/unleash/version.rb +1 -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: e8461b30f4a58518d73731731a7dfbc32041a5a017362319b9d8ba76d2cecb98
|
4
|
+
data.tar.gz: '06098a3f106f50b0ddad46e17bef57584918ecbefe88486009d95edbdb546550'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ec0644f3bd93de7f75b06e44c059d39ff3ed87af00ee7ca17d1ad3a3e444626f190c4e26863167b116eda85ce0c01196542f8167f4494052fdae9b3e3e09e15c
|
7
|
+
data.tar.gz: 11764caf8ccd33c757cbd282a5e5f3d6d6b9dc7b70c29c0e9e196b512be3c1baee10abb21279358e7c7001a91b3825d5c42661910695e74e9e1585e2003c9b58
|
data/.rubocop.yml
CHANGED
data/README.md
CHANGED
@@ -10,6 +10,7 @@ Leverage the [Unleash Server](https://github.com/Unleash/unleash) for powerful f
|
|
10
10
|
|
11
11
|
## Supported Ruby Interpreters
|
12
12
|
|
13
|
+
* MRI 3.2
|
13
14
|
* MRI 3.1
|
14
15
|
* MRI 3.0
|
15
16
|
* MRI 2.7
|
@@ -124,6 +125,12 @@ if @unleash.is_enabled?(feature_name, unleash_context)
|
|
124
125
|
else
|
125
126
|
puts " #{feature_name} is disabled according to unleash"
|
126
127
|
end
|
128
|
+
|
129
|
+
if @unleash.is_disabled?(feature_name, unleash_context)
|
130
|
+
puts " #{feature_name} is disabled according to unleash"
|
131
|
+
else
|
132
|
+
puts " #{feature_name} is enabled according to unleash"
|
133
|
+
end
|
127
134
|
```
|
128
135
|
|
129
136
|
## Usage in a Rails Application
|
@@ -303,6 +310,9 @@ Then wherever in your application that you need a feature toggle, you can use:
|
|
303
310
|
if UNLEASH.is_enabled? "AwesomeFeature", @unleash_context
|
304
311
|
puts "AwesomeFeature is enabled"
|
305
312
|
end
|
313
|
+
if UNLEASH.is_disabled? "AwesomeFeature", @unleash_context
|
314
|
+
puts "AwesomeFeature is disabled"
|
315
|
+
end
|
306
316
|
```
|
307
317
|
|
308
318
|
or if client is set in `Rails.configuration.unleash`:
|
@@ -311,6 +321,9 @@ or if client is set in `Rails.configuration.unleash`:
|
|
311
321
|
if Rails.configuration.unleash.is_enabled? "AwesomeFeature", @unleash_context
|
312
322
|
puts "AwesomeFeature is enabled"
|
313
323
|
end
|
324
|
+
if Rails.configuration.unleash.is_disabled? "AwesomeFeature", @unleash_context
|
325
|
+
puts "AwesomeFeature is enabled"
|
326
|
+
end
|
314
327
|
```
|
315
328
|
|
316
329
|
If the feature is not found in the server, it will by default return false.
|
@@ -444,6 +457,9 @@ Method Name | Description | Return Type |
|
|
444
457
|
`is_enabled?` | Check if feature toggle is to be enabled or not. | Boolean |
|
445
458
|
`enabled?` | Alias to the `is_enabled?` method. But more ruby idiomatic. | Boolean |
|
446
459
|
`if_enabled` | Run a code block, if a feature is enabled. | `yield` |
|
460
|
+
`is_disabled?` | Check if feature toggle is to be enabled or not. | Boolean |
|
461
|
+
`disabled?` | Alias to the `is_disabled?` method. But more ruby idiomatic. | Boolean |
|
462
|
+
`if_disabled` | Run a code block, if a feature is disabled. | `yield` |
|
447
463
|
`get_variant` | Get variant for a given feature | `Unleash::Variant` |
|
448
464
|
`shutdown` | Save metrics to disk, flush metrics to server, and then kill ToggleFetcher and MetricsReporter threads. A safe shutdown. Not really useful in long running applications, like web applications. | nil |
|
449
465
|
`shutdown!` | Kill ToggleFetcher and MetricsReporter threads immediately. | nil |
|
data/lib/unleash/client.rb
CHANGED
@@ -50,14 +50,25 @@ module Unleash
|
|
50
50
|
toggle.is_enabled?(context)
|
51
51
|
end
|
52
52
|
|
53
|
+
def is_disabled?(feature, context = nil, default_value_param = true, &fallback_blk)
|
54
|
+
!is_enabled?(feature, context, !default_value_param, &fallback_blk)
|
55
|
+
end
|
56
|
+
|
53
57
|
# enabled? is a more ruby idiomatic method name than is_enabled?
|
54
58
|
alias enabled? is_enabled?
|
59
|
+
# disabled? is a more ruby idiomatic method name than is_disabled?
|
60
|
+
alias disabled? is_disabled?
|
55
61
|
|
56
62
|
# execute a code block (passed as a parameter), if is_enabled? is true.
|
57
63
|
def if_enabled(feature, context = nil, default_value = false, &blk)
|
58
64
|
yield(blk) if is_enabled?(feature, context, default_value)
|
59
65
|
end
|
60
66
|
|
67
|
+
# execute a code block (passed as a parameter), if is_disabled? is true.
|
68
|
+
def if_disabled(feature, context = nil, default_value = true, &blk)
|
69
|
+
yield(blk) if is_disabled?(feature, context, default_value)
|
70
|
+
end
|
71
|
+
|
61
72
|
def get_variant(feature, context = Unleash::Context.new, fallback_variant = disabled_variant)
|
62
73
|
Unleash.logger.debug "Unleash::Client.get_variant for feature: #{feature} with context #{context}"
|
63
74
|
|
data/lib/unleash/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unleash
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.4.
|
4
|
+
version: 4.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Renato Arruda
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-01-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: murmurhash3
|