manyfold 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 +7 -0
- data/lib/generators/manyfold/app/USAGE +13 -0
- data/lib/generators/manyfold/app/app_generator.rb +35 -0
- data/lib/generators/manyfold/app/templates/config/initializers/active_model.rb +3 -0
- data/lib/generators/manyfold/app/templates/lib/active_model/type/symbol.rb +9 -0
- data/lib/generators/manyfold/authentication/USAGE +19 -0
- data/lib/generators/manyfold/authentication/authentication_generator.rb +87 -0
- data/lib/generators/manyfold/authentication/templates/app/controllers/concerns/authentication.rb +32 -0
- data/lib/generators/manyfold/authentication/templates/app/controllers/request_context/session_context.rb +17 -0
- data/lib/generators/manyfold/authentication/templates/app/lib/request_context/context/base.rb +35 -0
- data/lib/generators/manyfold/authentication/templates/app/lib/request_context/session/base.rb +35 -0
- data/lib/generators/manyfold/authentication/templates/app/lib/request_context/session/browser_session.rb +27 -0
- data/lib/generators/manyfold/authorization/USAGE +12 -0
- data/lib/generators/manyfold/authorization/authorization_generator.rb +39 -0
- data/lib/generators/manyfold/config/USAGE +13 -0
- data/lib/generators/manyfold/config/config_generator.rb +36 -0
- data/lib/generators/manyfold/config/templates/config/configs/app_config.rb +8 -0
- data/lib/generators/manyfold/config/templates/config/etc/app.yml +13 -0
- data/lib/generators/manyfold/enums/USAGE +12 -0
- data/lib/generators/manyfold/enums/enums_generator.rb +21 -0
- data/lib/generators/manyfold/field_errors/USAGE +10 -0
- data/lib/generators/manyfold/field_errors/field_errors_generator.rb +16 -0
- data/lib/generators/manyfold/field_errors/templates/app/views/errors/fields/_field.html.erb +3 -0
- data/lib/generators/manyfold/field_errors/templates/app/views/errors/fields/_label.html.erb +3 -0
- data/lib/generators/manyfold/field_errors/templates/config/initializers/field_with_errors.rb +15 -0
- data/lib/generators/manyfold/forms/USAGE +11 -0
- data/lib/generators/manyfold/forms/forms_generator.rb +21 -0
- data/lib/generators/manyfold/i18n/USAGE +11 -0
- data/lib/generators/manyfold/i18n/i18n_generator.rb +16 -0
- data/lib/generators/manyfold/i18n/templates/config/initializers/i18n.rb +4 -0
- data/lib/generators/manyfold/install/USAGE +5 -0
- data/lib/generators/manyfold/install/install_generator.rb +26 -0
- data/lib/generators/manyfold/mailer/USAGE +15 -0
- data/lib/generators/manyfold/mailer/mailer_generator.rb +72 -0
- data/lib/generators/manyfold/mailer/templates/config/configs/mailer_config.rb +7 -0
- data/lib/generators/manyfold/pagination/USAGE +13 -0
- data/lib/generators/manyfold/pagination/pagination_generator.rb +40 -0
- data/lib/generators/manyfold/solid/USAGE +20 -0
- data/lib/generators/manyfold/solid/solid_generator.rb +59 -0
- data/lib/generators/manyfold/solid/templates/app/controllers/jobs_controller.rb +3 -0
- data/lib/generators/manyfold/solid/templates/config/configs/database_config.rb +7 -0
- data/lib/generators/manyfold/solid/templates/config/configs/jobs_config.rb +4 -0
- data/lib/generators/manyfold/solid/templates/config/database.yml +37 -0
- data/lib/generators/manyfold/solid/templates/config/etc/database.yml +7 -0
- data/lib/generators/manyfold/solid/templates/config/etc/jobs.yml +9 -0
- data/lib/manyfold/version.rb +5 -0
- data/lib/manyfold.rb +19 -0
- metadata +86 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 36599cdaf4144c74bb3ad21ad34a4cbdf342ec05d7718b6f86f24ec54c82f102
|
4
|
+
data.tar.gz: f1829407d24c13bd7c146ca7ac66dbd106138a304f7d365209eb800d05218762
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5c9ddc9f2a2ab40a97ceaf29dd1503a00e71b696451628cd87c3acb637d9af477d8a7d2c1fe9dd07ea0caacbe5bdfd14142edf88b40bc68a6d8df149d3cd2110
|
7
|
+
data.tar.gz: 8eabce58b377ea87b141db3ddc3fb5fffc02188a021b6aac86212ec6733277b12ef2100ddaea9571fc3be4069285d8345473e0bbc749e3023be36ab09242e46d
|
@@ -0,0 +1,13 @@
|
|
1
|
+
Description:
|
2
|
+
Performs basic application framework modifications and additions an ApplicationEnum class and extends ApplicationRecord as a starting point for your application.
|
3
|
+
|
4
|
+
Example:
|
5
|
+
bin/rails generate manyfold:app
|
6
|
+
|
7
|
+
This will create:
|
8
|
+
lib/active_model/type/symbol.rb
|
9
|
+
config/initializers/active_model.rb
|
10
|
+
|
11
|
+
This will modify:
|
12
|
+
config/environments/production.rb
|
13
|
+
Gemfile
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require "rails/generators"
|
2
|
+
|
3
|
+
module Manyfold
|
4
|
+
module Generators
|
5
|
+
class AppGenerator < Rails::Generators::Base
|
6
|
+
source_root File.expand_path("templates", __dir__)
|
7
|
+
|
8
|
+
def gems
|
9
|
+
if [run("grep debase Gemfile"), run("grep ruby-debug-ide Gemfile")].any?(&:blank?)
|
10
|
+
gem_group :development, :test do
|
11
|
+
gem "debase", "0.2.5.beta2" if run("grep debase Gemfile").blank?
|
12
|
+
gem "ruby-debug-ide", "~> 0.7.4" if run("grep ruby-debug-ide Gemfile").blank?
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
Bundler.with_unbundled_env do
|
17
|
+
run 'bundle install'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def setup
|
22
|
+
copy_file "lib/active_model/type/symbol.rb", "lib/active_model/type/symbol.rb"
|
23
|
+
copy_file "config/initializers/active_model.rb", "config/initializers/active_model.rb"
|
24
|
+
|
25
|
+
inject_into_file "config/environments/production.rb", before: /^end$/ do
|
26
|
+
<<~CONFIG
|
27
|
+
|
28
|
+
\tconfig.logger = ActiveSupport::TaggedLogging.new(ActiveSupport::Logger.new("log/production.log"))
|
29
|
+
CONFIG
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
Description:
|
2
|
+
Sets up authentication.
|
3
|
+
|
4
|
+
Example:
|
5
|
+
bin/rails generate manyfold:authentication
|
6
|
+
|
7
|
+
This will create:
|
8
|
+
app/controllers/concerns/authentication.rb
|
9
|
+
app/controllers/request_context/session_context.rb
|
10
|
+
app/lib/request_context/context/base.rb
|
11
|
+
app/lib/request_context/session/base.rb
|
12
|
+
app/lib/request_context/session/browser_session.rb
|
13
|
+
|
14
|
+
This will modify:
|
15
|
+
config/configs/app_config.rb
|
16
|
+
config/etc/app.yml
|
17
|
+
app/helpers/application_helper.rb
|
18
|
+
app/controllers/application_controller.rb
|
19
|
+
app/controllers/application_controller.rb
|
@@ -0,0 +1,87 @@
|
|
1
|
+
require "rails/generators"
|
2
|
+
|
3
|
+
module Manyfold
|
4
|
+
module Generators
|
5
|
+
class AuthenticationGenerator < Rails::Generators::Base
|
6
|
+
source_root File.expand_path("templates", __dir__)
|
7
|
+
|
8
|
+
def gems
|
9
|
+
gem "bcrypt" if run("grep bcrypt Gemfile").blank?
|
10
|
+
Bundler.with_unbundled_env do
|
11
|
+
run 'bundle install'
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def setup
|
16
|
+
copy_file "app/controllers/concerns/authentication.rb", "app/controllers/concerns/authentication.rb"
|
17
|
+
copy_file "app/controllers/request_context/session_context.rb", "app/controllers/request_context/session_context.rb"
|
18
|
+
|
19
|
+
copy_file "app/lib/request_context/context/base.rb", "app/lib/request_context/context/base.rb"
|
20
|
+
copy_file "app/lib/request_context/session/base.rb", "app/lib/request_context/session/base.rb"
|
21
|
+
copy_file "app/lib/request_context/session/browser_session.rb", "app/lib/request_context/session/browser_session.rb"
|
22
|
+
|
23
|
+
inject_into_class "app/controllers/application_controller.rb", "ApplicationController" do
|
24
|
+
<<~CODE
|
25
|
+
\tinclude Authentication
|
26
|
+
|
27
|
+
CODE
|
28
|
+
end
|
29
|
+
|
30
|
+
inject_into_file "app/controllers/application_controller.rb", before: /^end/ do
|
31
|
+
<<~CODE
|
32
|
+
|
33
|
+
\tattr_accessor :request_context
|
34
|
+
|
35
|
+
\tonly_allow_authenticated_access
|
36
|
+
|
37
|
+
\tdef request_context
|
38
|
+
\t@request_context ||= RequestContext::SessionContext.new(RequestContext::Session::BrowserSession.new(cookies))
|
39
|
+
\tend
|
40
|
+
|
41
|
+
\tdef current_user
|
42
|
+
\trequest_context.user
|
43
|
+
\tend
|
44
|
+
|
45
|
+
\tdef authentication_user
|
46
|
+
\trequest_context.user
|
47
|
+
\tend
|
48
|
+
CODE
|
49
|
+
end
|
50
|
+
|
51
|
+
inject_into_file "app/helpers/application_helper.rb", before: /^end/ do
|
52
|
+
<<~CODE
|
53
|
+
|
54
|
+
\tdelegate :current_user, to: :controller
|
55
|
+
CODE
|
56
|
+
end
|
57
|
+
|
58
|
+
double_space = ' '
|
59
|
+
inject_into_file "config/etc/app.yml", after: /default: &default/ do
|
60
|
+
<<~CODE.chomp
|
61
|
+
|
62
|
+
#{double_space}unauthenticated_root_path:
|
63
|
+
#{double_space}authenticated_root_path:
|
64
|
+
CODE
|
65
|
+
end
|
66
|
+
|
67
|
+
inject_into_class 'config/configs/app_config.rb', "AppConfig" do
|
68
|
+
<<~CODE.chomp
|
69
|
+
\tattr_config :unauthenticated_root_path
|
70
|
+
\tattr_config :authenticated_root_path
|
71
|
+
|
72
|
+
CODE
|
73
|
+
end
|
74
|
+
|
75
|
+
rails_command("g model user email:string password_digest:string")
|
76
|
+
|
77
|
+
inject_into_class 'app/models/user.rb', "User" do
|
78
|
+
<<~CODE.chomp
|
79
|
+
\thas_secure_password
|
80
|
+
|
81
|
+
CODE
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
data/lib/generators/manyfold/authentication/templates/app/controllers/concerns/authentication.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
module Authentication
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
|
4
|
+
included do
|
5
|
+
only_allow_authenticated_access
|
6
|
+
end
|
7
|
+
|
8
|
+
class_methods do
|
9
|
+
def only_allow_unauthenticated_access(**options)
|
10
|
+
skip_before_action :redirect_unauthenticated_user, raise: false, **options
|
11
|
+
before_action :redirect_authenticated_user, **options
|
12
|
+
end
|
13
|
+
|
14
|
+
def only_allow_authenticated_access(**options)
|
15
|
+
before_action :redirect_unauthenticated_user, **options
|
16
|
+
end
|
17
|
+
|
18
|
+
def allow_all_access(**options)
|
19
|
+
skip_before_action :redirect_unauthenticated_user, raise: false, **options
|
20
|
+
skip_before_action :redirect_authenticated_user, raise: false, **options
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
def redirect_unauthenticated_user(route = nil)
|
26
|
+
redirect_to route || AppConfig.unauthenticated_root_path if current_user.nil?
|
27
|
+
end
|
28
|
+
|
29
|
+
def redirect_authenticated_user(route = nil)
|
30
|
+
redirect_to route || AppConfig.authenticated_root_path if current_user
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class RequestContext::SessionContext < RequestContext::Context::Base
|
2
|
+
attr_reader :user
|
3
|
+
|
4
|
+
def sync
|
5
|
+
if session[:user_id].nil? && @user
|
6
|
+
@user = nil
|
7
|
+
elsif @user || session[:user_id]
|
8
|
+
if @user.nil? || @user.id != session[:user_id]
|
9
|
+
@user = User.find_by(id: session[:user_id])
|
10
|
+
else
|
11
|
+
@user.reload
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
session.close if @user.nil? || @user.session_key != session[:session_key]
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module RequestContext
|
2
|
+
module Context
|
3
|
+
class Base
|
4
|
+
extend ActiveModel::Callbacks
|
5
|
+
|
6
|
+
define_model_callbacks :initialize, only: [:after]
|
7
|
+
|
8
|
+
attr_reader :session
|
9
|
+
|
10
|
+
after_initialize :sync
|
11
|
+
|
12
|
+
def initialize(session)
|
13
|
+
raise NotImplementedError.new("`#{self.class.name}` is abstract and cannot be instantiated directly.") if self.class.name == RequestContext::Context::Base.name
|
14
|
+
|
15
|
+
run_callbacks(:initialize) do
|
16
|
+
@session = session
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def sync
|
21
|
+
# Can be derived to specify how the session and the context should be synchronized
|
22
|
+
end
|
23
|
+
|
24
|
+
def update(data)
|
25
|
+
session.update(data)
|
26
|
+
sync
|
27
|
+
end
|
28
|
+
|
29
|
+
def close
|
30
|
+
session.close
|
31
|
+
sync
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module RequestContext
|
2
|
+
module Session
|
3
|
+
class Base
|
4
|
+
include ActiveModel::Callbacks
|
5
|
+
|
6
|
+
attr_reader :session_store
|
7
|
+
|
8
|
+
def initialize(session_store)
|
9
|
+
raise NotImplementedError.new("`#{self.class.name}` is abstract and cannot be instantiated directly.") if self.class.name == RequestContext::Session::Base.name
|
10
|
+
@session_store = session_store
|
11
|
+
end
|
12
|
+
|
13
|
+
def [](key)
|
14
|
+
raise NotImplementedError
|
15
|
+
end
|
16
|
+
|
17
|
+
def []=(key, value)
|
18
|
+
raise NotImplementedError
|
19
|
+
end
|
20
|
+
|
21
|
+
def delete(key)
|
22
|
+
raise NotImplementedError
|
23
|
+
end
|
24
|
+
|
25
|
+
def update(data)
|
26
|
+
raise NotImplementedError
|
27
|
+
end
|
28
|
+
|
29
|
+
def close
|
30
|
+
raise NotImplementedError
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module RequestContext
|
2
|
+
module Session
|
3
|
+
class BrowserSession < RequestContext::Session::Base
|
4
|
+
|
5
|
+
def [](key)
|
6
|
+
session_store[key]
|
7
|
+
end
|
8
|
+
|
9
|
+
def []=(key, value)
|
10
|
+
session_store[key] = value
|
11
|
+
end
|
12
|
+
|
13
|
+
def delete(key)
|
14
|
+
session_store.delete(key)
|
15
|
+
end
|
16
|
+
|
17
|
+
def close
|
18
|
+
session_store.destroy
|
19
|
+
end
|
20
|
+
|
21
|
+
def update(data)
|
22
|
+
session_store.update(data)
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require "rails/generators"
|
2
|
+
|
3
|
+
module Manyfold
|
4
|
+
module Generators
|
5
|
+
class AuthorizationGenerator < Rails::Generators::Base
|
6
|
+
source_root File.expand_path("templates", __dir__)
|
7
|
+
|
8
|
+
def gems
|
9
|
+
gem "pundit", "~> 2.3" if run("grep pundit Gemfile").blank?
|
10
|
+
Bundler.with_unbundled_env do
|
11
|
+
run 'bundle install'
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def setup
|
16
|
+
rails_command "g pundit:install"
|
17
|
+
|
18
|
+
inject_into_class "app/controllers/application_controller.rb", "ApplicationController" do
|
19
|
+
<<~CODE
|
20
|
+
|
21
|
+
\tinclude Pundit::Authorization
|
22
|
+
CODE
|
23
|
+
end
|
24
|
+
|
25
|
+
inject_into_file "app/controllers/application_controller.rb", :before => /^end/ do
|
26
|
+
<<~CODE
|
27
|
+
|
28
|
+
\tafter_action :verify_authorized
|
29
|
+
|
30
|
+
\tdef pundit_user
|
31
|
+
\t\trequest_context
|
32
|
+
\tend
|
33
|
+
CODE
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require "rails/generators"
|
2
|
+
|
3
|
+
module Manyfold
|
4
|
+
module Generators
|
5
|
+
class ConfigGenerator < Rails::Generators::Base
|
6
|
+
source_root File.expand_path("templates", __dir__)
|
7
|
+
|
8
|
+
def gems
|
9
|
+
gem 'anyway_config', '~> 2.6' if run("grep anyway_config Gemfile").blank?
|
10
|
+
Bundler.with_unbundled_env do
|
11
|
+
run 'bundle install'
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def setup
|
16
|
+
copy_file "config/configs/app_config.rb", "config/configs/app_config.rb"
|
17
|
+
copy_file "config/etc/app.yml", "config/etc/app.yml"
|
18
|
+
|
19
|
+
rails_command "g anyway:install"
|
20
|
+
|
21
|
+
gsub_file "config/application.rb",
|
22
|
+
/^\s{1}class Application < Rails::Application.*?\s{2}config.load_defaults/m,
|
23
|
+
"\tclass Application < Rails::Application\n\t\tconfig.load_defaults"
|
24
|
+
|
25
|
+
inject_into_file "config/application.rb", before: /^\s{2}end$/ do
|
26
|
+
<<~CONFIG
|
27
|
+
|
28
|
+
\t\tconfig.anyway_config.autoload_static_config_path = "config/configs"
|
29
|
+
\t\tconfig.anyway_config.default_config_path = "config/etc"
|
30
|
+
CONFIG
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require "rails/generators"
|
2
|
+
|
3
|
+
module Manyfold
|
4
|
+
module Generators
|
5
|
+
class EnumsGenerator < Rails::Generators::Base
|
6
|
+
source_root File.expand_path("templates", __dir__)
|
7
|
+
|
8
|
+
def gems
|
9
|
+
gem 'enumy', '~> 0.1' if run("grep enumy Gemfile").blank?
|
10
|
+
Bundler.with_unbundled_env do
|
11
|
+
run 'bundle install'
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def setup
|
16
|
+
rails_command "g enumy:install"
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require "rails/generators"
|
2
|
+
|
3
|
+
module Manyfold
|
4
|
+
module Generators
|
5
|
+
class FieldErrorsGenerator < Rails::Generators::Base
|
6
|
+
source_root File.expand_path("templates", __dir__)
|
7
|
+
|
8
|
+
def setup
|
9
|
+
copy_file "config/initializers/field_with_errors.rb", "config/initializers/field_with_errors.rb"
|
10
|
+
copy_file "app/views/errors/fields/_label.html.erb", "app/views/errors/fields/_label.html.erb"
|
11
|
+
copy_file "app/views/errors/fields/_field.html.erb", "app/views/errors/fields/_field.html.erb"
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
ActionView::Base.field_error_proc = Proc.new do |tag, field|
|
2
|
+
element = Nokogiri::HTML::DocumentFragment.parse(tag).children.first
|
3
|
+
|
4
|
+
locals = {
|
5
|
+
object: field.object,
|
6
|
+
name: field.instance_variable_get(:@method_name),
|
7
|
+
tag: tag
|
8
|
+
}
|
9
|
+
|
10
|
+
if element.name.to_sym == :label
|
11
|
+
ActionController::Base.render(partial: 'errors/fields/label', locals: locals)
|
12
|
+
else
|
13
|
+
ActionController::Base.render(partial: 'errors/fields/field', locals: locals)
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require "rails/generators"
|
2
|
+
|
3
|
+
module Manyfold
|
4
|
+
module Generators
|
5
|
+
class FormsGenerator < Rails::Generators::Base
|
6
|
+
source_root File.expand_path("templates", __dir__)
|
7
|
+
|
8
|
+
def gems
|
9
|
+
gem 'formstar', '~> 0.1' if run("grep formstar Gemfile").blank?
|
10
|
+
Bundler.with_unbundled_env do
|
11
|
+
run 'bundle install'
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def setup
|
16
|
+
rails_command "g formstar:install"
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require "rails/generators"
|
2
|
+
|
3
|
+
module Manyfold
|
4
|
+
module Generators
|
5
|
+
class I18nGenerator < Rails::Generators::Base
|
6
|
+
source_root File.expand_path("templates", __dir__)
|
7
|
+
|
8
|
+
def setup
|
9
|
+
copy_file "config/initializers/i18n.rb", "config/initializers/i18n.rb"
|
10
|
+
|
11
|
+
gsub_file "config/environments/development.rb", /^.*#.*config\.i18n\.raise_on_missing_translations = true.*$/, "\tconfig.i18n.raise_on_missing_translations = :strict"
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'open-uri'
|
2
|
+
|
3
|
+
module Manyfold
|
4
|
+
module Generators
|
5
|
+
class InstallGenerator < Rails::Generators::Base
|
6
|
+
source_root File.expand_path("templates", __dir__)
|
7
|
+
|
8
|
+
def setup
|
9
|
+
generate "manyfold:app"
|
10
|
+
generate "manyfold:config"
|
11
|
+
|
12
|
+
generate "manyfold:solid"
|
13
|
+
generate "manyfold:mailer"
|
14
|
+
generate "manyfold:i18n"
|
15
|
+
generate "manyfold:field_errors"
|
16
|
+
|
17
|
+
generate "manyfold:authentication"
|
18
|
+
generate "manyfold:authorization"
|
19
|
+
generate "manyfold:pagination"
|
20
|
+
generate "manyfold:enums"
|
21
|
+
generate "manyfold:forms"
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
Description:
|
2
|
+
Sets up ActionMailer and other mailer related items.
|
3
|
+
|
4
|
+
Example:
|
5
|
+
bin/rails generate manyfold:mailer
|
6
|
+
|
7
|
+
This will create:
|
8
|
+
config/configs/mailer_config.rb
|
9
|
+
config/etc/mailer.yml
|
10
|
+
|
11
|
+
This will modify:
|
12
|
+
config/environments/development.rb
|
13
|
+
config/environments/production.rb
|
14
|
+
config/routes.rb
|
15
|
+
Gemfile
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require "rails/generators"
|
2
|
+
|
3
|
+
module Manyfold
|
4
|
+
module Generators
|
5
|
+
class MailerGenerator < Rails::Generators::Base
|
6
|
+
source_root File.expand_path("templates", __dir__)
|
7
|
+
|
8
|
+
def gems
|
9
|
+
if [run("grep letter_opener Gemfile"), run("grep letter_opener_web Gemfile")].any?(&:blank?)
|
10
|
+
gem_group :development do
|
11
|
+
gem 'letter_opener', '~> 1.10' if run("grep letter_opener Gemfile").blank?
|
12
|
+
gem 'letter_opener_web', '~> 3.0' if run("grep letter_opener_web Gemfile").blank?
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
Bundler.with_unbundled_env do
|
17
|
+
run 'bundle install'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def setup
|
22
|
+
copy_file "config/configs/mailer_config.rb", "config/configs/mailer_config.rb"
|
23
|
+
|
24
|
+
inject_into_file "config/environments/development.rb", before: /^end$/ do
|
25
|
+
<<~CONFIG
|
26
|
+
|
27
|
+
\tconfig.active_job.queue_adapter = :solid_queue
|
28
|
+
\tconfig.solid_queue.connects_to = { database: { writing: :queue } }
|
29
|
+
CONFIG
|
30
|
+
end
|
31
|
+
|
32
|
+
gsub_file "config/environments/development.rb",
|
33
|
+
/.*config\.action_mailer\.default_url_options.*\n/,
|
34
|
+
<<~CODE
|
35
|
+
\tconfig.action_mailer.default_url_options = { host: AppConfig.host, port: 3000 }
|
36
|
+
\tconfig.action_mailer.delivery_method = :letter_opener_web
|
37
|
+
CODE
|
38
|
+
|
39
|
+
gsub_file "config/environments/production.rb",
|
40
|
+
/.*config\.action_mailer\.default_url_options.*\n/,
|
41
|
+
<<~CODE
|
42
|
+
\tconfig.action_mailer.default_url_options = { host: AppConfig.host }
|
43
|
+
CODE
|
44
|
+
|
45
|
+
gsub_file "config/environments/production.rb",
|
46
|
+
/.*config\.action_mailer\.smtp_settings = {[\S\s]*?}/,
|
47
|
+
<<~CODE
|
48
|
+
\tconfig.action_mailer.perform_deliveries = true
|
49
|
+
\tconfig.action_mailer.delivery_method = :smtp
|
50
|
+
\tconfig.action_mailer.smtp_settings = {
|
51
|
+
\taddress: MailerConfig.host,
|
52
|
+
\tport: MailerConfig.port,
|
53
|
+
\tdomain: MailerConfig.domain,
|
54
|
+
\tuser_name: MailerConfig.username,
|
55
|
+
\tpassword: MailerConfig.password,
|
56
|
+
\tauthentication: :plain
|
57
|
+
\t}
|
58
|
+
CODE
|
59
|
+
|
60
|
+
inject_into_file "config/routes.rb", before: /^end$/ do
|
61
|
+
<<~CONFIG
|
62
|
+
|
63
|
+
\tif AppConfig.local?
|
64
|
+
\tmount LetterOpenerWeb::Engine, at: "/letter_opener"
|
65
|
+
\tend
|
66
|
+
CONFIG
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
Description:
|
2
|
+
Sets up pagination.
|
3
|
+
|
4
|
+
Example:
|
5
|
+
bin/rails generate manyfold:pagination
|
6
|
+
|
7
|
+
This will create:
|
8
|
+
config/initializers/pagy.rb
|
9
|
+
|
10
|
+
This will modify:
|
11
|
+
app/controllers/application_controller.rb
|
12
|
+
app/helpers/application_helper.rb
|
13
|
+
Gemfile
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require "rails/generators"
|
2
|
+
require 'open-uri'
|
3
|
+
|
4
|
+
module Manyfold
|
5
|
+
module Generators
|
6
|
+
class PaginationGenerator < Rails::Generators::Base
|
7
|
+
source_root File.expand_path("templates", __dir__)
|
8
|
+
|
9
|
+
def gems
|
10
|
+
gem 'pagy', '~> 9.0' if run("grep pagy Gemfile").blank?
|
11
|
+
Bundler.with_unbundled_env do
|
12
|
+
run 'bundle install'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def setup
|
17
|
+
inject_into_class "app/controllers/application_controller.rb", "ApplicationController" do
|
18
|
+
<<~CODE
|
19
|
+
|
20
|
+
\tinclude Pagy::Backend
|
21
|
+
CODE
|
22
|
+
end
|
23
|
+
|
24
|
+
inject_into_module "app/helpers/application_helper.rb", "ApplicationHelper" do
|
25
|
+
<<~CODE
|
26
|
+
|
27
|
+
\tinclude Pagy::Frontend
|
28
|
+
CODE
|
29
|
+
end
|
30
|
+
|
31
|
+
::OpenURI.open_uri("https://raw.githubusercontent.com/ddnexus/pagy/master/gem/config/pagy.rb") do |file|
|
32
|
+
File.open("config/initializers/pagy.rb", 'wb') do |f|
|
33
|
+
f.write(file.read)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
Description:
|
2
|
+
Sets up SolidQueue, SolidCable, SolidCache, and other related items.
|
3
|
+
|
4
|
+
Example:
|
5
|
+
bin/rails generate manyfold:solid
|
6
|
+
|
7
|
+
This will create:
|
8
|
+
config/configs/jobs_config.rb
|
9
|
+
config/etc/jobs.yml
|
10
|
+
config/configs/database_config.rb
|
11
|
+
config/etc/database.yml
|
12
|
+
app/controllers/jobs_controller.rb
|
13
|
+
config/database.yml
|
14
|
+
|
15
|
+
This will modify:
|
16
|
+
config/application.rb
|
17
|
+
config/environments/development.rb
|
18
|
+
config/environments/production.rb
|
19
|
+
config/routes.rb
|
20
|
+
Gemfile
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require "rails/generators"
|
2
|
+
|
3
|
+
module Manyfold
|
4
|
+
module Generators
|
5
|
+
class SolidGenerator < Rails::Generators::Base
|
6
|
+
source_root File.expand_path("templates", __dir__)
|
7
|
+
|
8
|
+
def gems
|
9
|
+
gem 'mission_control-jobs', '~> 1.0' if run("grep mission_control-jobs Gemfile").blank?
|
10
|
+
Bundler.with_unbundled_env do
|
11
|
+
run 'bundle install'
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def setup
|
16
|
+
copy_file "config/configs/jobs_config.rb", "config/configs/jobs_config.rb"
|
17
|
+
copy_file "config/etc/jobs.yml", "config/etc/jobs.yml"
|
18
|
+
|
19
|
+
copy_file "config/configs/database_config.rb", "config/configs/database_config.rb"
|
20
|
+
copy_file "config/etc/database.yml", "config/etc/database.yml"
|
21
|
+
|
22
|
+
copy_file "app/controllers/jobs_controller.rb", "app/controllers/jobs_controller.rb"
|
23
|
+
|
24
|
+
copy_file "config/database.yml", "config/database.yml"
|
25
|
+
|
26
|
+
inject_into_file "config/application.rb", before: /^\s{2}end$/ do
|
27
|
+
<<~CONFIG
|
28
|
+
|
29
|
+
\t\tconfig.mission_control.jobs.base_controller_class = "JobsController"
|
30
|
+
\t\tconfig.mission_control.jobs.http_basic_auth_enabled = false
|
31
|
+
CONFIG
|
32
|
+
end
|
33
|
+
|
34
|
+
inject_into_file "config/environments/development.rb", before: /^end$/ do
|
35
|
+
<<~CONFIG
|
36
|
+
|
37
|
+
\tconfig.active_job.queue_adapter = :solid_queue
|
38
|
+
\tconfig.solid_queue.connects_to = { database: { writing: :queue } }
|
39
|
+
CONFIG
|
40
|
+
end
|
41
|
+
|
42
|
+
inject_into_file "config/environments/production.rb", before: /^end$/ do
|
43
|
+
<<~CONFIG
|
44
|
+
|
45
|
+
\tconfig.solid_queue.logger = ActiveSupport::TaggedLogging.new(ActiveSupport::Logger.new("log/solid_queue.log"))
|
46
|
+
CONFIG
|
47
|
+
end
|
48
|
+
|
49
|
+
inject_into_file "config/routes.rb", before: /^end$/ do
|
50
|
+
<<~CONFIG
|
51
|
+
|
52
|
+
\tmount MissionControl::Jobs::Engine, at: "/jobs"
|
53
|
+
CONFIG
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
default: &default
|
2
|
+
adapter: postgresql
|
3
|
+
pool: <%= ENV.fetch("RAILS_MAX_THREADS", 5) %>
|
4
|
+
encoding: UTF-8
|
5
|
+
host: postgres
|
6
|
+
username: <%= DatabaseConfig.user %>
|
7
|
+
password: <%= DatabaseConfig.password %>
|
8
|
+
|
9
|
+
development:
|
10
|
+
primary:
|
11
|
+
<<: *default
|
12
|
+
database: <%= DatabaseConfig.database_name %>
|
13
|
+
|
14
|
+
queue:
|
15
|
+
<<: *default
|
16
|
+
database: <%= "#{DatabaseConfig.database_name}_queue" %>
|
17
|
+
migrations_paths: db/queue_migrate
|
18
|
+
|
19
|
+
cable:
|
20
|
+
<<: *default
|
21
|
+
database: <%= "#{DatabaseConfig.database_name}_cable" %>
|
22
|
+
migrations_paths: db/cable_migrate
|
23
|
+
|
24
|
+
production:
|
25
|
+
primary:
|
26
|
+
<<: *default
|
27
|
+
database: <%= DatabaseConfig.database_name %>
|
28
|
+
|
29
|
+
queue:
|
30
|
+
<<: *default
|
31
|
+
database: <%= "#{DatabaseConfig.database_name}_queue" %>
|
32
|
+
migrations_paths: db/queue_migrate
|
33
|
+
|
34
|
+
cable:
|
35
|
+
<<: *default
|
36
|
+
database: <%= "#{DatabaseConfig.database_name}_cable" %>
|
37
|
+
migrations_paths: db/cable_migrate
|
data/lib/manyfold.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "manyfold/version"
|
4
|
+
require_relative "generators/manyfold/app/app_generator"
|
5
|
+
require_relative "generators/manyfold/authentication/authentication_generator"
|
6
|
+
require_relative "generators/manyfold/authorization/authorization_generator"
|
7
|
+
require_relative "generators/manyfold/config/config_generator"
|
8
|
+
require_relative "generators/manyfold/enums/enums_generator"
|
9
|
+
require_relative "generators/manyfold/field_errors/field_errors_generator"
|
10
|
+
require_relative "generators/manyfold/forms/forms_generator"
|
11
|
+
require_relative "generators/manyfold/i18n/i18n_generator"
|
12
|
+
require_relative "generators/manyfold/install/install_generator"
|
13
|
+
require_relative "generators/manyfold/mailer/mailer_generator"
|
14
|
+
require_relative "generators/manyfold/pagination/pagination_generator"
|
15
|
+
require_relative "generators/manyfold/solid/solid_generator"
|
16
|
+
|
17
|
+
module Manyfold
|
18
|
+
|
19
|
+
end
|
metadata
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: manyfold
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.4
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Bevan Holborn
|
8
|
+
bindir: bin
|
9
|
+
cert_chain: []
|
10
|
+
date: 2025-01-19 00:00:00.000000000 Z
|
11
|
+
dependencies: []
|
12
|
+
description: Rails generators collection
|
13
|
+
executables: []
|
14
|
+
extensions: []
|
15
|
+
extra_rdoc_files: []
|
16
|
+
files:
|
17
|
+
- lib/generators/manyfold/app/USAGE
|
18
|
+
- lib/generators/manyfold/app/app_generator.rb
|
19
|
+
- lib/generators/manyfold/app/templates/config/initializers/active_model.rb
|
20
|
+
- lib/generators/manyfold/app/templates/lib/active_model/type/symbol.rb
|
21
|
+
- lib/generators/manyfold/authentication/USAGE
|
22
|
+
- lib/generators/manyfold/authentication/authentication_generator.rb
|
23
|
+
- lib/generators/manyfold/authentication/templates/app/controllers/concerns/authentication.rb
|
24
|
+
- lib/generators/manyfold/authentication/templates/app/controllers/request_context/session_context.rb
|
25
|
+
- lib/generators/manyfold/authentication/templates/app/lib/request_context/context/base.rb
|
26
|
+
- lib/generators/manyfold/authentication/templates/app/lib/request_context/session/base.rb
|
27
|
+
- lib/generators/manyfold/authentication/templates/app/lib/request_context/session/browser_session.rb
|
28
|
+
- lib/generators/manyfold/authorization/USAGE
|
29
|
+
- lib/generators/manyfold/authorization/authorization_generator.rb
|
30
|
+
- lib/generators/manyfold/config/USAGE
|
31
|
+
- lib/generators/manyfold/config/config_generator.rb
|
32
|
+
- lib/generators/manyfold/config/templates/config/configs/app_config.rb
|
33
|
+
- lib/generators/manyfold/config/templates/config/etc/app.yml
|
34
|
+
- lib/generators/manyfold/enums/USAGE
|
35
|
+
- lib/generators/manyfold/enums/enums_generator.rb
|
36
|
+
- lib/generators/manyfold/field_errors/USAGE
|
37
|
+
- lib/generators/manyfold/field_errors/field_errors_generator.rb
|
38
|
+
- lib/generators/manyfold/field_errors/templates/app/views/errors/fields/_field.html.erb
|
39
|
+
- lib/generators/manyfold/field_errors/templates/app/views/errors/fields/_label.html.erb
|
40
|
+
- lib/generators/manyfold/field_errors/templates/config/initializers/field_with_errors.rb
|
41
|
+
- lib/generators/manyfold/forms/USAGE
|
42
|
+
- lib/generators/manyfold/forms/forms_generator.rb
|
43
|
+
- lib/generators/manyfold/i18n/USAGE
|
44
|
+
- lib/generators/manyfold/i18n/i18n_generator.rb
|
45
|
+
- lib/generators/manyfold/i18n/templates/config/initializers/i18n.rb
|
46
|
+
- lib/generators/manyfold/install/USAGE
|
47
|
+
- lib/generators/manyfold/install/install_generator.rb
|
48
|
+
- lib/generators/manyfold/mailer/USAGE
|
49
|
+
- lib/generators/manyfold/mailer/mailer_generator.rb
|
50
|
+
- lib/generators/manyfold/mailer/templates/config/configs/mailer_config.rb
|
51
|
+
- lib/generators/manyfold/pagination/USAGE
|
52
|
+
- lib/generators/manyfold/pagination/pagination_generator.rb
|
53
|
+
- lib/generators/manyfold/solid/USAGE
|
54
|
+
- lib/generators/manyfold/solid/solid_generator.rb
|
55
|
+
- lib/generators/manyfold/solid/templates/app/controllers/jobs_controller.rb
|
56
|
+
- lib/generators/manyfold/solid/templates/config/configs/database_config.rb
|
57
|
+
- lib/generators/manyfold/solid/templates/config/configs/jobs_config.rb
|
58
|
+
- lib/generators/manyfold/solid/templates/config/database.yml
|
59
|
+
- lib/generators/manyfold/solid/templates/config/etc/database.yml
|
60
|
+
- lib/generators/manyfold/solid/templates/config/etc/jobs.yml
|
61
|
+
- lib/manyfold.rb
|
62
|
+
- lib/manyfold/version.rb
|
63
|
+
homepage: https://rubygems.org/gems/manyfold
|
64
|
+
licenses:
|
65
|
+
- MIT
|
66
|
+
metadata:
|
67
|
+
homepage_uri: https://rubygems.org/gems/manyfold
|
68
|
+
source_code_uri: https://gitlab.com/BevanHolborn/manyfold
|
69
|
+
rdoc_options: []
|
70
|
+
require_paths:
|
71
|
+
- lib
|
72
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: 2.7.4
|
77
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
requirements: []
|
83
|
+
rubygems_version: 3.6.2
|
84
|
+
specification_version: 4
|
85
|
+
summary: A collection of Rails generators for a variety of additions
|
86
|
+
test_files: []
|