abstract_feature_branch 0.3.5 → 0.3.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +46 -4
- data/VERSION +1 -1
- data/abstract_feature_branch.gemspec +1 -1
- data/lib/ext/feature_branch.rb +1 -1
- 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: 6f1030acce2b8092fcf6ac90e233253b273d5e10
|
4
|
+
data.tar.gz: 91baad506146ddd0aa419062c30c8d3f7d8dae3e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c4a44fabd06d5945c799cc157b22019cc2522fcbe7aa86ff0174d83f0bba64eebdee6d539b28c2628c61b0d84343167ed6ff37f17877ad6241f750472ee5be7c
|
7
|
+
data.tar.gz: 54c63e4ea5f19b9900ec5b565f8c8100f033bdaa35a40640dd960d3809855f109b5eb8defd5bbe825122eeff18eda10bce03a82af32e0cf5bdb42372a81cbb3b
|
data/README.md
CHANGED
@@ -24,7 +24,7 @@ Setup
|
|
24
24
|
-----
|
25
25
|
|
26
26
|
1. Configure Rubygem
|
27
|
-
- Rails (~> 4.0.0 or ~> 3.0): Add the following to Gemfile <pre>gem 'abstract_feature_branch', '0.3.
|
27
|
+
- Rails (~> 4.0.0 or ~> 3.0): Add the following to Gemfile <pre>gem 'abstract_feature_branch', '0.3.6'</pre>
|
28
28
|
- Rails (~> 2.0): Add the following to config/environment.rb <pre>config.gem 'absract_feature_branch'</pre>
|
29
29
|
2. Generate config/features.yml in your Rails app directory by running <pre>rails g abstract_feature_branch:install</pre>
|
30
30
|
|
@@ -56,13 +56,19 @@ overridden as false (disabled) in production. This is a recommended practice.
|
|
56
56
|
Instructions
|
57
57
|
------------
|
58
58
|
|
59
|
-
-
|
59
|
+
- Declaratively feature branch logic to only run when feature1 is enabled:
|
60
60
|
|
61
|
+
multi-line logic:
|
61
62
|
> feature_branch :feature1 do
|
62
63
|
> # perform logic
|
63
64
|
> end
|
64
65
|
|
65
|
-
-
|
66
|
+
single-line logic:
|
67
|
+
> feature_branch(:feature1) { # perform logic }
|
68
|
+
|
69
|
+
Note that feature_branch returns nil and does not execute the block if the feature is disabled or non-existent.
|
70
|
+
|
71
|
+
- Declaratively feature branch two paths of logic, one that runs when feature1 is enabled and one that runs when it is disabled:
|
66
72
|
|
67
73
|
> feature_branch :feature1,
|
68
74
|
> :true => lambda {
|
@@ -72,7 +78,9 @@ Instructions
|
|
72
78
|
> # perform alternate logic
|
73
79
|
> }
|
74
80
|
|
75
|
-
|
81
|
+
Note that feature_branch executes the false branch if the feature is non-existent.
|
82
|
+
|
83
|
+
- Imperatively check if a feature is enabled or not:
|
76
84
|
|
77
85
|
> if feature_enabled?(:feature1)
|
78
86
|
> # perform logic
|
@@ -80,6 +88,8 @@ Instructions
|
|
80
88
|
> # perform alternate logic
|
81
89
|
> end
|
82
90
|
|
91
|
+
Note that feature_enabled? returns false if the feature is disabled and nil if the feature is non-existent (practically the same effect, but nil can sometimes be useful to detect if a feature is referenced).
|
92
|
+
|
83
93
|
Recommendations
|
84
94
|
---------------
|
85
95
|
|
@@ -107,6 +117,35 @@ simply switching off the URL route to them. Example:
|
|
107
117
|
> </h4>
|
108
118
|
> <% end %>
|
109
119
|
|
120
|
+
- In Rails 4, wrap newly added strong parameters in controllers for data security. Example:
|
121
|
+
|
122
|
+
> params.require(:project).permit(
|
123
|
+
> feature_branch(:project_gallery) {:exclude_display},
|
124
|
+
> :name,
|
125
|
+
> :description,
|
126
|
+
> :website
|
127
|
+
> )
|
128
|
+
|
129
|
+
- In Rails 4 and 3.1+ with the asset pipeline, wrap newly added CSS or JavaScript using .erb format. Example (renamed projects.css.scss to projects.css.scss.erb and wrapped CSS with an abstract feature branch block):
|
130
|
+
|
131
|
+
> <% feature_branch :project_gallery do %>
|
132
|
+
> .exclude_display {
|
133
|
+
> margin-left: auto;
|
134
|
+
> margin-right: auto;
|
135
|
+
> label {
|
136
|
+
> font-size: 1em;
|
137
|
+
> text-align: center;
|
138
|
+
> }
|
139
|
+
> height: 47px;
|
140
|
+
> }
|
141
|
+
> <% end %>
|
142
|
+
> label {
|
143
|
+
> font-size: 1.5em;
|
144
|
+
> margin-bottom: -15px;
|
145
|
+
> margin-top: 3px;
|
146
|
+
> display: inline;
|
147
|
+
> }
|
148
|
+
|
110
149
|
- Once a feature has been released and switched on in production, and it has worked well for a while,
|
111
150
|
it is recommended that its feature branching code is plucked out of the code base to simplify the code
|
112
151
|
for better maintenance as the need is not longer there for feature branching at that point.
|
@@ -114,6 +153,9 @@ for better maintenance as the need is not longer there for feature branching at
|
|
114
153
|
Release Notes
|
115
154
|
-------------
|
116
155
|
|
156
|
+
Version 0.3.6:
|
157
|
+
- Fixed feature_branch issue with invalid feature name, preventing block execution and returning nil instead
|
158
|
+
|
117
159
|
Version 0.3.5:
|
118
160
|
- Fixed issue with generator not allowing consuming client app to start Rails server successfully
|
119
161
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.6
|
data/lib/ext/feature_branch.rb
CHANGED
@@ -3,7 +3,7 @@ class Object
|
|
3
3
|
def self.feature_branch(feature_name, branches = {}, &feature_work)
|
4
4
|
branches[:true] ||= feature_work
|
5
5
|
branches[:false] ||= lambda {}
|
6
|
-
feature_status = AbstractFeatureBranch.features[Rails.env.to_s][feature_name.to_s].to_s.to_sym
|
6
|
+
feature_status = (AbstractFeatureBranch.features[Rails.env.to_s][feature_name.to_s] || false).to_s.to_sym
|
7
7
|
branches[feature_status].call
|
8
8
|
end
|
9
9
|
|