rollout 2.2.4 → 2.3.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 +4 -4
- data/Gemfile.lock +2 -2
- data/lib/rollout.rb +2 -2
- data/lib/rollout/version.rb +1 -1
- data/spec/rollout_spec.rb +12 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f64f1c9012cf7fed3496317cec7542d606c1b7b7
|
4
|
+
data.tar.gz: af8ead4306e97cd5038a16cc88b495e4dc68c9ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6972dfe9065234da74ed4f260a8d73ca837828b83793fc7b12ea8327c45fc463af2ab89782ec79a0f8988a0fbcc7af7291e3c829452c8d373a27f72494ba7db7
|
7
|
+
data.tar.gz: e82e2f6c194edd80142e88b54419c4d466910438a3b92ee243e2edbd71ea546178b72fedc34749c9ca114851e862221f2009f23e8adedd2fa65213736fbda5b6
|
data/Gemfile.lock
CHANGED
data/lib/rollout.rb
CHANGED
@@ -13,7 +13,7 @@ class Rollout
|
|
13
13
|
|
14
14
|
if string
|
15
15
|
raw_percentage,raw_users,raw_groups = string.split("|")
|
16
|
-
@percentage = raw_percentage.
|
16
|
+
@percentage = raw_percentage.to_f
|
17
17
|
@users = (raw_users || "").split(",").map(&:to_s).to_set
|
18
18
|
@groups = (raw_groups || "").split(",").map(&:to_sym).to_set
|
19
19
|
else
|
@@ -85,7 +85,7 @@ class Rollout
|
|
85
85
|
end
|
86
86
|
|
87
87
|
def user_in_percentage?(user)
|
88
|
-
Zlib.crc32(user_id_for_percentage(user)) %
|
88
|
+
Zlib.crc32(user_id_for_percentage(user)) % 100_000 < @percentage * 1_000
|
89
89
|
end
|
90
90
|
|
91
91
|
def user_id_for_percentage(user)
|
data/lib/rollout/version.rb
CHANGED
data/spec/rollout_spec.rb
CHANGED
@@ -227,7 +227,7 @@ RSpec.describe "Rollout" do
|
|
227
227
|
end
|
228
228
|
|
229
229
|
it "activates the feature for that percentage of the users" do
|
230
|
-
expect((1..
|
230
|
+
expect((1..100).select { |id| @rollout.active?(:chat, double(id: id)) }.length).to be_within(2).of(20)
|
231
231
|
end
|
232
232
|
end
|
233
233
|
|
@@ -237,7 +237,7 @@ RSpec.describe "Rollout" do
|
|
237
237
|
end
|
238
238
|
|
239
239
|
it "activates the feature for that percentage of the users" do
|
240
|
-
expect((1..200).select { |id| @rollout.active?(:chat, double(id: id)) }.length).to be_within(
|
240
|
+
expect((1..200).select { |id| @rollout.active?(:chat, double(id: id)) }.length).to be_within(4).of(40)
|
241
241
|
end
|
242
242
|
end
|
243
243
|
|
@@ -251,6 +251,16 @@ RSpec.describe "Rollout" do
|
|
251
251
|
end
|
252
252
|
end
|
253
253
|
|
254
|
+
describe "activating a feature for a percentage of users" do
|
255
|
+
before do
|
256
|
+
@rollout.activate_percentage(:chat, 0.1)
|
257
|
+
end
|
258
|
+
|
259
|
+
it "activates the feature for that percentage of the users" do
|
260
|
+
expect((1..10_000).to_set.select { |id| @rollout.active?(:chat, double(id: id)) }.length).to be_within(2).of(10)
|
261
|
+
end
|
262
|
+
end
|
263
|
+
|
254
264
|
describe "activating a feature for a percentage of users" do
|
255
265
|
before do
|
256
266
|
@rollout.activate_percentage(:chat, 20)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rollout
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Golick
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-06-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|