abstract_feature_branch 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE.txt +20 -0
- data/README.md +106 -0
- data/VERSION +1 -0
- data/abstract_feature_branch.gemspec +56 -0
- data/lib/abstract_feature_branch.rb +22 -0
- data/lib/ext/feature_branch.rb +13 -0
- metadata +158 -0
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2012 Annas "Andy" Maleh
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
Abstract Feature Branch
|
2
|
+
=======================
|
3
|
+
|
4
|
+
abstract_feature_branch is a Rails gem that enables developers to easily branch by
|
5
|
+
abstraction as per this pattern: http://paulhammant.com/blog/branch_by_abstraction.html
|
6
|
+
|
7
|
+
It gives ability to wrap blocks of code with an abstract feature branch name, and then
|
8
|
+
specify which features to be switched on or off in a configuration file.
|
9
|
+
|
10
|
+
The goal is to build out future features with full integration into the codebase, thus
|
11
|
+
ensuring no delay in integration in the future, while releasing currently done features
|
12
|
+
at the same time. Developers then disable future features until they are ready to be
|
13
|
+
switched on in production, but do enable them in staging and locally.
|
14
|
+
|
15
|
+
This gives developers the added benefit of being able to switch a feature off after
|
16
|
+
release should big problems arise for a high risk feature.
|
17
|
+
|
18
|
+
Setup
|
19
|
+
-----
|
20
|
+
|
21
|
+
In Rails 3.x:
|
22
|
+
|
23
|
+
1. Add 'abstract_feature_branch' gem to Gemfile in Rails 3.x or
|
24
|
+
"config.gem 'absract_feature_branch'" to environment.rb in Rails 2.x
|
25
|
+
2. Configure config/features.yml in your Rails app directory as follows:
|
26
|
+
\*
|
27
|
+
defaults: &defaults
|
28
|
+
features:
|
29
|
+
# feature1: true
|
30
|
+
# feature2: true
|
31
|
+
# feature3: false
|
32
|
+
|
33
|
+
development:
|
34
|
+
<<: *defaults
|
35
|
+
|
36
|
+
test:
|
37
|
+
<<: *defaults
|
38
|
+
|
39
|
+
staging:
|
40
|
+
<<: *defaults
|
41
|
+
# feature2: false
|
42
|
+
|
43
|
+
production:
|
44
|
+
<<: *defaults
|
45
|
+
features:
|
46
|
+
# feature1: false
|
47
|
+
# feature2: false
|
48
|
+
\*
|
49
|
+
Notice how the feature "add_business_project" was configured as true (enabled) by default, but
|
50
|
+
overridden as false (disabled) in production. This is a recommended practice.
|
51
|
+
3. feature branch your logic as per this example:
|
52
|
+
\*
|
53
|
+
feature_branch :feature1 do
|
54
|
+
# perform add business logic
|
55
|
+
end
|
56
|
+
\*
|
57
|
+
|
58
|
+
Recommendations
|
59
|
+
---------------
|
60
|
+
- Wrap routes in routes.rb with feature blocks to disable entire MVC feature elements by
|
61
|
+
simply switching off the URL route to them. Example:
|
62
|
+
\*
|
63
|
+
feature_branch :add_business_project do
|
64
|
+
resources :projects
|
65
|
+
end
|
66
|
+
\*
|
67
|
+
|
68
|
+
- Wrap visual links to these routes in ERB views. Example:
|
69
|
+
\*
|
70
|
+
<% feature_branch :add_business_project do %>
|
71
|
+
<h2>Submit a Business</h2>
|
72
|
+
<p>
|
73
|
+
Please submit a business idea for investors to look at.
|
74
|
+
</p>
|
75
|
+
<ul>
|
76
|
+
<% current_user.projects.each do |p| %>
|
77
|
+
<li><%= link_to p.business_campaign_name, project_path(p) %></li>
|
78
|
+
<% end %>
|
79
|
+
</ul>
|
80
|
+
<h4>
|
81
|
+
<%= link_to('Start', new_project_path, :id => "business_background_invitation", :class => 'button') %>
|
82
|
+
</h4>
|
83
|
+
<% end %>
|
84
|
+
\*
|
85
|
+
- Once a feature has been released and switched on in production, and it has worked well for a while,
|
86
|
+
it is recommended that its feature branching code is plucked out of the code base to simplify the code
|
87
|
+
for better maintenance as the need is not longer there for feature branching at that point.
|
88
|
+
|
89
|
+
|
90
|
+
Contributing to abstract_feature_branch
|
91
|
+
---------------------------------------
|
92
|
+
|
93
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
94
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
95
|
+
* Fork the project.
|
96
|
+
* Start a feature/bugfix branch.
|
97
|
+
* Commit and push until you are happy with your contribution.
|
98
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
99
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
100
|
+
|
101
|
+
Copyright
|
102
|
+
---------------------------------------
|
103
|
+
|
104
|
+
Copyright (c) 2012 Annas "Andy" Maleh. See LICENSE.txt for
|
105
|
+
further details.
|
106
|
+
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "abstract_feature_branch"
|
8
|
+
s.version = "0.1.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Annas \"Andy\" Maleh"]
|
12
|
+
s.date = "2012-11-12"
|
13
|
+
s.description = "It gives ability to wrap blocks of code with an abstract feature branch name, and then\nspecify which features to be switched on or off in a configuration file.\n\nThe goal is to build out future features with full integration into the codebase, thus\nensuring no delay in integration in the future, while releasing currently done features\nat the same time. Developers then disable future features until they are ready to be\nswitched on in production, but do enable them in staging and locally.\n\nThis gives developers the added benefit of being able to switch a feature off after\nrelease should big problems arise for a high risk feature.\n"
|
14
|
+
s.extra_rdoc_files = [
|
15
|
+
"LICENSE.txt",
|
16
|
+
"README.md"
|
17
|
+
]
|
18
|
+
s.files = [
|
19
|
+
"LICENSE.txt",
|
20
|
+
"README.md",
|
21
|
+
"VERSION",
|
22
|
+
"abstract_feature_branch.gemspec",
|
23
|
+
"lib/abstract_feature_branch.rb",
|
24
|
+
"lib/ext/feature_branch.rb"
|
25
|
+
]
|
26
|
+
s.homepage = "http://github.com/AndyObtiva/abstract_feature_branch"
|
27
|
+
s.licenses = ["MIT"]
|
28
|
+
s.require_paths = ["lib"]
|
29
|
+
s.rubygems_version = "1.8.24"
|
30
|
+
s.summary = "abstract_feature_branch is a Rails gem that enables developers to easily branch by abstraction as per this pattern: http://paulhammant.com/blog/branch_by_abstraction.html"
|
31
|
+
|
32
|
+
if s.respond_to? :specification_version then
|
33
|
+
s.specification_version = 3
|
34
|
+
|
35
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
36
|
+
s.add_runtime_dependency(%q<rails_config>, [">= 0.3.1"])
|
37
|
+
s.add_development_dependency(%q<rspec>, ["= 2.11.0"])
|
38
|
+
s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
|
39
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.8.4"])
|
40
|
+
s.add_runtime_dependency(%q<rails_config>, [">= 0.3.1"])
|
41
|
+
else
|
42
|
+
s.add_dependency(%q<rails_config>, [">= 0.3.1"])
|
43
|
+
s.add_dependency(%q<rspec>, ["= 2.11.0"])
|
44
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
45
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
|
46
|
+
s.add_dependency(%q<rails_config>, [">= 0.3.1"])
|
47
|
+
end
|
48
|
+
else
|
49
|
+
s.add_dependency(%q<rails_config>, [">= 0.3.1"])
|
50
|
+
s.add_dependency(%q<rspec>, ["= 2.11.0"])
|
51
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
52
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
|
53
|
+
s.add_dependency(%q<rails_config>, [">= 0.3.1"])
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'rails_config'
|
11
|
+
|
12
|
+
RailsConfig.setup do |config|
|
13
|
+
config.const_name = "Settings"
|
14
|
+
end
|
15
|
+
RailsConfig.load_and_set_settings("#{Rails.root}/config/features.yml")
|
16
|
+
|
17
|
+
# Add this line if you need a local override. Make sure it is added to .gitignore
|
18
|
+
#Settings.add_source!("#{Rails.root}/config/features.local.yml")
|
19
|
+
|
20
|
+
Settings.reload!
|
21
|
+
|
22
|
+
require File.join(File.dirname(__FILE__), 'ext', 'feature_branch')
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class Object
|
2
|
+
raise 'Abstract branch conflicts with another Ruby library' if respond_to?(:feature_branch)
|
3
|
+
def self.feature_branch(feature_name, &feature_work)
|
4
|
+
if Settings[Rails.env.to_s]['features'][feature_name]
|
5
|
+
feature_work.call
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
raise 'Abstract branch conflicts with another Ruby library' if Object.new.respond_to?(:feature_branch)
|
10
|
+
def feature_branch(feature_name, &feature_work)
|
11
|
+
Object.feature_branch(feature_name, &feature_work)
|
12
|
+
end
|
13
|
+
end
|
metadata
ADDED
@@ -0,0 +1,158 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: abstract_feature_branch
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Annas "Andy" Maleh
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-11-12 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rails_config
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 0.3.1
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 0.3.1
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rspec
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - '='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 2.11.0
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - '='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 2.11.0
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rdoc
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '3.12'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.12'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: jeweler
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 1.8.4
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 1.8.4
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: rails_config
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: 0.3.1
|
86
|
+
type: :runtime
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: 0.3.1
|
94
|
+
description: ! 'It gives ability to wrap blocks of code with an abstract feature branch
|
95
|
+
name, and then
|
96
|
+
|
97
|
+
specify which features to be switched on or off in a configuration file.
|
98
|
+
|
99
|
+
|
100
|
+
The goal is to build out future features with full integration into the codebase,
|
101
|
+
thus
|
102
|
+
|
103
|
+
ensuring no delay in integration in the future, while releasing currently done features
|
104
|
+
|
105
|
+
at the same time. Developers then disable future features until they are ready to
|
106
|
+
be
|
107
|
+
|
108
|
+
switched on in production, but do enable them in staging and locally.
|
109
|
+
|
110
|
+
|
111
|
+
This gives developers the added benefit of being able to switch a feature off after
|
112
|
+
|
113
|
+
release should big problems arise for a high risk feature.
|
114
|
+
|
115
|
+
'
|
116
|
+
email:
|
117
|
+
executables: []
|
118
|
+
extensions: []
|
119
|
+
extra_rdoc_files:
|
120
|
+
- LICENSE.txt
|
121
|
+
- README.md
|
122
|
+
files:
|
123
|
+
- LICENSE.txt
|
124
|
+
- README.md
|
125
|
+
- VERSION
|
126
|
+
- abstract_feature_branch.gemspec
|
127
|
+
- lib/abstract_feature_branch.rb
|
128
|
+
- lib/ext/feature_branch.rb
|
129
|
+
homepage: http://github.com/AndyObtiva/abstract_feature_branch
|
130
|
+
licenses:
|
131
|
+
- MIT
|
132
|
+
post_install_message:
|
133
|
+
rdoc_options: []
|
134
|
+
require_paths:
|
135
|
+
- lib
|
136
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - ! '>='
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
142
|
+
segments:
|
143
|
+
- 0
|
144
|
+
hash: -381377031789369031
|
145
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
146
|
+
none: false
|
147
|
+
requirements:
|
148
|
+
- - ! '>='
|
149
|
+
- !ruby/object:Gem::Version
|
150
|
+
version: '0'
|
151
|
+
requirements: []
|
152
|
+
rubyforge_project:
|
153
|
+
rubygems_version: 1.8.24
|
154
|
+
signing_key:
|
155
|
+
specification_version: 3
|
156
|
+
summary: ! 'abstract_feature_branch is a Rails gem that enables developers to easily
|
157
|
+
branch by abstraction as per this pattern: http://paulhammant.com/blog/branch_by_abstraction.html'
|
158
|
+
test_files: []
|