feature_cop 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/README.md +37 -2
- data/lib/feature_cop/version.rb +1 -1
- data/lib/feature_cop/whitelist.rb +4 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9e1f95a32775c436171633f817e7e76822c29286
|
4
|
+
data.tar.gz: 60e06e3dd10ed4ca78b65818ace9589589bd982d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a5813436e352897917ae79feab51cea416782fd8a5c8756702eb869db5c04fcb3a3d853c869972ee182639e4d26dd4717e6eab6802f3e028f1bf0b53cd48a93a
|
7
|
+
data.tar.gz: 9731ccc6a042b404048ef56ad720035421aa6f41a060c533de60632de81ef99ddbe50cf83e69cdab8c79a60c3fe6e236e98ffab84c28848db3d1640bae2f1ce5
|
data/README.md
CHANGED
@@ -1,6 +1,17 @@
|
|
1
1
|
# FeatureCop
|
2
2
|
|
3
|
-
|
3
|
+
FeatureCop is a simple feature toggling system for Ruby. It provides progressive roll out of features. A common (and my opinion, bad) practice is for developers to use branching as feature control. Feature Branching leads to humongous pull requests, messy merges, and long integrations. With continous integration and feature toggling everyone can make small, short lived branches off the mainline, continually merge code, and get code in production even when it isn't ready for launch.
|
4
|
+
|
5
|
+
The following roll out strategies is available:
|
6
|
+
|
7
|
+
1. **disabled** - during development, a feature can completely disabled so it isn't seen or executed.
|
8
|
+
2. **whitelist_only** - features can be turned on for specific users or groups. For example, QA users can be whitelisted, then a small group of customers, etc.
|
9
|
+
3. **sample10** - feature is enabled for roughly 10% of users
|
10
|
+
4. **sample25** - feature is enabled for rougly 25% of users
|
11
|
+
5. **sample50** - feature is enabled for rougly 50% of users
|
12
|
+
6. **all_except_blacklist** - feature is enabled for everyone except for a specified list of customers. These customers could be enterprise clients that must be notified before enabling new features, etc.
|
13
|
+
6. **enabled** - enabled for all customers. At this point it is recommended to remove the feature flag from the system as the roll out is complete.
|
14
|
+
|
4
15
|
|
5
16
|
## Installation
|
6
17
|
|
@@ -17,7 +28,7 @@ Or install it yourself as:
|
|
17
28
|
|
18
29
|
## Basic Usage - Ruby
|
19
30
|
|
20
|
-
|
31
|
+
Features are configured in your applications ENV per [12-Factor App](http://12factor.net/config) guidelines.
|
21
32
|
|
22
33
|
```
|
23
34
|
MY_COOL_FEATURE = enabled
|
@@ -39,6 +50,16 @@ else
|
|
39
50
|
end
|
40
51
|
```
|
41
52
|
|
53
|
+
You can also pass a string identifier to FeatureCop. Identifiers can be anything but are typicall a user_id or a group_id. Identifiers are used for the whitelist, sample10, sample25, sample50, and blacklist feature types.
|
54
|
+
|
55
|
+
```ruby
|
56
|
+
|
57
|
+
if FeatureCop.allows?(:my_cool_feature, "USERID_123")
|
58
|
+
# execute new feature code
|
59
|
+
else
|
60
|
+
# execute old feature code
|
61
|
+
end
|
62
|
+
```
|
42
63
|
|
43
64
|
## Basic Usage - Javascript
|
44
65
|
|
@@ -58,6 +79,20 @@ FeatureCop.to_json
|
|
58
79
|
|
59
80
|
```
|
60
81
|
|
82
|
+
You can pass an identifier to the to_json method and it will output the correct feature values for that identifier.
|
83
|
+
|
84
|
+
```
|
85
|
+
FeatureCop.to_json("USERID_1234")
|
86
|
+
#=>
|
87
|
+
{
|
88
|
+
|
89
|
+
"myCoolFeature" : true
|
90
|
+
"loginV1Feature" : false
|
91
|
+
"menubarV3Feature" : true
|
92
|
+
}
|
93
|
+
|
94
|
+
```
|
95
|
+
|
61
96
|
Because javascript patterns & frameworks vary wildly and change often, we have opted not to provide any furtuer javascript helpers. The easiset way to use FeatureCop in your client side is to get features into window.env, then you can use simple if statements to control features.
|
62
97
|
|
63
98
|
```javascript
|
data/lib/feature_cop/version.rb
CHANGED
@@ -8,13 +8,14 @@ module FeatureCop
|
|
8
8
|
module ClassMethods
|
9
9
|
|
10
10
|
def whitelist_from_yaml(file = "feature_cop_whitelist.yml")
|
11
|
+
|
11
12
|
if ::File.exists?(file)
|
12
13
|
absolute_path = file
|
13
|
-
|
14
|
-
absolute_path = ::File.
|
15
|
-
raise "#{file} not found!" unless ::File.exists?(absolute_path)
|
14
|
+
elsif defined?(Rails)
|
15
|
+
absolute_path = ::File.join(Rails.root, "config", file)
|
16
16
|
end
|
17
17
|
|
18
|
+
raise "#{file} not found!" unless ::File.exists?(absolute_path)
|
18
19
|
self.whitelist = ::YAML.load_file(absolute_path)[env]
|
19
20
|
end
|
20
21
|
|