rollout_percentage 0.1.1 → 0.1.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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.txt +21 -0
  3. data/lib/rollout_percentage.rb +29 -0
  4. metadata +6 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8e301153f0e958fa56bd17dd6ca76740a9a3a697764bc92ca345c47870c96386
4
- data.tar.gz: 9974a64a7b197524a99700ab64d4160c05409d87aad4c887109c5325378243ce
3
+ metadata.gz: 7a5aa73e3b1643e4fc62f733944c9b19fcac2af505c3560fa824713ed4f087e6
4
+ data.tar.gz: 865bf745ce7825be662a2e0d97d1b2b1d3eb03989fe88abf55d5f3cfadde711f
5
5
  SHA512:
6
- metadata.gz: f99af6adffbabbbdcdfb1e0ef35b1dc7e009128d51705354977912c55ac23651d90c2fbc1a48d18fe5cfac5bad448000730cb428157d79a0cc3ff8b419908f3a
7
- data.tar.gz: 14baa4910b83b6ff18f66a2e8054220beb57e5b677eea2b7bb8a60f3583450793d224686b0ff2fed8b85c98161a26ab8893877d92dd3a00d29dde53a531c8e66
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.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: 2020-11-15 00:00:00.000000000 Z
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.3.0
78
+ version: 2.6.0
77
79
  required_rubygems_version: !ruby/object:Gem::Requirement
78
80
  requirements:
79
81
  - - ">="