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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4c3d5ba3f2d87215c418e884e974eb2a8850899d
4
- data.tar.gz: cc27d0818364f12cc1fa88c4548cda823b752de4
3
+ metadata.gz: 6f1030acce2b8092fcf6ac90e233253b273d5e10
4
+ data.tar.gz: 91baad506146ddd0aa419062c30c8d3f7d8dae3e
5
5
  SHA512:
6
- metadata.gz: d18c7bc9cfb24c793078e81b50beea7549fb867714f2a55a2f7fd690a613a7004aa0839644b5c4c33f13fe778be9507d5c7539d685a29e30d3e3c9ae1a7b6e71
7
- data.tar.gz: 6f72bc02aae8b05d3d0751267648ca12b0f7b3bf275f1418149b216a683b0b0735ebc80b8253a93719ba254710deb41bd334ca3c23d4a93398d25eebfe2c1ea8
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.5'</pre>
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
- - declaratively feature branch logic to only run when feature1 is enabled:
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
- - declaratively feature branch two paths of logic, one that runs when feature1 is enabled and one that runs when it is disabled:
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
- - imperatively check if a feature is enabled or not:
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.5
1
+ 0.3.6
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "abstract_feature_branch"
8
- s.version = "0.3.5"
8
+ s.version = "0.3.6"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Annas \"Andy\" Maleh"]
@@ -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
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: abstract_feature_branch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.5
4
+ version: 0.3.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Annas "Andy" Maleh