rollout_percentage 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.txt +21 -0
- data/lib/rollout_percentage.rb +29 -0
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7a5aa73e3b1643e4fc62f733944c9b19fcac2af505c3560fa824713ed4f087e6
|
4
|
+
data.tar.gz: 865bf745ce7825be662a2e0d97d1b2b1d3eb03989fe88abf55d5f3cfadde711f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9fbd0da05336293c3dd501d67d2c391bd6a568d69f03ef996cc6dacbb0490920bbdd0a9c0f4d2132b74ded63f274d6f11260b1a56ac6cd1cb4c96a1cb5dd3f45
|
7
|
+
data.tar.gz: 684e562937a5350d244908dbf5cf6d8bb978487b1726417c94c2b72e0fa9387bf7b25bf67191d29c107d6b35e7dc344194e9a4458daddf8f2f276a4739546e84
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2020 Aleksey Strizhak
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
@@ -0,0 +1,29 @@
|
|
1
|
+
class RolloutPercentage
|
2
|
+
VERSION = '0.1.2'.freeze
|
3
|
+
|
4
|
+
def initialize(feature_flag:, rollout_client:)
|
5
|
+
self.feature_flag = feature_flag
|
6
|
+
self.rollout_client = rollout_client
|
7
|
+
end
|
8
|
+
|
9
|
+
def perform
|
10
|
+
if enabled?
|
11
|
+
block_given? ? yield : true
|
12
|
+
else
|
13
|
+
false
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
attr_accessor :feature_flag, :rollout_client
|
20
|
+
|
21
|
+
def enabled?
|
22
|
+
percentage = rollout_client.get(feature_flag)
|
23
|
+
percentage && random_number < percentage.to_i
|
24
|
+
end
|
25
|
+
|
26
|
+
def random_number
|
27
|
+
rand(100)
|
28
|
+
end
|
29
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rollout_percentage
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aleksey Strizhak
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-02-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: byebug
|
@@ -58,7 +58,9 @@ email:
|
|
58
58
|
executables: []
|
59
59
|
extensions: []
|
60
60
|
extra_rdoc_files: []
|
61
|
-
files:
|
61
|
+
files:
|
62
|
+
- LICENSE.txt
|
63
|
+
- lib/rollout_percentage.rb
|
62
64
|
homepage: https://github.com/Mifrill/rollout_percentage.git
|
63
65
|
licenses:
|
64
66
|
- MIT
|
@@ -73,7 +75,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
73
75
|
requirements:
|
74
76
|
- - ">="
|
75
77
|
- !ruby/object:Gem::Version
|
76
|
-
version: 2.
|
78
|
+
version: 2.6.0
|
77
79
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
80
|
requirements:
|
79
81
|
- - ">="
|