flip 0.0.1.alpha2 → 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +2 -2
- data/TODO +3 -0
- data/app/assets/stylesheets/flip.css +64 -0
- data/app/controllers/flip/features_controller.rb +47 -0
- data/app/controllers/flip/strategies_controller.rb +31 -0
- data/app/helpers/flip_helper.rb +9 -0
- data/app/views/flip/features/index.html.erb +60 -0
- data/config/routes.rb +14 -0
- data/lib/flip/engine.rb +5 -0
- data/lib/flip/version.rb +1 -1
- data/lib/generators/flip/install/install_generator.rb +9 -0
- data/lib/generators/flip/model/templates/feature.rb +1 -1
- metadata +22 -16
data/README.md
CHANGED
@@ -108,5 +108,5 @@ A dashboard allows you to view the current state of the feature set, and flip an
|
|
108
108
|
|
109
109
|
|
110
110
|
----
|
111
|
-
|
112
|
-
|
111
|
+
Created by Paul Annesley
|
112
|
+
Copyright © 2011 Learnable Pty Ltd, [MIT Licence](http://www.opensource.org/licenses/mit-license.php).
|
data/TODO
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
/* Flip */
|
2
|
+
|
3
|
+
.flip {
|
4
|
+
margin: 2em 1em 4em 1em;
|
5
|
+
}
|
6
|
+
|
7
|
+
.flip th.name, .flip th.description, .flip th.status {
|
8
|
+
visibility: hidden;
|
9
|
+
}
|
10
|
+
|
11
|
+
.flip td.name {
|
12
|
+
font-family: Monaco, sans-serif;
|
13
|
+
font-weight: bold;
|
14
|
+
}
|
15
|
+
|
16
|
+
.flip td.name, .flip td.description {
|
17
|
+
vertical-align: top;
|
18
|
+
}
|
19
|
+
|
20
|
+
.flip th {
|
21
|
+
font-weight: normal;
|
22
|
+
text-align: left;
|
23
|
+
vertical-align: top;
|
24
|
+
}
|
25
|
+
|
26
|
+
.flip th .description {
|
27
|
+
font-weight: normal;
|
28
|
+
display: block;
|
29
|
+
font-size: 80%;
|
30
|
+
}
|
31
|
+
|
32
|
+
.flip th, .flip td {
|
33
|
+
padding: 5px 10px;
|
34
|
+
width: 160px;
|
35
|
+
height: 40px;
|
36
|
+
}
|
37
|
+
|
38
|
+
.flip td.off, .flip td.on, .flip td.pass {
|
39
|
+
text-align: center;
|
40
|
+
text-transform: capitalize;
|
41
|
+
}
|
42
|
+
|
43
|
+
.flip td.off {
|
44
|
+
background-color: #fbb;
|
45
|
+
}
|
46
|
+
|
47
|
+
.flip td.on {
|
48
|
+
background-color: #cfc;
|
49
|
+
}
|
50
|
+
|
51
|
+
.flip td.pass {
|
52
|
+
background-color: #eef;
|
53
|
+
}
|
54
|
+
|
55
|
+
.flip form {
|
56
|
+
display: inline;
|
57
|
+
}
|
58
|
+
|
59
|
+
.flip form input[type=submit] {
|
60
|
+
font-size: 80%;
|
61
|
+
padding: 2px 5px;
|
62
|
+
margin: 0;
|
63
|
+
}
|
64
|
+
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module Flip
|
2
|
+
class FeaturesController < ApplicationController
|
3
|
+
|
4
|
+
def index
|
5
|
+
@p = FeaturesPresenter.new(FeatureSet.instance)
|
6
|
+
end
|
7
|
+
|
8
|
+
class FeaturesPresenter
|
9
|
+
|
10
|
+
include Flip::Engine.routes.url_helpers
|
11
|
+
|
12
|
+
def initialize(feature_set)
|
13
|
+
@feature_set = feature_set
|
14
|
+
end
|
15
|
+
|
16
|
+
def strategies
|
17
|
+
@feature_set.strategies
|
18
|
+
end
|
19
|
+
|
20
|
+
def definitions
|
21
|
+
@feature_set.definitions
|
22
|
+
end
|
23
|
+
|
24
|
+
def status(definition)
|
25
|
+
@feature_set.on?(definition.key) ? "on" : "off"
|
26
|
+
end
|
27
|
+
|
28
|
+
def default_status(definition)
|
29
|
+
@feature_set.default_for(definition) ? "on" : "off"
|
30
|
+
end
|
31
|
+
|
32
|
+
def strategy_status(strategy, definition)
|
33
|
+
if strategy.knows? definition
|
34
|
+
strategy.on?(definition) ? "on" : "off"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def switch_url(strategy, definition)
|
39
|
+
feature_strategy_path \
|
40
|
+
definition.key,
|
41
|
+
strategy.name.underscore
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Flip
|
2
|
+
class StrategiesController < ApplicationController
|
3
|
+
|
4
|
+
include Flip::Engine.routes.url_helpers
|
5
|
+
|
6
|
+
def update
|
7
|
+
strategy.switch! feature_key, turn_on?
|
8
|
+
redirect_to features_url
|
9
|
+
end
|
10
|
+
|
11
|
+
def destroy
|
12
|
+
strategy.delete! feature_key
|
13
|
+
redirect_to features_url
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def turn_on?
|
19
|
+
params[:commit] == "Switch On"
|
20
|
+
end
|
21
|
+
|
22
|
+
def feature_key
|
23
|
+
params[:feature_id].to_sym
|
24
|
+
end
|
25
|
+
|
26
|
+
def strategy
|
27
|
+
FeatureSet.instance.strategy(params[:id])
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
<h1>Feature Flippers</h1>
|
2
|
+
|
3
|
+
<table class="flip">
|
4
|
+
<thead>
|
5
|
+
<th class="name">Feature Name</th>
|
6
|
+
<th class="description">Description</th>
|
7
|
+
<th class="status">Status</th>
|
8
|
+
<% @p.strategies.each do |strategy| %>
|
9
|
+
<th>
|
10
|
+
<%= strategy.name %>
|
11
|
+
<span class="description"><%= strategy.description %></span>
|
12
|
+
</th>
|
13
|
+
<% end %>
|
14
|
+
<th>
|
15
|
+
Default
|
16
|
+
<span class="description">The system default when no strategies match.</span>
|
17
|
+
</th>
|
18
|
+
</thead>
|
19
|
+
<tbody>
|
20
|
+
<% @p.definitions.each do |definition| %>
|
21
|
+
<tr>
|
22
|
+
<td class="name"><%= definition.name %></td>
|
23
|
+
|
24
|
+
<td class="description"><%= definition.description %></td>
|
25
|
+
|
26
|
+
<%= content_tag :td, class: @p.status(definition) do %>
|
27
|
+
<%= @p.status definition %>
|
28
|
+
<% end %>
|
29
|
+
|
30
|
+
<% @p.strategies.each do |strategy| %>
|
31
|
+
<%= content_tag :td, class: @p.strategy_status(strategy, definition) || "pass" do %>
|
32
|
+
<%= @p.strategy_status strategy, definition %>
|
33
|
+
|
34
|
+
<% if strategy.switchable? %>
|
35
|
+
<%= form_tag(@p.switch_url(strategy, definition), method: :put) do %>
|
36
|
+
<% unless @p.strategy_status(strategy, definition) == "on" %>
|
37
|
+
<%= submit_tag "Switch On" %>
|
38
|
+
<% end %>
|
39
|
+
<% unless @p.strategy_status(strategy, definition) == "off" %>
|
40
|
+
<%= submit_tag "Switch Off" %>
|
41
|
+
<% end %>
|
42
|
+
<% end %>
|
43
|
+
<% unless @p.strategy_status(strategy, definition).blank? %>
|
44
|
+
<%= form_tag(@p.switch_url(strategy, definition), method: :delete) do %>
|
45
|
+
<%= submit_tag "Delete" %>
|
46
|
+
<% end %>
|
47
|
+
<% end %>
|
48
|
+
<% end %>
|
49
|
+
|
50
|
+
<% end %>
|
51
|
+
<% end %>
|
52
|
+
|
53
|
+
<%= content_tag :td, class: @p.default_status(definition) do %>
|
54
|
+
<%= @p.default_status definition %>
|
55
|
+
<% end %>
|
56
|
+
|
57
|
+
</tr>
|
58
|
+
<% end %>
|
59
|
+
</tbody>
|
60
|
+
</table>
|
data/config/routes.rb
ADDED
data/lib/flip/engine.rb
CHANGED
data/lib/flip/version.rb
CHANGED
metadata
CHANGED
@@ -1,20 +1,19 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flip
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.1
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Paul Annesley
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-
|
13
|
-
default_executable:
|
12
|
+
date: 2011-11-10 00:00:00.000000000 Z
|
14
13
|
dependencies:
|
15
14
|
- !ruby/object:Gem::Dependency
|
16
15
|
name: activesupport
|
17
|
-
requirement: &
|
16
|
+
requirement: &70108786050000 !ruby/object:Gem::Requirement
|
18
17
|
none: false
|
19
18
|
requirements:
|
20
19
|
- - ~>
|
@@ -22,10 +21,10 @@ dependencies:
|
|
22
21
|
version: '3.0'
|
23
22
|
type: :runtime
|
24
23
|
prerelease: false
|
25
|
-
version_requirements: *
|
24
|
+
version_requirements: *70108786050000
|
26
25
|
- !ruby/object:Gem::Dependency
|
27
26
|
name: i18n
|
28
|
-
requirement: &
|
27
|
+
requirement: &70108786049300 !ruby/object:Gem::Requirement
|
29
28
|
none: false
|
30
29
|
requirements:
|
31
30
|
- - ! '>='
|
@@ -33,10 +32,10 @@ dependencies:
|
|
33
32
|
version: '0'
|
34
33
|
type: :runtime
|
35
34
|
prerelease: false
|
36
|
-
version_requirements: *
|
35
|
+
version_requirements: *70108786049300
|
37
36
|
- !ruby/object:Gem::Dependency
|
38
37
|
name: rspec
|
39
|
-
requirement: &
|
38
|
+
requirement: &70108786048500 !ruby/object:Gem::Requirement
|
40
39
|
none: false
|
41
40
|
requirements:
|
42
41
|
- - ~>
|
@@ -44,10 +43,10 @@ dependencies:
|
|
44
43
|
version: '2.5'
|
45
44
|
type: :development
|
46
45
|
prerelease: false
|
47
|
-
version_requirements: *
|
46
|
+
version_requirements: *70108786048500
|
48
47
|
- !ruby/object:Gem::Dependency
|
49
48
|
name: rake
|
50
|
-
requirement: &
|
49
|
+
requirement: &70108786048060 !ruby/object:Gem::Requirement
|
51
50
|
none: false
|
52
51
|
requirements:
|
53
52
|
- - ! '>='
|
@@ -55,7 +54,7 @@ dependencies:
|
|
55
54
|
version: '0'
|
56
55
|
type: :development
|
57
56
|
prerelease: false
|
58
|
-
version_requirements: *
|
57
|
+
version_requirements: *70108786048060
|
59
58
|
description: Declarative API for specifying features, switchable in declaration, database
|
60
59
|
and cookies.
|
61
60
|
email:
|
@@ -68,6 +67,13 @@ files:
|
|
68
67
|
- Gemfile
|
69
68
|
- README.md
|
70
69
|
- Rakefile
|
70
|
+
- TODO
|
71
|
+
- app/assets/stylesheets/flip.css
|
72
|
+
- app/controllers/flip/features_controller.rb
|
73
|
+
- app/controllers/flip/strategies_controller.rb
|
74
|
+
- app/helpers/flip_helper.rb
|
75
|
+
- app/views/flip/features/index.html.erb
|
76
|
+
- config/routes.rb
|
71
77
|
- flip.gemspec
|
72
78
|
- lib/flip.rb
|
73
79
|
- lib/flip/abstract_strategy.rb
|
@@ -81,6 +87,7 @@ files:
|
|
81
87
|
- lib/flip/facade.rb
|
82
88
|
- lib/flip/feature_set.rb
|
83
89
|
- lib/flip/version.rb
|
90
|
+
- lib/generators/flip/install/install_generator.rb
|
84
91
|
- lib/generators/flip/migration/USAGE
|
85
92
|
- lib/generators/flip/migration/migration_generator.rb
|
86
93
|
- lib/generators/flip/migration/templates/create_features.rb
|
@@ -99,7 +106,6 @@ files:
|
|
99
106
|
- spec/feature_set_spec.rb
|
100
107
|
- spec/flip_spec.rb
|
101
108
|
- spec/spec_helper.rb
|
102
|
-
has_rdoc: true
|
103
109
|
homepage: https://github.com/pda/flip
|
104
110
|
licenses: []
|
105
111
|
post_install_message:
|
@@ -115,12 +121,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
115
121
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
116
122
|
none: false
|
117
123
|
requirements:
|
118
|
-
- - ! '
|
124
|
+
- - ! '>='
|
119
125
|
- !ruby/object:Gem::Version
|
120
|
-
version:
|
126
|
+
version: '0'
|
121
127
|
requirements: []
|
122
128
|
rubyforge_project: flip
|
123
|
-
rubygems_version: 1.
|
129
|
+
rubygems_version: 1.8.11
|
124
130
|
signing_key:
|
125
131
|
specification_version: 3
|
126
132
|
summary: A feature flipper for Rails web applications.
|