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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6f90532fb87a21090eb99cc8122997d0ce462b08
4
- data.tar.gz: 01ddaf927a04082461a1227fd34941f0b2b751cb
3
+ metadata.gz: 9e1f95a32775c436171633f817e7e76822c29286
4
+ data.tar.gz: 60e06e3dd10ed4ca78b65818ace9589589bd982d
5
5
  SHA512:
6
- metadata.gz: d4e7f3ec3d361dd151e489e865b84d1f0c31e23e139c0db122a8f41cbf05553f1020063bed47f3897f760a702bf54361a51d5c7e6cf1b53da6db7a1d52ae69a3
7
- data.tar.gz: 3fcd97b89c919e3491ae224bfca305b27d2073b97f92b273b9fb75ef6e87b45d67a3b82247f91133ce8e201d907f46aae3bdc988a2309c24e30ff34e01d65d3b
6
+ metadata.gz: a5813436e352897917ae79feab51cea416782fd8a5c8756702eb869db5c04fcb3a3d853c869972ee182639e4d26dd4717e6eab6802f3e028f1bf0b53cd48a93a
7
+ data.tar.gz: 9731ccc6a042b404048ef56ad720035421aa6f41a060c533de60632de81ef99ddbe50cf83e69cdab8c79a60c3fe6e236e98ffab84c28848db3d1640bae2f1ce5
data/.gitignore CHANGED
@@ -7,3 +7,5 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
+
11
+ *.gem
data/README.md CHANGED
@@ -1,6 +1,17 @@
1
1
  # FeatureCop
2
2
 
3
- Feature cop is a simple feature toggling system for Ruby. All features are configured in the ENV, following the guidelines of a [12-Factor App](http://12factor.net/config)
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
- Add features definitions to your ENV
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
@@ -1,3 +1,3 @@
1
1
  module FeatureCop
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -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
- else
14
- absolute_path = ::File.expand_path(::File.join("config", 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
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: feature_cop
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brett Allred