feature_gate 0.1.1 → 0.1.2
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.
- checksums.yaml +4 -4
- data/README.md +4 -0
- data/app/assets/stylesheets/feature_gate/application.scss.css +38 -0
- data/app/controllers/feature_gate/gated_features_controller.rb +23 -0
- data/app/views/feature_gate/gated_features/index.html.erb +35 -0
- data/app/views/layouts/feature_gate/application.html.erb +18 -0
- data/config/routes.rb +4 -2
- data/lib/feature_gate/engine.rb +5 -0
- data/lib/feature_gate/version.rb +1 -1
- data/lib/generators/feature_gate/feature_gate_generator.rb +1 -1
- data/lib/generators/feature_gate/templates/migration.rb +3 -3
- metadata +5 -3
- data/app/controllers/feature_gates_controller.rb +0 -8
- data/app/view/feature_gates/index.html.erb +0 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a55a3b7dcb354b59674d121dedd1817f9789cd65
|
4
|
+
data.tar.gz: 9368c51d64e9f7a9421c9e79d5bdf3d3114e7aff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7fcf931569a8629ee9d6b483086978624074714510e0d87ba519597a57fd4c3d216d6557dc24b45d19cba0896e18079a3dea5e190704f7c114eacd9e44fa6bcb
|
7
|
+
data.tar.gz: 1f1adde8b2ebf1a59412545adadad6dfe676f19f876506035450cffdeece7972a269dbcb1571e730046c9c7fbc86f587ef6f6273ea2f8ab829c0d476f166f072
|
data/README.md
CHANGED
@@ -16,6 +16,10 @@ Migrate to create the table in your DB:
|
|
16
16
|
|
17
17
|
rake db:migrate
|
18
18
|
|
19
|
+
Add to `config/routes.rb`
|
20
|
+
|
21
|
+
mount FeatureGate::Engine, at: '/feature_gate'
|
22
|
+
|
19
23
|
## Usage
|
20
24
|
|
21
25
|
All gates are closed by default, meaning the features you gate will be hidden until you toggle the gates open.
|
@@ -0,0 +1,38 @@
|
|
1
|
+
.content {
|
2
|
+
max-width: 1000px;
|
3
|
+
margin-left: auto;
|
4
|
+
margin-right: auto;
|
5
|
+
}
|
6
|
+
|
7
|
+
.alert-success {
|
8
|
+
background-color: #d2e7ba;
|
9
|
+
color: #24a318;
|
10
|
+
}
|
11
|
+
|
12
|
+
.alert-notice {
|
13
|
+
background-color: #eeeec7;
|
14
|
+
color: #72725f;
|
15
|
+
}
|
16
|
+
|
17
|
+
.alert-error {
|
18
|
+
background-color: #f6c8cd;
|
19
|
+
color: #e35d6a;
|
20
|
+
}
|
21
|
+
|
22
|
+
.alert {
|
23
|
+
border-radius: 5px;
|
24
|
+
margin-top: 10px;
|
25
|
+
padding: 10px;
|
26
|
+
}
|
27
|
+
|
28
|
+
body {
|
29
|
+
font-family: Helvetica, sans-serif;
|
30
|
+
}
|
31
|
+
|
32
|
+
ul {
|
33
|
+
list-style-type: none;
|
34
|
+
}
|
35
|
+
|
36
|
+
.gates {
|
37
|
+
margin-bottom: 25px;
|
38
|
+
}
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module FeatureGate
|
2
|
+
class GatedFeaturesController < ApplicationController
|
3
|
+
layout 'feature_gate/application'
|
4
|
+
|
5
|
+
def index
|
6
|
+
@closed_gates = FeatureGate::GatedFeature.closed
|
7
|
+
@opened_gates = FeatureGate::GatedFeature.opened
|
8
|
+
end
|
9
|
+
|
10
|
+
def update
|
11
|
+
gate = FeatureGate::GatedFeature.find(params[:id])
|
12
|
+
if params[:gated] == 'true'
|
13
|
+
gate.gate_feature!
|
14
|
+
flash[:notice] = 'Feature has been gated'
|
15
|
+
else
|
16
|
+
gate.deploy_feature!
|
17
|
+
flash[:success] = 'Feature is live!'
|
18
|
+
end
|
19
|
+
|
20
|
+
redirect_to gated_features_path
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
<h1>Feature Gates</h1>
|
2
|
+
|
3
|
+
<section class="gates">
|
4
|
+
<h3>Opened Gates</h3>
|
5
|
+
<% if @opened_gates.any? %>
|
6
|
+
<ul>
|
7
|
+
<% @opened_gates.each do |gate| %>
|
8
|
+
<li>
|
9
|
+
<%= gate.name %>
|
10
|
+
<%= link_to 'Close', gated_feature_path(gate, gated: true), method: :put, data: { confirm: "Shutting down #{gate.name}, are you sure?" } %>
|
11
|
+
</li>
|
12
|
+
<% end %>
|
13
|
+
</ul>
|
14
|
+
<% else %>
|
15
|
+
<em>No opened gates</em>
|
16
|
+
<% end %>
|
17
|
+
</section>
|
18
|
+
|
19
|
+
<hr>
|
20
|
+
|
21
|
+
<section class="gates">
|
22
|
+
<h3>Closed Gates</h3>
|
23
|
+
<% if @closed_gates.any? %>
|
24
|
+
<ul>
|
25
|
+
<% @closed_gates.each do |gate| %>
|
26
|
+
<li>
|
27
|
+
<%= gate.name %>
|
28
|
+
<%= link_to 'Open', gated_feature_path(gate, gated: false), method: :put, data: { confirm: "Deploying #{gate.name}, are you sure?" } %>
|
29
|
+
</li>
|
30
|
+
<% end %>
|
31
|
+
</ul>
|
32
|
+
<% else %>
|
33
|
+
<em>No closed gates</em>
|
34
|
+
<% end %>
|
35
|
+
</section>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
|
5
|
+
<title>FeatureGate</title>
|
6
|
+
<%= stylesheet_link_tag 'feature_gate/application.scss' %>
|
7
|
+
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
|
8
|
+
<%= csrf_meta_tags %>
|
9
|
+
</head>
|
10
|
+
<body>
|
11
|
+
<% flash.each do |key, value| %>
|
12
|
+
<div class="content alert alert-<%= key %>"><%= value %></div>
|
13
|
+
<% end %>
|
14
|
+
<div class="content">
|
15
|
+
<%= yield %>
|
16
|
+
</div>
|
17
|
+
</body>
|
18
|
+
</html>
|
data/config/routes.rb
CHANGED
data/lib/feature_gate/engine.rb
CHANGED
data/lib/feature_gate/version.rb
CHANGED
@@ -7,7 +7,7 @@ class FeatureGateGenerator < Rails::Generators::Base
|
|
7
7
|
desc 'creates gated_features table'
|
8
8
|
|
9
9
|
def install
|
10
|
-
migration_template 'migration.rb', 'db/migrate/
|
10
|
+
migration_template 'migration.rb', 'db/migrate/create_feature_gate_gated_features.rb'
|
11
11
|
end
|
12
12
|
|
13
13
|
def self.next_migration_number(dirname)
|
@@ -1,11 +1,11 @@
|
|
1
|
-
class
|
1
|
+
class CreateFeatureGateGatedFeatures < ActiveRecord::Migration
|
2
2
|
def change
|
3
|
-
create_table :
|
3
|
+
create_table :feature_gate_gated_features do |t|
|
4
4
|
t.text :name, null: false
|
5
5
|
t.boolean :gated, default: true, null: false
|
6
6
|
t.timestamps
|
7
7
|
end
|
8
8
|
|
9
|
-
add_index :
|
9
|
+
add_index :feature_gate_gated_features, :name, unique: true
|
10
10
|
end
|
11
11
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: feature_gate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tiffany Huang
|
@@ -77,10 +77,12 @@ files:
|
|
77
77
|
- Gemfile.lock
|
78
78
|
- LICENSE
|
79
79
|
- README.md
|
80
|
-
- app/
|
80
|
+
- app/assets/stylesheets/feature_gate/application.scss.css
|
81
|
+
- app/controllers/feature_gate/gated_features_controller.rb
|
81
82
|
- app/models/feature_gate/gated_feature.rb
|
82
83
|
- app/models/feature_gate/manager.rb
|
83
|
-
- app/
|
84
|
+
- app/views/feature_gate/gated_features/index.html.erb
|
85
|
+
- app/views/layouts/feature_gate/application.html.erb
|
84
86
|
- config/routes.rb
|
85
87
|
- feature_gate.gemspec
|
86
88
|
- lib/feature_gate.rb
|
@@ -1,23 +0,0 @@
|
|
1
|
-
<h1>Feature Gates</h1>
|
2
|
-
|
3
|
-
<h3>Opened Gates</h3>
|
4
|
-
<ul>
|
5
|
-
<% @gates.each do |gate| %>
|
6
|
-
<li>
|
7
|
-
<%= gate.name %>
|
8
|
-
<%= link_to 'Close', feature_gate_path(gate, gated: true), method: :put %>
|
9
|
-
</li>
|
10
|
-
<% end %>
|
11
|
-
</ul>
|
12
|
-
|
13
|
-
<hr>
|
14
|
-
|
15
|
-
<h3>Closed Gates</h3>
|
16
|
-
<ul>
|
17
|
-
<% @gates.each do |gate| %>
|
18
|
-
<li>
|
19
|
-
<%= gate.name %>
|
20
|
-
<%= link_to 'Open', feature_gate_path(gate, gated: false), method: :put %>
|
21
|
-
</li>
|
22
|
-
<% end %>
|
23
|
-
</ul>
|