plug 0.1.23 → 0.1.24
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 +1 -1
- data/Rakefile +3 -1
- data/app/controllers/plug/api/api_controller.rb +2 -0
- data/app/controllers/plug/api/site_notices_controller.rb +2 -0
- data/app/controllers/plug/application_controller.rb +3 -3
- data/app/controllers/plug/features_controller.rb +13 -19
- data/app/controllers/plug/site_notices_controller.rb +13 -19
- data/app/helpers/plug/application_helper.rb +2 -0
- data/app/mailers/plug/application_mailer.rb +2 -0
- data/app/models/plug/application_record.rb +2 -0
- data/app/models/plug/concerns/model_helpers.rb +6 -5
- data/app/models/plug/feature.rb +2 -0
- data/app/models/plug/resources/site_notice.rb +2 -0
- data/app/models/plug/site_notice.rb +2 -0
- data/app/services/plug/task_execution_service.rb +2 -0
- data/config/routes.rb +2 -0
- data/db/migrate/20180424015828_add_theme_to_plug_site_notice.rb +2 -0
- data/lib/generators/plug/install_generator.rb +3 -1
- data/lib/plug.rb +15 -13
- data/lib/plug/configuration.rb +11 -9
- data/lib/plug/constraint.rb +4 -2
- data/lib/plug/engine.rb +4 -0
- data/lib/plug/version.rb +3 -1
- data/lib/tasks/plug_tasks.rake +1 -0
- metadata +27 -28
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b83146ab631927c0756e4f9e1db5224b731e7ff6f3cb34504cc52f687c0294de
|
4
|
+
data.tar.gz: 8cb113cc3497c15054b62198c7fb8ab66583ace08b346481eac56e6d467b36eb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0a1fc2650f634afa48066f635f1c911248a684074243afdacb27a679191a7ad8d6330c8c479825b7a5cdfd59d70409430d4ea615ed426bf0475d48bfba88a3ea
|
7
|
+
data.tar.gz: b7cc1b56cd7d2da25f23012f76ecf773b59366fdb37bb5614cb08b5e1391982e0e38d8abe33efee817c7b6b03a05b5e4d0a0e5ea55b039e1c39f7d781de267cf
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Plug [](https://codeclimate.com/github/DigitalNZ/plug/maintainability)
|
1
|
+
# Plug [](https://codeclimate.com/github/DigitalNZ/plug/maintainability)
|
2
2
|
|
3
3
|
A Rails engine to turn on/off features (Feature flipper).
|
4
4
|
|
data/Rakefile
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
begin
|
2
4
|
require 'bundler/setup'
|
3
5
|
rescue LoadError
|
@@ -14,7 +16,7 @@ RDoc::Task.new(:rdoc) do |rdoc|
|
|
14
16
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
17
|
end
|
16
18
|
|
17
|
-
APP_RAKEFILE = File.expand_path('
|
19
|
+
APP_RAKEFILE = File.expand_path('spec/dummy/Rakefile', __dir__)
|
18
20
|
load 'rails/tasks/engine.rake'
|
19
21
|
|
20
22
|
load 'rails/tasks/statistics.rake'
|
@@ -1,11 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Plug
|
2
4
|
class ApplicationController < ActionController::Base
|
3
5
|
protect_from_forgery with: :exception
|
4
6
|
|
5
7
|
content_security_policy false
|
6
8
|
|
7
|
-
if Plug.auth_user.present? && Plug.auth_password.present?
|
8
|
-
http_basic_authenticate_with name: Plug.auth_user, password: Plug.auth_password
|
9
|
-
end
|
9
|
+
http_basic_authenticate_with name: Plug.auth_user, password: Plug.auth_password if Plug.auth_user.present? && Plug.auth_password.present?
|
10
10
|
end
|
11
11
|
end
|
@@ -1,12 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_dependency 'plug/application_controller'
|
2
4
|
|
3
5
|
module Plug
|
4
6
|
class FeaturesController < ApplicationController
|
5
|
-
|
6
|
-
before_filter :set_feature, only: [:edit, :update, :destroy]
|
7
|
-
else
|
8
|
-
before_action :set_feature, only: [:edit, :update, :destroy]
|
9
|
-
end
|
7
|
+
before_action :set_feature, only: %i[edit update destroy]
|
10
8
|
|
11
9
|
# GET /features
|
12
10
|
def index
|
@@ -37,7 +35,7 @@ module Plug
|
|
37
35
|
|
38
36
|
# PATCH/PUT /features/1
|
39
37
|
def update
|
40
|
-
if @feature.
|
38
|
+
if @feature.update(feature_params)
|
41
39
|
redirect_to features_path, notice: 'Feature was successfully updated.'
|
42
40
|
else
|
43
41
|
render :edit
|
@@ -65,19 +63,15 @@ module Plug
|
|
65
63
|
end
|
66
64
|
|
67
65
|
private
|
68
|
-
# Use callbacks to share common setup or constraints between actions.
|
69
|
-
def set_feature
|
70
|
-
@feature = Feature.find(params[:id])
|
71
|
-
end
|
72
66
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
67
|
+
# Use callbacks to share common setup or constraints between actions.
|
68
|
+
def set_feature
|
69
|
+
@feature = Feature.find(params[:id])
|
70
|
+
end
|
71
|
+
|
72
|
+
# Only allow a trusted parameter "white list" through.
|
73
|
+
def feature_params
|
74
|
+
params.require(:feature).permit(:name, :description, :state, :notice)
|
75
|
+
end
|
82
76
|
end
|
83
77
|
end
|
@@ -1,12 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_dependency 'plug/application_controller'
|
2
4
|
|
3
5
|
module Plug
|
4
6
|
class SiteNoticesController < ApplicationController
|
5
|
-
|
6
|
-
before_filter :set_site_notice, only: [:edit, :update, :destroy]
|
7
|
-
else
|
8
|
-
before_action :set_site_notice, only: [:edit, :update, :destroy]
|
9
|
-
end
|
7
|
+
before_action :set_site_notice, only: %i[edit update destroy]
|
10
8
|
|
11
9
|
# GET /site_notices
|
12
10
|
def index
|
@@ -37,7 +35,7 @@ module Plug
|
|
37
35
|
|
38
36
|
# PATCH/PUT /site_notices/1
|
39
37
|
def update
|
40
|
-
if @site_notice.
|
38
|
+
if @site_notice.update(site_notice_params)
|
41
39
|
redirect_to site_notices_path, notice: 'Site Notice was successfully updated.'
|
42
40
|
else
|
43
41
|
render :edit
|
@@ -51,19 +49,15 @@ module Plug
|
|
51
49
|
end
|
52
50
|
|
53
51
|
private
|
54
|
-
# Use callbacks to share common setup or constraints between actions.
|
55
|
-
def set_site_notice
|
56
|
-
@site_notice = SiteNotice.find(params[:id])
|
57
|
-
end
|
58
52
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
53
|
+
# Use callbacks to share common setup or constraints between actions.
|
54
|
+
def set_site_notice
|
55
|
+
@site_notice = SiteNotice.find(params[:id])
|
56
|
+
end
|
57
|
+
|
58
|
+
# Only allow a trusted parameter "white list" through.
|
59
|
+
def site_notice_params
|
60
|
+
params.require(:site_notice).permit(:name, :notice, :state, :theme)
|
61
|
+
end
|
68
62
|
end
|
69
63
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'active_support/concern'
|
2
4
|
|
3
5
|
module Plug
|
@@ -9,9 +11,9 @@ module Plug
|
|
9
11
|
include AASM
|
10
12
|
|
11
13
|
# Validations
|
12
|
-
validates :name, presence: { message: "#{
|
13
|
-
uniqueness: { message: "#{
|
14
|
-
validates :state, presence: { message: "#{
|
14
|
+
validates :name, presence: { message: "#{humanized_class_name} name is required" },
|
15
|
+
uniqueness: { message: "#{humanized_class_name} name must be unique", case_sensitive: false }
|
16
|
+
validates :state, presence: { message: "#{humanized_class_name} state is required" }
|
15
17
|
|
16
18
|
# Callbacks
|
17
19
|
before_save { self.slug = name.parameterize }
|
@@ -32,12 +34,11 @@ module Plug
|
|
32
34
|
transitions from: :enabled, to: :disabled
|
33
35
|
end
|
34
36
|
end
|
35
|
-
|
36
37
|
end
|
37
38
|
|
38
39
|
module ClassMethods
|
39
40
|
def humanized_class_name
|
40
|
-
|
41
|
+
name.demodulize.underscore.humanize.capitalize
|
41
42
|
end
|
42
43
|
end
|
43
44
|
end
|
data/app/models/plug/feature.rb
CHANGED
data/config/routes.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Plug
|
2
4
|
class InstallGenerator < Rails::Generators::Base
|
3
|
-
source_root File.expand_path('
|
5
|
+
source_root File.expand_path('templates', __dir__)
|
4
6
|
|
5
7
|
def copy_initializer_file
|
6
8
|
copy_file 'plug.rb', 'config/initializers/plug.rb'
|
data/lib/plug.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'plug/engine'
|
2
4
|
require 'plug/configuration'
|
3
5
|
require 'plug/constraint'
|
@@ -12,9 +14,9 @@ module Plug
|
|
12
14
|
#
|
13
15
|
# @return [Boolean] true - Feature found and enabled | true - Feature not found (We don't want to block) | false - Feature was set to disabled
|
14
16
|
def enabled?(arg)
|
15
|
-
|
16
|
-
rescue
|
17
|
-
|
17
|
+
get_feature(arg).enabled?
|
18
|
+
rescue StandardError
|
19
|
+
true
|
18
20
|
end
|
19
21
|
|
20
22
|
#
|
@@ -27,21 +29,21 @@ module Plug
|
|
27
29
|
feature = get_feature(arg)
|
28
30
|
|
29
31
|
render_notice(feature.notice, &block) unless feature.enabled? || feature.notice.blank?
|
30
|
-
rescue
|
31
|
-
|
32
|
+
rescue StandardError
|
33
|
+
nil
|
32
34
|
end
|
33
35
|
|
34
36
|
private
|
35
37
|
|
36
|
-
|
37
|
-
|
38
|
+
def get_feature(arg)
|
39
|
+
arg = arg.to_s if arg.is_a? Symbol
|
38
40
|
|
39
|
-
|
40
|
-
|
41
|
+
return Plug::Feature.slug_and_name(arg).first
|
42
|
+
end
|
41
43
|
|
42
|
-
|
43
|
-
|
44
|
+
def render_notice(notice, &block)
|
45
|
+
return notice unless block_given?
|
44
46
|
|
45
|
-
|
46
|
-
|
47
|
+
yield(notice)
|
48
|
+
end
|
47
49
|
end
|
data/lib/plug/configuration.rb
CHANGED
@@ -1,26 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Plug
|
2
4
|
module Configuration
|
3
5
|
AUTH_USER = ''
|
4
6
|
AUTH_PASSWORD = ''
|
5
7
|
ALLOW_DELETE = true
|
6
8
|
|
7
|
-
VALID_OPTIONS_KEYS = [
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
9
|
+
VALID_OPTIONS_KEYS = %i[
|
10
|
+
auth_user
|
11
|
+
auth_password
|
12
|
+
allow_delete
|
13
|
+
buttons
|
14
|
+
api_path
|
15
|
+
themes
|
14
16
|
].freeze
|
15
17
|
|
16
|
-
attr_accessor
|
18
|
+
attr_accessor(*VALID_OPTIONS_KEYS)
|
17
19
|
|
18
20
|
def configure
|
19
21
|
yield self
|
20
22
|
end
|
21
23
|
|
22
24
|
def options
|
23
|
-
Hash[
|
25
|
+
Hash[* VALID_OPTIONS_KEYS.map { |key| [key, send(key)] }.flatten]
|
24
26
|
end
|
25
27
|
end
|
26
28
|
end
|
data/lib/plug/constraint.rb
CHANGED
@@ -1,12 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Plug
|
2
4
|
class Constraint
|
3
5
|
def initialize(feature)
|
4
6
|
@feature = feature
|
5
7
|
end
|
6
8
|
|
7
|
-
def matches?(
|
9
|
+
def matches?(_request)
|
8
10
|
Plug.enabled?(@feature)
|
9
|
-
rescue
|
11
|
+
rescue StandardError
|
10
12
|
true
|
11
13
|
end
|
12
14
|
end
|
data/lib/plug/engine.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Require engine dependencies
|
2
4
|
require 'haml-rails'
|
3
5
|
require 'aasm'
|
@@ -9,6 +11,8 @@ module Plug
|
|
9
11
|
|
10
12
|
config.generators do |g|
|
11
13
|
g.test_framework :rspec
|
14
|
+
g.fixture_replacement :factory_bot
|
15
|
+
g.factory_bot dir: 'spec/factories'
|
12
16
|
end
|
13
17
|
end
|
14
18
|
end
|
data/lib/plug/version.rb
CHANGED
data/lib/tasks/plug_tasks.rake
CHANGED
metadata
CHANGED
@@ -1,18 +1,18 @@
|
|
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.24
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
- Ben
|
8
7
|
- Boost
|
8
|
+
- DNZ
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2021-
|
12
|
+
date: 2021-07-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
15
|
+
name: aasm
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
18
|
- - ">="
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: '0'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
|
-
name:
|
29
|
+
name: activeresource
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
32
|
- - ">="
|
@@ -40,7 +40,7 @@ dependencies:
|
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '0'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
|
-
name:
|
43
|
+
name: haml-rails
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
46
|
- - ">="
|
@@ -54,7 +54,7 @@ dependencies:
|
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: '0'
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
|
-
name:
|
57
|
+
name: jquery-rails
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
59
59
|
requirements:
|
60
60
|
- - ">="
|
@@ -68,21 +68,21 @@ dependencies:
|
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: '0'
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
|
-
name:
|
71
|
+
name: rails
|
72
72
|
requirement: !ruby/object:Gem::Requirement
|
73
73
|
requirements:
|
74
74
|
- - ">="
|
75
75
|
- !ruby/object:Gem::Version
|
76
|
-
version: '
|
76
|
+
version: '5.2'
|
77
77
|
type: :runtime
|
78
78
|
prerelease: false
|
79
79
|
version_requirements: !ruby/object:Gem::Requirement
|
80
80
|
requirements:
|
81
81
|
- - ">="
|
82
82
|
- !ruby/object:Gem::Version
|
83
|
-
version: '
|
83
|
+
version: '5.2'
|
84
84
|
- !ruby/object:Gem::Dependency
|
85
|
-
name:
|
85
|
+
name: sass-rails
|
86
86
|
requirement: !ruby/object:Gem::Requirement
|
87
87
|
requirements:
|
88
88
|
- - ">="
|
@@ -96,7 +96,7 @@ dependencies:
|
|
96
96
|
- !ruby/object:Gem::Version
|
97
97
|
version: '0'
|
98
98
|
- !ruby/object:Gem::Dependency
|
99
|
-
name:
|
99
|
+
name: capybara
|
100
100
|
requirement: !ruby/object:Gem::Requirement
|
101
101
|
requirements:
|
102
102
|
- - ">="
|
@@ -110,35 +110,35 @@ dependencies:
|
|
110
110
|
- !ruby/object:Gem::Version
|
111
111
|
version: '0'
|
112
112
|
- !ruby/object:Gem::Dependency
|
113
|
-
name:
|
113
|
+
name: factory_bot_rails
|
114
114
|
requirement: !ruby/object:Gem::Requirement
|
115
115
|
requirements:
|
116
|
-
- - "
|
116
|
+
- - ">="
|
117
117
|
- !ruby/object:Gem::Version
|
118
|
-
version:
|
118
|
+
version: '0'
|
119
119
|
type: :development
|
120
120
|
prerelease: false
|
121
121
|
version_requirements: !ruby/object:Gem::Requirement
|
122
122
|
requirements:
|
123
|
-
- - "
|
123
|
+
- - ">="
|
124
124
|
- !ruby/object:Gem::Version
|
125
|
-
version:
|
125
|
+
version: '0'
|
126
126
|
- !ruby/object:Gem::Dependency
|
127
127
|
name: rails-controller-testing
|
128
128
|
requirement: !ruby/object:Gem::Requirement
|
129
129
|
requirements:
|
130
|
-
- - "
|
130
|
+
- - ">="
|
131
131
|
- !ruby/object:Gem::Version
|
132
|
-
version:
|
132
|
+
version: '0'
|
133
133
|
type: :development
|
134
134
|
prerelease: false
|
135
135
|
version_requirements: !ruby/object:Gem::Requirement
|
136
136
|
requirements:
|
137
|
-
- - "
|
137
|
+
- - ">="
|
138
138
|
- !ruby/object:Gem::Version
|
139
|
-
version:
|
139
|
+
version: '0'
|
140
140
|
- !ruby/object:Gem::Dependency
|
141
|
-
name:
|
141
|
+
name: rspec-rails
|
142
142
|
requirement: !ruby/object:Gem::Requirement
|
143
143
|
requirements:
|
144
144
|
- - ">="
|
@@ -152,7 +152,7 @@ dependencies:
|
|
152
152
|
- !ruby/object:Gem::Version
|
153
153
|
version: '0'
|
154
154
|
- !ruby/object:Gem::Dependency
|
155
|
-
name:
|
155
|
+
name: selenium-webdriver
|
156
156
|
requirement: !ruby/object:Gem::Requirement
|
157
157
|
requirements:
|
158
158
|
- - ">="
|
@@ -166,7 +166,7 @@ dependencies:
|
|
166
166
|
- !ruby/object:Gem::Version
|
167
167
|
version: '0'
|
168
168
|
- !ruby/object:Gem::Dependency
|
169
|
-
name:
|
169
|
+
name: shoulda-matchers
|
170
170
|
requirement: !ruby/object:Gem::Requirement
|
171
171
|
requirements:
|
172
172
|
- - ">="
|
@@ -180,7 +180,7 @@ dependencies:
|
|
180
180
|
- !ruby/object:Gem::Version
|
181
181
|
version: '0'
|
182
182
|
- !ruby/object:Gem::Dependency
|
183
|
-
name:
|
183
|
+
name: sqlite3
|
184
184
|
requirement: !ruby/object:Gem::Requirement
|
185
185
|
requirements:
|
186
186
|
- - ">="
|
@@ -193,9 +193,8 @@ dependencies:
|
|
193
193
|
- - ">="
|
194
194
|
- !ruby/object:Gem::Version
|
195
195
|
version: '0'
|
196
|
-
description: Rails engine that can plug/unplug features with notice
|
196
|
+
description: Rails engine that can plug/unplug features with notice
|
197
197
|
email:
|
198
|
-
- benedict@boost.co.nz
|
199
198
|
- info@boost.co.nz
|
200
199
|
executables: []
|
201
200
|
extensions: []
|
@@ -267,7 +266,7 @@ files:
|
|
267
266
|
- lib/plug/engine.rb
|
268
267
|
- lib/plug/version.rb
|
269
268
|
- lib/tasks/plug_tasks.rake
|
270
|
-
homepage: https://github.com/
|
269
|
+
homepage: https://github.com/digitalnz/plug
|
271
270
|
licenses:
|
272
271
|
- MIT
|
273
272
|
metadata: {}
|