abstract_feature_branch 0.9.0 → 1.0.0

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: c89fdfb59675ab1f3591c973daf0970ca1ad2c8f
4
- data.tar.gz: 9fdb542f2134917987b0b45be6d2a6db9510b49a
3
+ metadata.gz: a94572977e6efa72fc039c72a7674229b158a774
4
+ data.tar.gz: 4afc8329e8a7122248ba1be4fd4af84d8f58f386
5
5
  SHA512:
6
- metadata.gz: 13306a2b078d7fbc4938f7f4306bb0c8a0615ef1726a7b2bdbb306c5c16675a4e9d9956110982ffbeea2e1b4cc1e0e7e732a2073832b0e354561dd0240aff221
7
- data.tar.gz: 408facf5b950144549f27faef351d36362f1a324a5f78faf8473574b7f0ed5331bff4c8ae70f4af2b8f096a174689547ea0ecc2162af098725d68ac46aab4fe2
6
+ metadata.gz: b35df2e5e4fbdc3430c88ef4642895296063a2479584fceeed1c89d43dd95675905198d28edae0dbcdd1d5ce5952c73a7837046827feec60d253a46b6a8bea13
7
+ data.tar.gz: 9ecc727ef80cae0d170e123fd310db95154ad7da8d12ddc7732e72e523bcf20a50781a0b88c256c3dcce273e6d22be2b1a68f53e2d67b860d1d78f6dfcb99161
data/.travis.yml CHANGED
@@ -11,18 +11,18 @@ gemfile:
11
11
  - Gemfile
12
12
  - ruby187.Gemfile
13
13
  matrix:
14
- include:
14
+ exclude:
15
15
  - rvm: 2.0.0
16
- gemfile: Gemfile
16
+ gemfile: ruby187.Gemfile
17
17
  - rvm: 1.9.3
18
- gemfile: Gemfile
19
- - rvm: 1.8.7
20
18
  gemfile: ruby187.Gemfile
19
+ - rvm: 1.8.7
20
+ gemfile: Gemfile
21
21
  - rvm: ree
22
- gemfile: ruby187.Gemfile
23
- - rvm: jruby-18mode
24
22
  gemfile: Gemfile
23
+ - rvm: jruby-18mode
24
+ gemfile: ruby187.Gemfile
25
25
  - rvm: jruby-19mode
26
- gemfile: Gemfile
26
+ gemfile: ruby187.Gemfile
27
27
  - rvm: rbx-2.1.1
28
- gemfile: ruby187.Gemfile
28
+ gemfile: Gemfile
data/README.md CHANGED
@@ -36,15 +36,15 @@ Setup
36
36
  ### Rails Application Use
37
37
 
38
38
  1. Configure Rubygem
39
- - Rails (~> 4.0.0 or ~> 3.0): Add the following to Gemfile <pre>gem 'abstract_feature_branch', '0.9.0'</pre>
40
- - Rails (~> 2.0): Add the following to config/environment.rb <pre>config.gem 'abstract_feature_branch', :version => '0.9.0'</pre>
39
+ - Rails (~> 4.0.0 or ~> 3.0): Add the following to Gemfile <pre>gem 'abstract_feature_branch', '1.0.0'</pre>
40
+ - Rails (~> 2.0): Add the following to config/environment.rb <pre>config.gem 'abstract_feature_branch', :version => '1.0.0'</pre>
41
41
  2. Generate <code>config/initializers/abstract_feature_branch.rb</code>, <code>lib/tasks/abstract_feature_branch.rake</code>, <code>config/features.yml</code> and <code>config/features.local.yml</code> in your Rails app directory by running <pre>rails g abstract_feature_branch:install</pre>
42
42
  3. (Optional) Generate <code>config/features/[context_path].yml</code> in your Rails app directory by running <pre>rails g abstract_feature_branch:context context_path</pre> (more details under [**instructions**](#instructions))
43
43
  4. (Optional and rarely needed) Customize configuration in <code>config/initializers/abstract_feature_branch.rb</code> (can be useful for changing location of feature files in Rails application or troubleshooting a specific Rails environment feature configuration)
44
44
 
45
45
  ### Ruby Application General Use
46
46
 
47
- 1. <pre>gem install abstract_feature_branch -v 0.9.0</pre>
47
+ 1. <pre>gem install abstract_feature_branch -v 1.0.0</pre>
48
48
  2. Add code <code>require 'abstract_feature_branch'</code>
49
49
  3. Create <code>config/features.yml</code> under <code>AbstractFeatureBranch.application_root</code> and fill it with content similar to that of the sample <code>config/features.yml</code> mentioned under [**instructions**](#instructions).
50
50
  4. (Optional) Create <code>config/features.local.yml</code> under <code>AbstractFeatureBranch.application_root</code> (more details under [**instructions**](#instructions))
@@ -52,7 +52,8 @@ Setup
52
52
  6. (Optional) Add code <code>AbstractFeatureBranch.application_root = "[your_application_path]"</code> to configure the location of feature files (it defaults to <code>'.'</code>)
53
53
  7. (Optional) Add code <code>AbstractFeatureBranch.application_environment = "[your_application_environment]"</code> (it defaults to <code>'development'</code>). Alternatively, you can set <code>ENV['APP_ENV']</code> before the <code>require</code> statement or an an external environment variable.
54
54
  8. (Optional) Add code <code>AbstractFeatureBranch.logger = "[your_application_logger]"</code> (it defaults to a new instance of Ruby <code>Logger</code>. Must use a logger with <code>info</code> and <code>warn</code> methods).
55
- 9. (Optional) Add code <code>AbstractFeatureBranch.load_application_features</code> to pre-load application features for improved first-use performance
55
+ 9. (Optional) Add code <code>AbstractFeatureBranch.cacheable = {[environment] => [true/false]}</code> to indicate cacheability of loaded feature files for enhanced performance (it defaults to true for every environment other than development).
56
+ 10. (Optional) Add code <code>AbstractFeatureBranch.load_application_features</code> to pre-load application features for improved first-use performance
56
57
 
57
58
  Instructions
58
59
  ------------
@@ -283,8 +284,17 @@ Here is the content of the generated initializer (<code>config/initializers/abst
283
284
  > # Abstract Feature Branch logger
284
285
  > AbstractFeatureBranch.logger = Rails.logger
285
286
  >
286
- > # Pre-loads application features to improve performance of first web-page hit
287
- > AbstractFeatureBranch.load_application_features
287
+ > # Cache feature files once read or re-read them at runtime on every use (helps development).
288
+ > # Defaults to true if environment not specified, except for development, which defaults to false.
289
+ > AbstractFeatureBranch.cacheable = {
290
+ > :development => false,
291
+ > :test => true,
292
+ > :staging => true,
293
+ > :production => true
294
+ > }
295
+ >
296
+ > # Pre-load application features to improve performance of first web-page hit
297
+ > AbstractFeatureBranch.load_application_features unless Rails.env.development?
288
298
 
289
299
  Rake Task
290
300
  ---------
@@ -374,67 +384,10 @@ The rake task may be invoked in a number of ways:
374
384
  - <code>rake abstract_feature_branch:beautify_files[file_path]</code> beautifies a single feature file
375
385
  - <code>rake abstract_feature_branch:beautify_files[directory_path]</code> beautifies all feature files under directory path recursively
376
386
 
377
- Verify after the task has been invoked that your feature file contents are to your satisfaction before committing the
387
+ Note that the beautifier ignores comments at the top, but deletes entire line comments in the middle of a YAML file, so
388
+ after invoking the rake task, **verify** that your feature file contents are to your satisfaction before committing the
378
389
  task changes.
379
390
 
380
- Release Notes
381
- -------------
382
-
383
- Version 0.9.0:
384
- - Added support for runtime read of feature files in development to ease local testing (trading off performance)
385
-
386
- Version 0.8.0:
387
- - Added rake task for beautifying feature files, sorting feature names within environment sections and eliminating extra empty lines. Added support for externalized logger.
388
-
389
- Version 0.7.1:
390
- - Fixed undefined method issue with using <code>AbstractFeatureBranch.load_application_features</code> to improve first use performance
391
-
392
- Version 0.7.0:
393
- - Added support for general Ruby use (without Rails) by externalizing AbstractFeatureBranch.application_root and AbstractFeatureBranch.application_environment. Added initializer to optionally configure them. Supported case-insensitive feature names.
394
-
395
- Version 0.6.1 - 0.6.4:
396
- - Fixed issues including making feature configuration files optional (in case one wants to get rid of <code>features.local.yml</code> or even <code>features.yml</code>)
397
-
398
- Version 0.6.0:
399
- - Added a context generator and support for reading feature configuration from context files <code>config/features/**/*.yml</code> and <code>config/features/**/*.local.yml</code>
400
-
401
- Version 0.5.0:
402
- - Added support for local configuration feature ignored by git + some performance optimizations via configuration caching and better algorithms.
403
-
404
- Version 0.4.0:
405
- - Added support for overwriting feature configuration with environment variable overrides. Very useful on Heroku to quickly enable/disable features without a redeploy.
406
-
407
- Version 0.3.6:
408
- - Fixed feature_branch issue with invalid feature name, preventing block execution and returning nil instead
409
-
410
- Version 0.3.5:
411
- - Fixed issue with generator not allowing consuming client app to start Rails server successfully
412
-
413
- Version 0.3.4:
414
- - Added <code>abstract_feature_branch:install</code> generator to easily get started with a sample <code>config/features.yml</code>
415
-
416
- Version 0.3.3:
417
- - Removed version from README title
418
-
419
- Version 0.3.2:
420
- - Added <code>AbstractFeatureBranch.features</code> to delay YAML load until <code>Rails.root</code> has been established
421
-
422
- Version 0.3.1:
423
- - Removed dependency on the rails_config gem
424
-
425
- Version 0.3.0:
426
- - Simplified <code>features.yml</code> requirement to have a features header under each environment
427
- - Moved feature storage from Settings object to <code>AbstractFeatureBranch::FEATURES</code>
428
-
429
- Version 0.2.0:
430
- - Support an "else" block to execute when a feature is off (via <code>:true</code> and <code>:false</code> lambda arguments)
431
- - Support ability to check if a feature is enabled or not (via <code>feature_enabled?</code>)
432
-
433
- Upcoming
434
- --------
435
-
436
- - Support configuring per environment whether features yml is read at runtime or not (given performance trade-off)
437
-
438
391
  Contributing to abstract_feature_branch
439
392
  ---------------------------------------
440
393
 
data/RELEASE_NOTES.md ADDED
@@ -0,0 +1,55 @@
1
+ Release Notes
2
+ -------------
3
+
4
+ Version 0.9.0:
5
+ - Added configuration support for feature cacheability
6
+
7
+ Version 0.9.0:
8
+ - Added support for runtime read of feature files in development to ease local testing (trading off performance)
9
+
10
+ Version 0.8.0:
11
+ - Added rake task for beautifying feature files, sorting feature names within environment sections and eliminating extra empty lines. Added support for externalized logger.
12
+
13
+ Version 0.7.1:
14
+ - Fixed undefined method issue with using <code>AbstractFeatureBranch.load_application_features</code> to improve first use performance
15
+
16
+ Version 0.7.0:
17
+ - Added support for general Ruby use (without Rails) by externalizing AbstractFeatureBranch.application_root and AbstractFeatureBranch.application_environment. Added initializer to optionally configure them. Supported case-insensitive feature names.
18
+
19
+ Version 0.6.1 - 0.6.4:
20
+ - Fixed issues including making feature configuration files optional (in case one wants to get rid of <code>features.local.yml</code> or even <code>features.yml</code>)
21
+
22
+ Version 0.6.0:
23
+ - Added a context generator and support for reading feature configuration from context files <code>config/features/**/*.yml</code> and <code>config/features/**/*.local.yml</code>
24
+
25
+ Version 0.5.0:
26
+ - Added support for local configuration feature ignored by git + some performance optimizations via configuration caching and better algorithms.
27
+
28
+ Version 0.4.0:
29
+ - Added support for overwriting feature configuration with environment variable overrides. Very useful on Heroku to quickly enable/disable features without a redeploy.
30
+
31
+ Version 0.3.6:
32
+ - Fixed feature_branch issue with invalid feature name, preventing block execution and returning nil instead
33
+
34
+ Version 0.3.5:
35
+ - Fixed issue with generator not allowing consuming client app to start Rails server successfully
36
+
37
+ Version 0.3.4:
38
+ - Added <code>abstract_feature_branch:install</code> generator to easily get started with a sample <code>config/features.yml</code>
39
+
40
+ Version 0.3.3:
41
+ - Removed version from README title
42
+
43
+ Version 0.3.2:
44
+ - Added <code>AbstractFeatureBranch.features</code> to delay YAML load until <code>Rails.root</code> has been established
45
+
46
+ Version 0.3.1:
47
+ - Removed dependency on the rails_config gem
48
+
49
+ Version 0.3.0:
50
+ - Simplified <code>features.yml</code> requirement to have a features header under each environment
51
+ - Moved feature storage from Settings object to <code>AbstractFeatureBranch::FEATURES</code>
52
+
53
+ Version 0.2.0:
54
+ - Support an "else" block to execute when a feature is off (via <code>:true</code> and <code>:false</code> lambda arguments)
55
+ - Support ability to check if a feature is enabled or not (via <code>feature_enabled?</code>)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.9.0
1
+ 1.0.0
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "abstract_feature_branch"
8
- s.version = "0.9.0"
8
+ s.version = "1.0.0"
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"]
@@ -20,6 +20,7 @@ Gem::Specification.new do |s|
20
20
  ".travis.yml",
21
21
  "LICENSE.txt",
22
22
  "README.md",
23
+ "RELEASE_NOTES.md",
23
24
  "VERSION",
24
25
  "abstract_feature_branch.gemspec",
25
26
  "config/features/admin.local.yml",
@@ -39,6 +40,7 @@ Gem::Specification.new do |s|
39
40
  "lib/generators/templates/config/initializers/abstract_feature_branch.rb",
40
41
  "lib/generators/templates/lib/tasks/abstract_feature_branch.rake",
41
42
  "ruby187.Gemfile",
43
+ "ruby187.Gemfile.lock",
42
44
  "spec/abstract_feature_branch/file_beautifier_spec.rb",
43
45
  "spec/ext/feature_branch__feature_branch_spec.rb",
44
46
  "spec/ext/feature_branch__feature_enabled_spec.rb",
@@ -40,6 +40,20 @@ module AbstractFeatureBranch
40
40
  def self.initialize_logger
41
41
  self.logger = defined?(Rails) && Rails.logger ? Rails.logger : Logger.new(STDOUT)
42
42
  end
43
+ def self.cacheable
44
+ @cacheable ||= initialize_cacheable
45
+ end
46
+ def self.cacheable=(cacheable)
47
+ @cacheable = cacheable
48
+ end
49
+ def self.initialize_cacheable
50
+ self.cacheable = {
51
+ :development => false,
52
+ :test => true,
53
+ :staging => true,
54
+ :production => true
55
+ }
56
+ end
43
57
  def self.environment_variable_overrides
44
58
  @environment_variable_overrides ||= load_environment_variable_overrides
45
59
  end
@@ -98,7 +112,9 @@ module AbstractFeatureBranch
98
112
  @environment_features = nil
99
113
  end
100
114
  def self.cacheable?
101
- application_environment != 'development'
115
+ value = downcase_keys(cacheable)[application_environment]
116
+ value = (application_environment != 'development') if value.nil?
117
+ value
102
118
  end
103
119
 
104
120
  private
@@ -7,5 +7,14 @@ AbstractFeatureBranch.application_environment = Rails.env.to_s
7
7
  # Abstract Feature Branch logger
8
8
  AbstractFeatureBranch.logger = Rails.logger
9
9
 
10
- # Pre-loads application features to improve performance of first web-page hit
11
- AbstractFeatureBranch.load_application_features
10
+ # Cache feature files once read or re-read them at runtime on every use (helps development).
11
+ # Defaults to true if environment not specified, except for development, which defaults to false.
12
+ AbstractFeatureBranch.cacheable = {
13
+ :development => false,
14
+ :test => true,
15
+ :staging => true,
16
+ :production => true
17
+ }
18
+
19
+ # Pre-load application features to improve performance of first web-page hit
20
+ AbstractFeatureBranch.load_application_features unless Rails.env.development?
@@ -0,0 +1,63 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ addressable (2.3.5)
5
+ builder (3.2.2)
6
+ deep_merge (1.0.0)
7
+ diff-lcs (1.2.5)
8
+ faraday (0.8.8)
9
+ multipart-post (~> 1.2.0)
10
+ git (1.2.6)
11
+ github_api (0.10.1)
12
+ addressable
13
+ faraday (~> 0.8.1)
14
+ hashie (>= 1.2)
15
+ multi_json (~> 1.4)
16
+ nokogiri (~> 1.5.2)
17
+ oauth2
18
+ hashie (2.0.5)
19
+ highline (1.6.20)
20
+ httpauth (0.2.0)
21
+ jeweler (1.8.8)
22
+ builder
23
+ bundler (~> 1.0)
24
+ git (>= 1.2.5)
25
+ github_api (= 0.10.1)
26
+ highline (>= 1.6.15)
27
+ nokogiri (= 1.5.10)
28
+ rake
29
+ rdoc
30
+ json (1.8.1)
31
+ jwt (0.1.8)
32
+ multi_json (>= 1.5)
33
+ multi_json (1.8.2)
34
+ multi_xml (0.5.5)
35
+ multipart-post (1.2.0)
36
+ nokogiri (1.5.10)
37
+ oauth2 (0.9.2)
38
+ faraday (~> 0.8)
39
+ httpauth (~> 0.2)
40
+ jwt (~> 0.1.4)
41
+ multi_json (~> 1.0)
42
+ multi_xml (~> 0.5)
43
+ rack (~> 1.2)
44
+ rack (1.5.2)
45
+ rake (10.1.0)
46
+ rdoc (4.0.1)
47
+ json (~> 1.4)
48
+ rspec (2.14.1)
49
+ rspec-core (~> 2.14.0)
50
+ rspec-expectations (~> 2.14.0)
51
+ rspec-mocks (~> 2.14.0)
52
+ rspec-core (2.14.7)
53
+ rspec-expectations (2.14.4)
54
+ diff-lcs (>= 1.1.3, < 2.0)
55
+ rspec-mocks (2.14.4)
56
+
57
+ PLATFORMS
58
+ ruby
59
+
60
+ DEPENDENCIES
61
+ deep_merge (= 1.0.0)
62
+ jeweler (= 1.8.8)
63
+ rspec (= 2.14.1)
@@ -109,6 +109,7 @@ production:
109
109
  feature_enabled?(:feature1).should == true
110
110
  feature_enabled?(:feature2).should == false
111
111
  end
112
+
112
113
  %w(test staging production).each do |environment|
113
114
  it "does not refresh features at runtime in #{environment} (without forcing load of application features again)" do
114
115
  AbstractFeatureBranch.application_environment = environment
@@ -144,6 +145,77 @@ production:
144
145
  feature_enabled?(:feature2).should == true
145
146
  end
146
147
  end
148
+
149
+ it 'does not refresh features at runtime in development when overridden' do
150
+ AbstractFeatureBranch.application_environment = 'development'
151
+ AbstractFeatureBranch.cacheable = {:development => true}
152
+ AbstractFeatureBranch.load_application_features
153
+ feature_enabled?(:feature1).should == false
154
+ feature_enabled?(:feature2).should == true
155
+ File.open(@feature_file_path, 'w+') do |file|
156
+ file << <<-CONTENT
157
+ defaults: &defaults
158
+
159
+ development:
160
+ <<: *defaults
161
+ FEATURE1: true
162
+ Feature2: false
163
+
164
+ test:
165
+ <<: *defaults
166
+ FEATURE1: true
167
+ Feature2: false
168
+
169
+ staging:
170
+ <<: *defaults
171
+ FEATURE1: true
172
+ Feature2: false
173
+
174
+ production:
175
+ <<: *defaults
176
+ FEATURE1: true
177
+ Feature2: false
178
+ CONTENT
179
+ end
180
+ feature_enabled?(:feature1).should == false
181
+ feature_enabled?(:feature2).should == true
182
+ end
183
+
184
+ %w(test staging production).each do |environment|
185
+ it "does refresh features at runtime in #{environment} (without forcing load of application features again)" do
186
+ AbstractFeatureBranch.application_environment = environment
187
+ AbstractFeatureBranch.cacheable = {:test => false, :staging => false, :production => false}
188
+ feature_enabled?(:feature1).should == false
189
+ feature_enabled?(:feature2).should == true
190
+ File.open(@feature_file_path, 'w+') do |file|
191
+ file << <<-CONTENT
192
+ defaults: &defaults
193
+
194
+ development:
195
+ <<: *defaults
196
+ FEATURE1: true
197
+ Feature2: false
198
+
199
+ test:
200
+ <<: *defaults
201
+ FEATURE1: true
202
+ Feature2: false
203
+
204
+ staging:
205
+ <<: *defaults
206
+ FEATURE1: true
207
+ Feature2: false
208
+
209
+ production:
210
+ <<: *defaults
211
+ FEATURE1: true
212
+ Feature2: false
213
+ CONTENT
214
+ end
215
+ feature_enabled?(:feature1).should == true
216
+ feature_enabled?(:feature2).should == false
217
+ end
218
+ end
147
219
  end
148
220
  end
149
221
  describe 'self#feature_enabled?' do
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.9.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Annas "Andy" Maleh
@@ -70,6 +70,7 @@ files:
70
70
  - .travis.yml
71
71
  - LICENSE.txt
72
72
  - README.md
73
+ - RELEASE_NOTES.md
73
74
  - VERSION
74
75
  - abstract_feature_branch.gemspec
75
76
  - config/features/admin.local.yml
@@ -89,6 +90,7 @@ files:
89
90
  - lib/generators/templates/config/initializers/abstract_feature_branch.rb
90
91
  - lib/generators/templates/lib/tasks/abstract_feature_branch.rake
91
92
  - ruby187.Gemfile
93
+ - ruby187.Gemfile.lock
92
94
  - spec/abstract_feature_branch/file_beautifier_spec.rb
93
95
  - spec/ext/feature_branch__feature_branch_spec.rb
94
96
  - spec/ext/feature_branch__feature_enabled_spec.rb