plug 0.1.9 → 0.1.11
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 +43 -2
- data/app/assets/stylesheets/plug/application.scss +2 -1
- data/app/assets/stylesheets/plug/blocks/_nav.scss +3 -0
- data/app/assets/stylesheets/plug/blocks/_notice.scss +4 -0
- data/app/assets/stylesheets/plug/blocks/_state.scss +9 -0
- data/app/assets/stylesheets/plug/variables/_colors.scss +7 -5
- data/app/assets/stylesheets/plug/variables/_typography.scss +5 -1
- data/app/controllers/plug/features_controller.rb +6 -8
- data/app/views/plug/features/_form.html.haml +8 -2
- data/app/views/plug/features/edit.html.haml +1 -5
- data/app/views/plug/features/index.html.haml +15 -9
- data/app/views/plug/features/new.html.haml +3 -3
- data/app/views/plug/shared/_head.html.haml +3 -1
- data/app/views/plug/shared/_nav.html.haml +1 -1
- data/config/routes.rb +1 -1
- data/db/migrate/20180128202026_add_notice_to_plug_features.rb +5 -0
- data/lib/generators/plug/install_generator.rb +3 -3
- data/lib/plug.rb +32 -8
- data/lib/plug/configuration.rb +1 -1
- data/lib/plug/constraint.rb +1 -1
- data/lib/plug/version.rb +1 -1
- metadata +5 -5
- data/app/assets/stylesheets/plug/blocks/_plugs.scss +0 -17
- data/app/assets/stylesheets/plug/features.scss +0 -3
- data/app/views/plug/features/show.html.haml +0 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e1f4d0ccf9b5a963bf47b5ad06b51a717dfe87b7
|
4
|
+
data.tar.gz: 32be30ca94c6d54a846f1d8fc312f94e4c2537cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a0bd0322aef2ed5d88a4891fbc9b17e9a7f4fb8a337ae7ba67631e4a375df353f1eae3807a051f6432d9426f93a09f419beb058167a92687c3af372b24d8d9db
|
7
|
+
data.tar.gz: 66bcb2d3ef8cd2fd8352f4105ab54c89576b5eb8ab896578d530b5ef300667b7fc9aadb4c947a450d293bf29f7ca457a939ffffe37fde2c9efd8473ae099fcea
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# Plug [](https://codeclimate.com/github/DigitalNZ/plug/maintainability) [](https://codeclimate.com/github/DigitalNZ/plug/test_coverage) [](https://travis-ci.org/DigitalNZ/plug)
|
2
2
|
|
3
3
|
A Rails engine to turn on/off features (Feature flipper).
|
4
4
|
|
@@ -6,7 +6,7 @@ A Rails engine to turn on/off features (Feature flipper).
|
|
6
6
|
|
7
7
|
- Supports Rails 3 and above
|
8
8
|
- MySQL
|
9
|
-
- Set notices
|
9
|
+
- Set notices
|
10
10
|
|
11
11
|
### Prerequisites
|
12
12
|
|
@@ -55,6 +55,47 @@ Rails.application.routes.draw do
|
|
55
55
|
end
|
56
56
|
```
|
57
57
|
|
58
|
+
Notices can be displayed using the `Plug.notice` method.
|
59
|
+
|
60
|
+
```erb
|
61
|
+
<%= Plug.notice('my-awesome-feature-slug') %>
|
62
|
+
```
|
63
|
+
|
64
|
+
If you have custom HTML for notice, you can pass a block.
|
65
|
+
|
66
|
+
|
67
|
+
```erb
|
68
|
+
<% Plug.notice('my-awesome-feature-slug') do |notice| %>
|
69
|
+
<div class="alert">
|
70
|
+
<p><%= notice %></p>
|
71
|
+
</div>
|
72
|
+
<% end %>
|
73
|
+
```
|
74
|
+
|
75
|
+
### Running the tests
|
76
|
+
|
77
|
+
```bash
|
78
|
+
→ bundle exec rspec spec
|
79
|
+
```
|
80
|
+
|
81
|
+
### Publishing to `rubygems.org`
|
82
|
+
|
83
|
+
Make sure to bump the version. Rubygems don't accept version overrides.
|
84
|
+
|
85
|
+
```bash
|
86
|
+
→ gem build plug.gemspec
|
87
|
+
→ gem push plug-<version>.gem
|
88
|
+
```
|
89
|
+
|
90
|
+
### TODOs
|
91
|
+
|
92
|
+
- Ability to disable all features using one button
|
93
|
+
- Add screenshot
|
94
|
+
- Allow block parameters for `enabled?` method
|
95
|
+
- Versioning of features
|
96
|
+
- History of feature activities
|
97
|
+
|
98
|
+
|
58
99
|
### Questions/Issues?
|
59
100
|
|
60
101
|
File a new [issue](https://github.com/boost/plug/issues/new) if you have questions or issues.
|
@@ -3,9 +3,9 @@ require_dependency 'plug/application_controller'
|
|
3
3
|
module Plug
|
4
4
|
class FeaturesController < ApplicationController
|
5
5
|
if Rails.version.to_i < 5
|
6
|
-
before_filter :set_feature, only: [:
|
6
|
+
before_filter :set_feature, only: [:edit, :update, :destroy]
|
7
7
|
else
|
8
|
-
before_action :set_feature, only: [:
|
8
|
+
before_action :set_feature, only: [:edit, :update, :destroy]
|
9
9
|
end
|
10
10
|
|
11
11
|
# GET /features
|
@@ -14,8 +14,7 @@ module Plug
|
|
14
14
|
end
|
15
15
|
|
16
16
|
# GET /features/1
|
17
|
-
def show
|
18
|
-
end
|
17
|
+
# def show; end
|
19
18
|
|
20
19
|
# GET /features/new
|
21
20
|
def new
|
@@ -23,15 +22,14 @@ module Plug
|
|
23
22
|
end
|
24
23
|
|
25
24
|
# GET /features/1/edit
|
26
|
-
def edit
|
27
|
-
end
|
25
|
+
def edit; end
|
28
26
|
|
29
27
|
# POST /features
|
30
28
|
def create
|
31
29
|
@feature = Feature.new(feature_params)
|
32
30
|
|
33
31
|
if @feature.save
|
34
|
-
redirect_to
|
32
|
+
redirect_to features_path, notice: 'Feature was successfully created.'
|
35
33
|
else
|
36
34
|
render :new
|
37
35
|
end
|
@@ -40,7 +38,7 @@ module Plug
|
|
40
38
|
# PATCH/PUT /features/1
|
41
39
|
def update
|
42
40
|
if @feature.update_attributes(feature_params)
|
43
|
-
redirect_to
|
41
|
+
redirect_to features_path, notice: 'Feature was successfully updated.'
|
44
42
|
else
|
45
43
|
render :edit
|
46
44
|
end
|
@@ -12,8 +12,14 @@
|
|
12
12
|
.field
|
13
13
|
= f.label :description
|
14
14
|
= f.text_area :description, rows: 5
|
15
|
+
.field
|
16
|
+
= f.label :notice
|
17
|
+
= f.text_area :notice, rows: 10
|
15
18
|
.field
|
16
19
|
= f.label :state
|
17
20
|
= f.select :state, ['enabled', 'disabled']
|
18
|
-
.actions
|
19
|
-
|
21
|
+
.actions.clearfix
|
22
|
+
.float-left
|
23
|
+
= link_to 'Back', features_path, class: 'button'
|
24
|
+
.float-right
|
25
|
+
= f.submit 'Save'
|
@@ -1,6 +1,13 @@
|
|
1
1
|
.row
|
2
2
|
.column
|
3
|
-
|
3
|
+
- if notice
|
4
|
+
%p.notice= notice
|
5
|
+
|
6
|
+
.clearfix
|
7
|
+
.float-left
|
8
|
+
%h4 Features
|
9
|
+
.float-right
|
10
|
+
= link_to 'New Feature', new_feature_path, class: 'button'
|
4
11
|
|
5
12
|
%table
|
6
13
|
%thead
|
@@ -9,21 +16,20 @@
|
|
9
16
|
%th Description
|
10
17
|
%th Slug
|
11
18
|
%th State
|
12
|
-
%th
|
13
|
-
%th
|
14
|
-
%th
|
15
19
|
|
16
20
|
%tbody
|
17
21
|
- @features.each do |feature|
|
18
22
|
%tr
|
19
|
-
%td= feature.name
|
23
|
+
%td= link_to feature.name, edit_feature_path(feature), class: 'strong'
|
20
24
|
%td= feature.description
|
21
25
|
%td= feature.slug
|
22
|
-
%td
|
23
|
-
|
24
|
-
|
26
|
+
%td
|
27
|
+
- if feature.state == 'enabled'
|
28
|
+
%i.fas.fa-check-circle.fa-2x.state__enabled
|
29
|
+
- else
|
30
|
+
%i.fas.fa-times-circle.fa-2x.state__disabled
|
25
31
|
|
26
32
|
- if Plug.allow_delete
|
27
33
|
%td= link_to 'Destroy', feature, method: :delete, data: { confirm: 'Are you sure?' }
|
28
34
|
|
29
|
-
|
35
|
+
|
data/config/routes.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
module Plug
|
2
2
|
class InstallGenerator < Rails::Generators::Base
|
3
|
-
source_root File.expand_path(
|
3
|
+
source_root File.expand_path('../templates', __FILE__)
|
4
4
|
|
5
5
|
def copy_initializer_file
|
6
6
|
copy_file 'plug.rb', 'config/initializers/plug.rb'
|
7
7
|
end
|
8
8
|
|
9
9
|
def mount_engine
|
10
|
-
inject_into_file('config/routes.rb', "\n mount Plug::Engine => '/plug', as: 'plug'\n\n", :
|
10
|
+
inject_into_file('config/routes.rb', "\n mount Plug::Engine => '/plug', as: 'plug'\n\n", before: /^end/)
|
11
11
|
end
|
12
12
|
end
|
13
|
-
end
|
13
|
+
end
|
data/lib/plug.rb
CHANGED
@@ -6,18 +6,42 @@ module Plug
|
|
6
6
|
extend self
|
7
7
|
extend Configuration
|
8
8
|
|
9
|
-
#
|
9
|
+
#
|
10
10
|
# [enabled? returns true of false]
|
11
11
|
# @param arg [String, Symbol] The slug or name of the Feature
|
12
|
-
#
|
13
|
-
# @return [Boolean] true -
|
12
|
+
#
|
13
|
+
# @return [Boolean] true - Feature found and enabled | true - Feature not found (We don't want to block) | false - Feature was set to disabled
|
14
14
|
def enabled?(arg)
|
15
|
-
|
16
|
-
feature = Plug::Feature.slug_and_name(arg).first
|
17
|
-
|
18
|
-
return true unless feature
|
19
|
-
return feature.enabled?
|
15
|
+
return get_feature(arg).enabled?
|
20
16
|
rescue
|
21
17
|
return true
|
22
18
|
end
|
19
|
+
|
20
|
+
#
|
21
|
+
# Returns the notice of a given Feature
|
22
|
+
# @param arg [String] The slug or name of the Feature
|
23
|
+
# @param &block [Proc] The block of HTML/String for the notice
|
24
|
+
#
|
25
|
+
# @return [String] The block of HTML/String with notice
|
26
|
+
def notice(arg, &block)
|
27
|
+
feature = get_feature(arg)
|
28
|
+
|
29
|
+
render_notice(feature.notice, &block) unless feature.enabled? || feature.notice.blank?
|
30
|
+
rescue
|
31
|
+
return nil
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
def get_feature(arg)
|
37
|
+
arg = arg.to_s if arg.is_a? Symbol
|
38
|
+
|
39
|
+
return Plug::Feature.slug_and_name(arg).first
|
40
|
+
end
|
41
|
+
|
42
|
+
def render_notice(notice, &block)
|
43
|
+
return notice unless block_given?
|
44
|
+
|
45
|
+
yield(notice)
|
46
|
+
end
|
23
47
|
end
|
data/lib/plug/configuration.rb
CHANGED
data/lib/plug/constraint.rb
CHANGED
data/lib/plug/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: plug
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2018-02-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -196,8 +196,8 @@ files:
|
|
196
196
|
- app/assets/stylesheets/plug/_settings.scss
|
197
197
|
- app/assets/stylesheets/plug/application.scss
|
198
198
|
- app/assets/stylesheets/plug/blocks/_nav.scss
|
199
|
-
- app/assets/stylesheets/plug/blocks/
|
200
|
-
- app/assets/stylesheets/plug/
|
199
|
+
- app/assets/stylesheets/plug/blocks/_notice.scss
|
200
|
+
- app/assets/stylesheets/plug/blocks/_state.scss
|
201
201
|
- app/assets/stylesheets/plug/foundation_and_overrides.scss
|
202
202
|
- app/assets/stylesheets/plug/milligram.scss
|
203
203
|
- app/assets/stylesheets/plug/mixins/_bem.scss
|
@@ -217,11 +217,11 @@ files:
|
|
217
217
|
- app/views/plug/features/edit.html.haml
|
218
218
|
- app/views/plug/features/index.html.haml
|
219
219
|
- app/views/plug/features/new.html.haml
|
220
|
-
- app/views/plug/features/show.html.haml
|
221
220
|
- app/views/plug/shared/_head.html.haml
|
222
221
|
- app/views/plug/shared/_nav.html.haml
|
223
222
|
- config/routes.rb
|
224
223
|
- db/migrate/20171207020316_create_plug_features.rb
|
224
|
+
- db/migrate/20180128202026_add_notice_to_plug_features.rb
|
225
225
|
- lib/generators/plug/install_generator.rb
|
226
226
|
- lib/generators/plug/templates/plug.rb
|
227
227
|
- lib/plug.rb
|
@@ -1,17 +0,0 @@
|
|
1
|
-
.plugs {
|
2
|
-
margin-top: 2rem;
|
3
|
-
|
4
|
-
@include element('content') {
|
5
|
-
background: $white;
|
6
|
-
border: 1px solid $gallery;
|
7
|
-
|
8
|
-
@include element('item') {
|
9
|
-
padding: .5rem;
|
10
|
-
border-bottom: 1px solid $gallery;
|
11
|
-
|
12
|
-
&:last-of-type {
|
13
|
-
border-bottom: none;
|
14
|
-
}
|
15
|
-
}
|
16
|
-
}
|
17
|
-
}
|
@@ -1,20 +0,0 @@
|
|
1
|
-
.row
|
2
|
-
.column
|
3
|
-
%p#notice= notice
|
4
|
-
|
5
|
-
%p
|
6
|
-
%b Name:
|
7
|
-
= @feature.name
|
8
|
-
%p
|
9
|
-
%b Description:
|
10
|
-
= @feature.description
|
11
|
-
%p
|
12
|
-
%b Slug:
|
13
|
-
= @feature.slug
|
14
|
-
%p
|
15
|
-
%b State:
|
16
|
-
= @feature.state
|
17
|
-
|
18
|
-
= link_to 'Edit', edit_feature_path(@feature), class: 'button'
|
19
|
-
\|
|
20
|
-
= link_to 'Back', features_path, class: 'button'
|