feature_cop 0.1.2 → 0.1.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 23e13c27a95eb98d2e6575e2496cf0508a97b38c
4
- data.tar.gz: ab18e2e7f822c9d0e4cf0f2be37c8eb01c27d704
3
+ metadata.gz: cfc3f020ac957af0592f60d8483b3290cbd45094
4
+ data.tar.gz: b1b3f3aced850ffe765d09a6466c931f313093e6
5
5
  SHA512:
6
- metadata.gz: 1592e693b61d3d0a65940150caddff431a68545d8198cc5bddbd7bd3fc16ad0b08a543acf09de237a42e143c6fdf154711faf7c69577cf10f8c5cf1c7306de2f
7
- data.tar.gz: 2f490d457210964d0b049b468781616a18d07255be97b54e32ba3abf80a17e54e6ad4c39e81262d6eeadaebc4398f2452a624a8a7508bdfc7ebc0f892a764cde
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 users
10
- 4. **sample30** - feature is enabled for rougly 30% of users
11
- 5. **sample50** - feature is enabled for rougly 50% of users
12
- 6. **all_except_blacklist** - feature is enabled for everyone except a specified list of customers. These customers could be enterprise clients that must be notified before enabling new features, etc.
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
- else
14
- absolute_path = ::File.expand_path(::File.join("config", 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
- !@blacklist.include?(identifier)
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
@@ -1,3 +1,3 @@
1
1
  module FeatureCop
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
@@ -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.2
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-04-30 00:00:00.000000000 Z
11
+ date: 2016-05-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport