feature_cop 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -4
- data/lib/feature_cop.rb +6 -0
- data/lib/feature_cop/blacklist.rb +8 -5
- data/lib/feature_cop/version.rb +1 -1
- data/lib/feature_cop/whitelist.rb +4 -1
- 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: cfc3f020ac957af0592f60d8483b3290cbd45094
|
4
|
+
data.tar.gz: b1b3f3aced850ffe765d09a6466c931f313093e6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c48cdd39b1fc6de45ccea25b9930eac1e2bc4853f735bc48f148c060d8f985d7c8e9309b5a8706571949183c6fc70192b2870f9bca7f12f7206ec55a81457f28
|
7
|
+
data.tar.gz: 351df11878016e0e80a96fdd491dee93bf0aabdf452c44ff2cdb7552189ddcf108da2f8b9fef796754474544029dc3724a74cc4b9bb58c0c5feb23d40367016a
|
data/README.md
CHANGED
@@ -6,10 +6,11 @@ The following roll out strategies is available:
|
|
6
6
|
|
7
7
|
1. **disabled** - during development, a feature can be completely disabled so it isn't seen or executed.
|
8
8
|
2. **whitelist_only** - features can be turned on for specific users or groups.
|
9
|
-
3. **sample10** - feature is enabled for roughly 10% of
|
10
|
-
4. **sample30** - feature is enabled for
|
11
|
-
5. **sample50** - feature is enabled for
|
12
|
-
|
9
|
+
3. **sample10** - feature is enabled for roughly 10% of ids (statistically this ranges from 7% - 13%), includes whitelisted ids and excludes blacklisted ids
|
10
|
+
4. **sample30** - feature is enabled for roughly 30% of ids (statistically this ranges from 24% - 36%), includes whitelisted ids and excludes blacklisted ids
|
11
|
+
5. **sample50** - feature is enabled for roughly 50% of ids (statistically this ranges from 44% - 56%), includes whitelisted ids and excludes blacklisted ids
|
12
|
+
|
13
|
+
6. **all_except_blacklist** - feature is enabled for everyone except a specified list of ids. These customers could be enterprise clients that must be notified before enabling new features, etc.
|
13
14
|
6. **enabled** - enabled for all customers. At this point it is recommended to remove the feature flag from the system since the roll out is complete.
|
14
15
|
|
15
16
|
|
data/lib/feature_cop.rb
CHANGED
@@ -41,14 +41,20 @@ module FeatureCop
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def self.sample10(identifier)
|
44
|
+
return true if whitelisted?(identifier)
|
45
|
+
return false if blacklisted?(identifier)
|
44
46
|
identifier.bytes.sum % 10 == 0
|
45
47
|
end
|
46
48
|
|
47
49
|
def self.sample30(identifier)
|
50
|
+
return true if whitelisted?(identifier)
|
51
|
+
return false if blacklisted?(identifier)
|
48
52
|
identifier.bytes.sum % 3 == 0
|
49
53
|
end
|
50
54
|
|
51
55
|
def self.sample50(identifier)
|
56
|
+
return true if whitelisted?(identifier)
|
57
|
+
return false if blacklisted?(identifier)
|
52
58
|
identifier.bytes.sum.odd?
|
53
59
|
end
|
54
60
|
|
@@ -10,20 +10,19 @@ module FeatureCop
|
|
10
10
|
def blacklist_from_yaml(file = "feature_cop_blacklist.yml")
|
11
11
|
if ::File.exists?(file)
|
12
12
|
absolute_path = file
|
13
|
-
|
14
|
-
absolute_path = ::File.
|
15
|
-
raise "#{file} not found!" unless ::File.exists?(absolute_path)
|
13
|
+
elsif defined?(Rails)
|
14
|
+
absolute_path = ::File.join(Rails.root, "config", file)
|
16
15
|
end
|
17
16
|
|
17
|
+
raise "#{file} not found!" unless ::File.exists?(absolute_path)
|
18
18
|
self.blacklist = ::YAML.load_file(absolute_path)[env]
|
19
19
|
end
|
20
20
|
|
21
21
|
def all_except_blacklist(identifier)
|
22
22
|
return true if @blacklist.nil?
|
23
|
-
|
23
|
+
!blacklisted?(identifier)
|
24
24
|
end
|
25
25
|
|
26
|
-
|
27
26
|
def blacklist
|
28
27
|
@blacklist
|
29
28
|
end
|
@@ -32,6 +31,10 @@ module FeatureCop
|
|
32
31
|
@blacklist = blacklist
|
33
32
|
end
|
34
33
|
|
34
|
+
def blacklisted?(identifier)
|
35
|
+
return false if @blacklist.nil?
|
36
|
+
@blacklist.include?(identifier)
|
37
|
+
end
|
35
38
|
end
|
36
39
|
end
|
37
40
|
end
|
data/lib/feature_cop/version.rb
CHANGED
@@ -8,7 +8,6 @@ module FeatureCop
|
|
8
8
|
module ClassMethods
|
9
9
|
|
10
10
|
def whitelist_from_yaml(file = "feature_cop_whitelist.yml")
|
11
|
-
|
12
11
|
if ::File.exists?(file)
|
13
12
|
absolute_path = file
|
14
13
|
elsif defined?(Rails)
|
@@ -28,6 +27,10 @@ module FeatureCop
|
|
28
27
|
end
|
29
28
|
|
30
29
|
def whitelist_only(identifier)
|
30
|
+
whitelisted?(identifier)
|
31
|
+
end
|
32
|
+
|
33
|
+
def whitelisted?(identifier)
|
31
34
|
return false if @whitelist.nil?
|
32
35
|
@whitelist.include?(identifier)
|
33
36
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: feature_cop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brett Allred
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-05-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|