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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7259997f1fd944568830eb15be2a2c616a9f9676
4
- data.tar.gz: d38322d5a987e1b53027573eff2c16d6e7f98000
3
+ metadata.gz: a55a3b7dcb354b59674d121dedd1817f9789cd65
4
+ data.tar.gz: 9368c51d64e9f7a9421c9e79d5bdf3d3114e7aff
5
5
  SHA512:
6
- metadata.gz: 97064fcc931679b24154b8da943e5f72319598ea52e8bf34157180a00117cd4ab8efa5eac2bf90d22cd1d3b9954d5673af83102b76ca2717caf33557739f9f1b
7
- data.tar.gz: 0f3dfe2af42ef9ea9353a927b566f1b2c37ebb46c898aaa7e19002e5ad50bea9265f06e9ec3745dfceaf8a55a64fb10f034c74084e562a9bb1728b40f47f1410
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 %>&nbsp;
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
@@ -1,3 +1,5 @@
1
- Rails.application.routes.draw do
2
- resources :feature_gates, only: [:index, :update]
1
+ FeatureGate::Engine.routes.draw do
2
+ resources :gated_features, only: [:index, :update]
3
+
4
+ root to: 'gated_features#index'
3
5
  end
@@ -1,4 +1,9 @@
1
1
  module FeatureGate
2
2
  class Engine < Rails::Engine
3
+ isolate_namespace FeatureGate
4
+
5
+ initializer 'feature_gate.assets.precompile' do |app|
6
+ app.config.assets.precompile += %w(feature_gate/application.scss.css)
7
+ end
3
8
  end
4
9
  end
@@ -1,3 +1,3 @@
1
1
  module FeatureGate
2
- VERSION = '0.1.1'.freeze
2
+ VERSION = '0.1.2'.freeze
3
3
  end
@@ -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/create_gated_features.rb'
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 CreateGatedFeatures < ActiveRecord::Migration
1
+ class CreateFeatureGateGatedFeatures < ActiveRecord::Migration
2
2
  def change
3
- create_table :gated_features do |t|
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 :gated_features, :name, unique: true
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.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/controllers/feature_gates_controller.rb
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/view/feature_gates/index.html.erb
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,8 +0,0 @@
1
- class FeatureGatesController < ::ApplicationController
2
- def index
3
- @gates = FeatureGate::GatedFeature.all
4
- end
5
-
6
- def update
7
- end
8
- end
@@ -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>