rollout 2.4.1 → 2.4.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: be3151ff1e21e7693a5b5be187e4db45cf4eb5d3
4
- data.tar.gz: 4bf397113ea44c2a522b4929c2030ca1aa756fab
3
+ metadata.gz: ae73aef78e5898a7936f6853788580ace070953f
4
+ data.tar.gz: 216f839eb30e2dbd26b33c5a5f224c285e73dc66
5
5
  SHA512:
6
- metadata.gz: 579ebe41258df73bf78477cba47da1529302c560e246f03a1bf4c652e93518a1de7e7053ec9665f3eefc94f04e21015b48a568dbdd1951d44ce23775aa967673
7
- data.tar.gz: 34fee387845b0cd8df9f1f593d900b8bb22de23acc2aee4777e99672a5caac1c78122ca020f032453e786d607bb7d905e65dbf807cbb8b796beafabba98fa6c2
6
+ metadata.gz: 6da7d61689d2048e82ef624ac93bc38abf9b141fc53e1787bafcd937d84eccf663ad54141040eeabaaeab5580700600fbc5b8b1bc5a319447ce53fbb1c7a12b9
7
+ data.tar.gz: 8c2d609455ea50da07b7229736db71e83856c4701d1b8c296472f4e6fb3583e748257a04840599a9a833114bcc9e9443f85172a0bbfdb15212beb8079aa8e629
@@ -1,42 +1,42 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rollout (2.4.0)
4
+ rollout (2.4.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
- appraisal (2.1.0)
9
+ appraisal (2.2.0)
10
10
  bundler
11
11
  rake
12
12
  thor (>= 0.14.0)
13
- codeclimate-test-reporter (1.0.5)
14
- simplecov
13
+ codeclimate-test-reporter (1.0.8)
14
+ simplecov (<= 0.13)
15
15
  diff-lcs (1.3)
16
16
  docile (1.1.5)
17
17
  fakeredis (0.6.0)
18
18
  redis (~> 3.2)
19
- json (2.0.3)
19
+ json (2.1.0)
20
20
  rake (12.0.0)
21
21
  redis (3.3.3)
22
- rspec (3.5.0)
23
- rspec-core (~> 3.5.0)
24
- rspec-expectations (~> 3.5.0)
25
- rspec-mocks (~> 3.5.0)
26
- rspec-core (3.5.4)
27
- rspec-support (~> 3.5.0)
28
- rspec-expectations (3.5.0)
22
+ rspec (3.6.0)
23
+ rspec-core (~> 3.6.0)
24
+ rspec-expectations (~> 3.6.0)
25
+ rspec-mocks (~> 3.6.0)
26
+ rspec-core (3.6.0)
27
+ rspec-support (~> 3.6.0)
28
+ rspec-expectations (3.6.0)
29
29
  diff-lcs (>= 1.2.0, < 2.0)
30
- rspec-support (~> 3.5.0)
31
- rspec-mocks (3.5.0)
30
+ rspec-support (~> 3.6.0)
31
+ rspec-mocks (3.6.0)
32
32
  diff-lcs (>= 1.2.0, < 2.0)
33
- rspec-support (~> 3.5.0)
34
- rspec-support (3.5.0)
33
+ rspec-support (~> 3.6.0)
34
+ rspec-support (3.6.0)
35
35
  simplecov (0.13.0)
36
36
  docile (~> 1.1.0)
37
37
  json (>= 1.8, < 3)
38
38
  simplecov-html (~> 0.10.0)
39
- simplecov-html (0.10.0)
39
+ simplecov-html (0.10.1)
40
40
  thor (0.19.4)
41
41
 
42
42
  PLATFORMS
@@ -53,4 +53,4 @@ DEPENDENCIES
53
53
  simplecov
54
54
 
55
55
  BUNDLED WITH
56
- 1.12.5
56
+ 1.15.1
@@ -4,6 +4,8 @@ require "set"
4
4
  require "json"
5
5
 
6
6
  class Rollout
7
+ RAND_BASE = (2**32 - 1) / 100.0
8
+
7
9
  class Feature
8
10
  attr_accessor :groups, :users, :percentage, :data
9
11
  attr_reader :name, :options
@@ -88,7 +90,7 @@ class Rollout
88
90
  end
89
91
 
90
92
  def user_in_percentage?(user)
91
- Zlib.crc32(user_id_for_percentage(user)) % 100_000 < @percentage * 1_000
93
+ Zlib.crc32(user_id_for_percentage(user)) < RAND_BASE * @percentage
92
94
  end
93
95
 
94
96
  def user_id_for_percentage(user)
@@ -283,6 +285,10 @@ class Rollout
283
285
  @storage.del(features_key)
284
286
  end
285
287
 
288
+ def exists?(feature)
289
+ @storage.exists(key(feature))
290
+ end
291
+
286
292
  private
287
293
 
288
294
  def key(name)
@@ -1,3 +1,3 @@
1
1
  class Rollout
2
- VERSION = "2.4.1"
2
+ VERSION = "2.4.2"
3
3
  end
@@ -646,6 +646,17 @@ RSpec.describe "Rollout" do
646
646
  expect(@rollout.get(:chat).data).to eq({})
647
647
  end
648
648
  end
649
+
650
+ describe 'Check if feature exists' do
651
+ it 'it should return true if the feature is exist' do
652
+ @rollout.activate_percentage(:chat, 1)
653
+ expect(@rollout.exists?(:chat)).to be true
654
+ end
655
+
656
+ it 'it should return false if the feature is not exist' do
657
+ expect(@rollout.exists?(:chat)).to be false
658
+ end
659
+ end
649
660
  end
650
661
 
651
662
  describe "Rollout::Feature" do
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.1
4
+ version: 2.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Golick
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-08 00:00:00.000000000 Z
11
+ date: 2017-06-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -152,7 +152,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
152
152
  version: '0'
153
153
  requirements: []
154
154
  rubyforge_project:
155
- rubygems_version: 2.6.10
155
+ rubygems_version: 2.6.12
156
156
  signing_key:
157
157
  specification_version: 4
158
158
  summary: Feature flippers with redis.