feature_gate 0.1.3 → 0.1.4
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 +12 -0
- data/app/assets/stylesheets/feature_gate/application.scss.css +13 -0
- data/app/controllers/feature_gate/gated_features_controller.rb +1 -0
- data/app/models/feature_gate/cleaner.rb +7 -0
- data/app/models/feature_gate/gated_feature.rb +9 -0
- data/app/models/feature_gate/manager.rb +4 -0
- data/app/views/feature_gate/gated_features/index.html.erb +47 -14
- data/bin/feature_gate +5 -0
- data/feature_gate.gemspec +1 -0
- data/lib/feature_gate/version.rb +1 -1
- data/lib/feature_gate.rb +5 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 822d2404bcfa793c80f23f9bfbb5b2496f3f0e1b
|
4
|
+
data.tar.gz: 76c0dabcb6a31476ae64d9a3c330edc8a4628d42
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ddfde61be9c56acd921a486dee0cad63902c7c5966da5a5215d6e6e6dcfde621a97f196ce2105af8bc0861079360f5a84e70114151ddfb399601a38cebad2544
|
7
|
+
data.tar.gz: fe68b7c4ed06b4c1344a300b7562e0ce24fc061077a05c5728de67f13d61ddd3dbd19ef124fad4aff0cb618e9d6f798027b435025029cfd948959f16ba665742
|
data/README.md
CHANGED
@@ -20,6 +20,14 @@ Add to `config/routes.rb`
|
|
20
20
|
|
21
21
|
mount FeatureGate::Engine, at: '/feature_gate'
|
22
22
|
|
23
|
+
## Optional Configurations
|
24
|
+
|
25
|
+
Add `config/initializers/feature_gate.rb`
|
26
|
+
|
27
|
+
FeatureGate.setup do |config|
|
28
|
+
config.time_to_stale = 2.weeks # time until a gate is listed as stale, default is 1 month.
|
29
|
+
end
|
30
|
+
|
23
31
|
## Usage
|
24
32
|
|
25
33
|
### Gating features
|
@@ -70,3 +78,7 @@ To see the names of all opened gates:
|
|
70
78
|
To see the names of all closed gates:
|
71
79
|
|
72
80
|
FeatureGate::Manager.closed_gates
|
81
|
+
|
82
|
+
To see the names of all stale gates:
|
83
|
+
|
84
|
+
FeatureGate::Manager.stale_gates
|
@@ -5,6 +5,7 @@ module FeatureGate
|
|
5
5
|
|
6
6
|
scope :opened, -> { where(gated: false) }
|
7
7
|
scope :closed, -> { where(gated: true) }
|
8
|
+
scope :stale, -> { where('updated_at != created_at and updated_at < ?', Time.zone.now - FeatureGate.time_to_stale) }
|
8
9
|
|
9
10
|
def deploy_feature!
|
10
11
|
self.gated = false
|
@@ -15,5 +16,13 @@ module FeatureGate
|
|
15
16
|
self.gated = true
|
16
17
|
save!
|
17
18
|
end
|
19
|
+
|
20
|
+
def status
|
21
|
+
if gated
|
22
|
+
'closed'
|
23
|
+
else
|
24
|
+
'opened'
|
25
|
+
end
|
26
|
+
end
|
18
27
|
end
|
19
28
|
end
|
@@ -3,33 +3,66 @@
|
|
3
3
|
<section class="gates">
|
4
4
|
<h3>Opened Gates</h3>
|
5
5
|
<% if @opened_gates.any? %>
|
6
|
-
<
|
6
|
+
<table>
|
7
|
+
<tr>
|
8
|
+
<th>Gate name</th>
|
9
|
+
<th>Action</th>
|
10
|
+
</tr>
|
11
|
+
|
7
12
|
<% @opened_gates.each do |gate| %>
|
8
|
-
<
|
9
|
-
|
10
|
-
|
11
|
-
</
|
13
|
+
<tr>
|
14
|
+
<td><%= gate.name %></td>
|
15
|
+
<td><%= link_to 'Close', gated_feature_path(gate, gated: true), method: :put, data: { confirm: "Shutting down #{gate.name}, are you sure?" } %></td>
|
16
|
+
</tr>
|
12
17
|
<% end %>
|
13
|
-
</
|
18
|
+
</table>
|
14
19
|
<% else %>
|
15
20
|
<em>No opened gates</em>
|
16
21
|
<% end %>
|
17
22
|
</section>
|
18
23
|
|
19
|
-
<hr>
|
20
|
-
|
21
24
|
<section class="gates">
|
22
25
|
<h3>Closed Gates</h3>
|
23
26
|
<% if @closed_gates.any? %>
|
24
|
-
<
|
27
|
+
<table>
|
28
|
+
<tr>
|
29
|
+
<th>Gate name</th>
|
30
|
+
<th>Action</th>
|
31
|
+
</tr>
|
32
|
+
|
25
33
|
<% @closed_gates.each do |gate| %>
|
26
|
-
<
|
27
|
-
|
28
|
-
|
29
|
-
</
|
34
|
+
<tr>
|
35
|
+
<td><%= gate.name %></td>
|
36
|
+
<td><%= link_to 'Open', gated_feature_path(gate, gated: false), method: :put, data: { confirm: "Deploying #{gate.name}, are you sure?" } %></td>
|
37
|
+
</tr>
|
30
38
|
<% end %>
|
31
|
-
</
|
39
|
+
</table>
|
32
40
|
<% else %>
|
33
41
|
<em>No closed gates</em>
|
34
42
|
<% end %>
|
35
43
|
</section>
|
44
|
+
|
45
|
+
<hr>
|
46
|
+
|
47
|
+
<section class="gates">
|
48
|
+
<h3>Stale Gates</h3>
|
49
|
+
<% if @stale_gates.any? %>
|
50
|
+
<table>
|
51
|
+
<tr>
|
52
|
+
<th>Gate name</th>
|
53
|
+
<th>Status</th>
|
54
|
+
<th>Last updated at</th>
|
55
|
+
</tr>
|
56
|
+
|
57
|
+
<% @stale_gates.each do |gate| %>
|
58
|
+
<tr>
|
59
|
+
<td><%= gate.name %></td>
|
60
|
+
<td><%= gate.status %></td>
|
61
|
+
<td><%= gate.updated_at.strftime('%F') %></td>
|
62
|
+
</tr>
|
63
|
+
<% end %>
|
64
|
+
</table>
|
65
|
+
<% else %>
|
66
|
+
<em>No stale gates</em>
|
67
|
+
<% end %>
|
68
|
+
</section>
|
data/bin/feature_gate
ADDED
data/feature_gate.gemspec
CHANGED
@@ -13,6 +13,7 @@ Gem::Specification.new do |s|
|
|
13
13
|
s.homepage = 'https://github.com/tiffling/feature_gate'
|
14
14
|
s.license = 'MIT'
|
15
15
|
s.require_paths = ['lib']
|
16
|
+
s.executables = ['feature_gate']
|
16
17
|
|
17
18
|
s.add_dependency 'rails', '~> 4.0'
|
18
19
|
s.add_development_dependency('sqlite3', '~> 1.3')
|
data/lib/feature_gate/version.rb
CHANGED
data/lib/feature_gate.rb
CHANGED
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.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tiffany Huang
|
@@ -68,7 +68,8 @@ dependencies:
|
|
68
68
|
version: '4.5'
|
69
69
|
description: A gem to toggle feature gates on and off
|
70
70
|
email: little.huang@gmail.com
|
71
|
-
executables:
|
71
|
+
executables:
|
72
|
+
- feature_gate
|
72
73
|
extensions: []
|
73
74
|
extra_rdoc_files: []
|
74
75
|
files:
|
@@ -79,10 +80,12 @@ files:
|
|
79
80
|
- README.md
|
80
81
|
- app/assets/stylesheets/feature_gate/application.scss.css
|
81
82
|
- app/controllers/feature_gate/gated_features_controller.rb
|
83
|
+
- app/models/feature_gate/cleaner.rb
|
82
84
|
- app/models/feature_gate/gated_feature.rb
|
83
85
|
- app/models/feature_gate/manager.rb
|
84
86
|
- app/views/feature_gate/gated_features/index.html.erb
|
85
87
|
- app/views/layouts/feature_gate/application.html.erb
|
88
|
+
- bin/feature_gate
|
86
89
|
- config/routes.rb
|
87
90
|
- feature_gate.gemspec
|
88
91
|
- lib/feature_gate.rb
|