webamm_to_rails 7.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +3 -0
- data/lib/webamm_to_rails/features/definitions.rb +19 -0
- data/lib/webamm_to_rails/features/devise_onlineable/definition.rb +44 -0
- data/lib/webamm_to_rails/features/devise_onlineable/definitions/connection/presenter.rb +29 -0
- data/lib/webamm_to_rails/features/devise_onlineable/definitions/connection/template.erb +17 -0
- data/lib/webamm_to_rails/features/devise_onlineable/templates/app/channels/online_channel.rb.erb +13 -0
- data/lib/webamm_to_rails/features/devise_onlineable/templates/app/javascript/channels/consumer.js.erb +6 -0
- data/lib/webamm_to_rails/features/devise_onlineable/templates/app/javascript/channels/index.js.erb +5 -0
- data/lib/webamm_to_rails/features/devise_onlineable/templates/app/javascript/channels/online_channel.js.erb +48 -0
- data/lib/webamm_to_rails/features/devise_onlineable/templates/app/models/concerns/devise_onlineable.rb.erb +39 -0
- data/lib/webamm_to_rails/rails_boilerplate/builder.rb +318 -0
- data/lib/webamm_to_rails/rails_boilerplate/templates/Dockerfile.erb +83 -0
- data/lib/webamm_to_rails/rails_boilerplate/templates/Procfile.dev.erb +3 -0
- data/lib/webamm_to_rails/rails_boilerplate/templates/README.md.erb +24 -0
- data/lib/webamm_to_rails/rails_boilerplate/templates/Rakefile.erb +6 -0
- data/lib/webamm_to_rails/rails_boilerplate/templates/app/assets/config/manifest.js.erb +2 -0
- data/lib/webamm_to_rails/rails_boilerplate/templates/app/assets/stylesheets/application.tailwind.css.erb +3 -0
- data/lib/webamm_to_rails/rails_boilerplate/templates/app/channels/application_cable/channel.rb.erb +4 -0
- data/lib/webamm_to_rails/rails_boilerplate/templates/app/channels/application_cable/connection.rb.erb +4 -0
- data/lib/webamm_to_rails/rails_boilerplate/templates/app/helpers/application_helper.rb.erb +2 -0
- data/lib/webamm_to_rails/rails_boilerplate/templates/app/javascript/application.js.erb +3 -0
- data/lib/webamm_to_rails/rails_boilerplate/templates/app/javascript/controllers/application.js.erb +9 -0
- data/lib/webamm_to_rails/rails_boilerplate/templates/app/javascript/controllers/hello_controller.js.erb +7 -0
- data/lib/webamm_to_rails/rails_boilerplate/templates/app/javascript/controllers/index.js.erb +8 -0
- data/lib/webamm_to_rails/rails_boilerplate/templates/app/jobs/application_job.rb.erb +7 -0
- data/lib/webamm_to_rails/rails_boilerplate/templates/app/mailers/application_mailer.rb.erb +4 -0
- data/lib/webamm_to_rails/rails_boilerplate/templates/app/models/application_record.rb.erb +3 -0
- data/lib/webamm_to_rails/rails_boilerplate/templates/app/views/layouts/application.html.erb +44 -0
- data/lib/webamm_to_rails/rails_boilerplate/templates/app/views/layouts/mailer.html.erb +13 -0
- data/lib/webamm_to_rails/rails_boilerplate/templates/app/views/layouts/mailer.text.erb +1 -0
- data/lib/webamm_to_rails/rails_boilerplate/templates/app/views/pwa/manifest.json.erb +22 -0
- data/lib/webamm_to_rails/rails_boilerplate/templates/app/views/pwa/service-worker.js.erb +26 -0
- data/lib/webamm_to_rails/rails_boilerplate/templates/bin/brakeman.erb +7 -0
- data/lib/webamm_to_rails/rails_boilerplate/templates/bin/bundle.erb +109 -0
- data/lib/webamm_to_rails/rails_boilerplate/templates/bin/dev.erb +11 -0
- data/lib/webamm_to_rails/rails_boilerplate/templates/bin/docker-entrypoint.erb +13 -0
- data/lib/webamm_to_rails/rails_boilerplate/templates/bin/rails.erb +4 -0
- data/lib/webamm_to_rails/rails_boilerplate/templates/bin/rake.erb +4 -0
- data/lib/webamm_to_rails/rails_boilerplate/templates/bin/rubocop.erb +8 -0
- data/lib/webamm_to_rails/rails_boilerplate/templates/bin/setup.erb +40 -0
- data/lib/webamm_to_rails/rails_boilerplate/templates/config/application.rb.erb +42 -0
- data/lib/webamm_to_rails/rails_boilerplate/templates/config/boot.rb.erb +4 -0
- data/lib/webamm_to_rails/rails_boilerplate/templates/config/cable.yml.erb +11 -0
- data/lib/webamm_to_rails/rails_boilerplate/templates/config/credentials.yml.enc.erb +1 -0
- data/lib/webamm_to_rails/rails_boilerplate/templates/config/database.yml.erb +85 -0
- data/lib/webamm_to_rails/rails_boilerplate/templates/config/environment.rb.erb +5 -0
- data/lib/webamm_to_rails/rails_boilerplate/templates/config/environments/development.rb.erb +84 -0
- data/lib/webamm_to_rails/rails_boilerplate/templates/config/environments/production.rb.erb +102 -0
- data/lib/webamm_to_rails/rails_boilerplate/templates/config/environments/test.rb.erb +67 -0
- data/lib/webamm_to_rails/rails_boilerplate/templates/config/initializers/assets.rb.erb +12 -0
- data/lib/webamm_to_rails/rails_boilerplate/templates/config/initializers/content_security_policy.rb.erb +25 -0
- data/lib/webamm_to_rails/rails_boilerplate/templates/config/initializers/filter_parameter_logging.rb.erb +8 -0
- data/lib/webamm_to_rails/rails_boilerplate/templates/config/initializers/inflections.rb.erb +16 -0
- data/lib/webamm_to_rails/rails_boilerplate/templates/config/initializers/permissions_policy.rb.erb +13 -0
- data/lib/webamm_to_rails/rails_boilerplate/templates/config/locales/en.yml.erb +31 -0
- data/lib/webamm_to_rails/rails_boilerplate/templates/config/master.key.erb +1 -0
- data/lib/webamm_to_rails/rails_boilerplate/templates/config/puma.rb.erb +33 -0
- data/lib/webamm_to_rails/rails_boilerplate/templates/config/storage.yml.erb +34 -0
- data/lib/webamm_to_rails/rails_boilerplate/templates/config.ru.erb +6 -0
- data/lib/webamm_to_rails/rails_boilerplate/templates/db/seeds.rb.erb +9 -0
- data/lib/webamm_to_rails/rails_boilerplate/templates/dockerignore.erb +48 -0
- data/lib/webamm_to_rails/rails_boilerplate/templates/gitattributes.erb +9 -0
- data/lib/webamm_to_rails/rails_boilerplate/templates/github/dependabot.yml.erb +0 -0
- data/lib/webamm_to_rails/rails_boilerplate/templates/github/workflows/ci.yml.erb +38 -0
- data/lib/webamm_to_rails/rails_boilerplate/templates/gitignore.erb +40 -0
- data/lib/webamm_to_rails/rails_boilerplate/templates/node-version.erb +1 -0
- data/lib/webamm_to_rails/rails_boilerplate/templates/public/404.html.erb +67 -0
- data/lib/webamm_to_rails/rails_boilerplate/templates/public/406-unsupported-browser.html.erb +66 -0
- data/lib/webamm_to_rails/rails_boilerplate/templates/public/422.html.erb +67 -0
- data/lib/webamm_to_rails/rails_boilerplate/templates/public/500.html.erb +66 -0
- data/lib/webamm_to_rails/rails_boilerplate/templates/public/icon.png.erb +0 -0
- data/lib/webamm_to_rails/rails_boilerplate/templates/public/icon.svg.erb +3 -0
- data/lib/webamm_to_rails/rails_boilerplate/templates/public/robots.txt.erb +1 -0
- data/lib/webamm_to_rails/rails_boilerplate/templates/rubocop.yml.erb +8 -0
- data/lib/webamm_to_rails/rails_boilerplate/templates/ruby-version.erb +1 -0
- data/lib/webamm_to_rails/rails_boilerplate/templates/tailwind.config.js.erb +8 -0
- data/lib/webamm_to_rails/sources/controllers/actions/create_definition/presenter.rb +50 -0
- data/lib/webamm_to_rails/sources/controllers/actions/create_definition/template.erb +9 -0
- data/lib/webamm_to_rails/sources/controllers/actions/definition.rb +66 -0
- data/lib/webamm_to_rails/sources/controllers/actions/destroy_definition/presenter.rb +52 -0
- data/lib/webamm_to_rails/sources/controllers/actions/destroy_definition/template.erb +6 -0
- data/lib/webamm_to_rails/sources/controllers/actions/edit_definition/presenter.rb +40 -0
- data/lib/webamm_to_rails/sources/controllers/actions/edit_definition/template.erb +3 -0
- data/lib/webamm_to_rails/sources/controllers/actions/index_definition/presenter.rb +40 -0
- data/lib/webamm_to_rails/sources/controllers/actions/index_definition/template.erb +3 -0
- data/lib/webamm_to_rails/sources/controllers/actions/new_definition/presenter.rb +40 -0
- data/lib/webamm_to_rails/sources/controllers/actions/new_definition/template.erb +3 -0
- data/lib/webamm_to_rails/sources/controllers/actions/show_definition/presenter.rb +40 -0
- data/lib/webamm_to_rails/sources/controllers/actions/show_definition/template.erb +3 -0
- data/lib/webamm_to_rails/sources/controllers/actions/strong_parameters_definition/presenter.rb +50 -0
- data/lib/webamm_to_rails/sources/controllers/actions/strong_parameters_definition/template.erb +3 -0
- data/lib/webamm_to_rails/sources/controllers/actions/update_definition/presenter.rb +54 -0
- data/lib/webamm_to_rails/sources/controllers/actions/update_definition/template.erb +9 -0
- data/lib/webamm_to_rails/sources/controllers/application_controller/authentication/devise_groups/presenter.rb +49 -0
- data/lib/webamm_to_rails/sources/controllers/application_controller/authentication/devise_groups_definition/presenter.rb +30 -0
- data/lib/webamm_to_rails/sources/controllers/application_controller/definition.rb +36 -0
- data/lib/webamm_to_rails/sources/controllers/application_controller/template.erb +5 -0
- data/lib/webamm_to_rails/sources/controllers/class_definition/presenter.rb +17 -0
- data/lib/webamm_to_rails/sources/controllers/definition.rb +44 -0
- data/lib/webamm_to_rails/sources/controllers/filters/definition.rb +32 -0
- data/lib/webamm_to_rails/sources/controllers/filters/devise_definition/presenter.rb +55 -0
- data/lib/webamm_to_rails/sources/controllers/template.erb +17 -0
- data/lib/webamm_to_rails/sources/gemfile/default_set.rb +27 -0
- data/lib/webamm_to_rails/sources/gemfile/definition.rb +31 -0
- data/lib/webamm_to_rails/sources/gemfile/gem.rb +8 -0
- data/lib/webamm_to_rails/sources/gemfile/gem_definition/presenter.rb +22 -0
- data/lib/webamm_to_rails/sources/gemfile/project_set.rb +21 -0
- data/lib/webamm_to_rails/sources/gemfile/sets/authentication.rb +34 -0
- data/lib/webamm_to_rails/sources/gemfile/template.erb +17 -0
- data/lib/webamm_to_rails/sources/helpers/definitions.rb +21 -0
- data/lib/webamm_to_rails/sources/helpers/devise/presenter.rb +27 -0
- data/lib/webamm_to_rails/sources/helpers/devise/qr_code_helper/presenter.rb +19 -0
- data/lib/webamm_to_rails/sources/helpers/devise/qr_code_helper/template.erb +22 -0
- data/lib/webamm_to_rails/sources/initializers/definitions.rb +26 -0
- data/lib/webamm_to_rails/sources/initializers/devise_definition/presenter.rb +27 -0
- data/lib/webamm_to_rails/sources/initializers/devise_definition/template.erb +397 -0
- data/lib/webamm_to_rails/sources/migrations/active_storage_definition/presenter.rb +29 -0
- data/lib/webamm_to_rails/sources/migrations/active_storage_definition/template.erb +57 -0
- data/lib/webamm_to_rails/sources/migrations/associations.rb +49 -0
- data/lib/webamm_to_rails/sources/migrations/class_definition/presenter.rb +17 -0
- data/lib/webamm_to_rails/sources/migrations/column_definition/presenter.rb +38 -0
- data/lib/webamm_to_rails/sources/migrations/columns.rb +33 -0
- data/lib/webamm_to_rails/sources/migrations/definition.rb +52 -0
- data/lib/webamm_to_rails/sources/migrations/devise/definition.rb +278 -0
- data/lib/webamm_to_rails/sources/migrations/files_list.rb +98 -0
- data/lib/webamm_to_rails/sources/migrations/index_definition/presenter.rb +34 -0
- data/lib/webamm_to_rails/sources/migrations/indices.rb +33 -0
- data/lib/webamm_to_rails/sources/migrations/table_definition/presenter.rb +21 -0
- data/lib/webamm_to_rails/sources/migrations/template.erb +12 -0
- data/lib/webamm_to_rails/sources/migrations/uuid_definition/presenter.rb +29 -0
- data/lib/webamm_to_rails/sources/migrations/uuid_definition/template.erb +5 -0
- data/lib/webamm_to_rails/sources/models/association_definition/presenter.rb +49 -0
- data/lib/webamm_to_rails/sources/models/associations.rb +113 -0
- data/lib/webamm_to_rails/sources/models/attachment_definition/presenter.rb +21 -0
- data/lib/webamm_to_rails/sources/models/attachments.rb +25 -0
- data/lib/webamm_to_rails/sources/models/class_definition/presenter.rb +17 -0
- data/lib/webamm_to_rails/sources/models/concerns.rb +27 -0
- data/lib/webamm_to_rails/sources/models/definition.rb +57 -0
- data/lib/webamm_to_rails/sources/models/devise_definition/presenter.rb +49 -0
- data/lib/webamm_to_rails/sources/models/enum_definition/presenter.rb +19 -0
- data/lib/webamm_to_rails/sources/models/enums.rb +25 -0
- data/lib/webamm_to_rails/sources/models/template.erb +7 -0
- data/lib/webamm_to_rails/sources/package_json/definition.rb +27 -0
- data/lib/webamm_to_rails/sources/package_json/template.erb +21 -0
- data/lib/webamm_to_rails/sources/routes/authentication_definition/presenter.rb +21 -0
- data/lib/webamm_to_rails/sources/routes/definition.rb +38 -0
- data/lib/webamm_to_rails/sources/routes/resource_definition/presenter.rb +25 -0
- data/lib/webamm_to_rails/sources/routes/template.erb +14 -0
- data/lib/webamm_to_rails/sources/views/definition.rb +28 -0
- data/lib/webamm_to_rails/sources/views/devise/invitable/presenter.rb +31 -0
- data/lib/webamm_to_rails/sources/views/devise/invitable/templates/invitations/edit.html.erb +38 -0
- data/lib/webamm_to_rails/sources/views/devise/invitable/templates/invitations/new.html.erb +31 -0
- data/lib/webamm_to_rails/sources/views/devise/invitable/templates/mailer/invitation_instructions.html.erb +23 -0
- data/lib/webamm_to_rails/sources/views/devise/otp/presenter.rb +32 -0
- data/lib/webamm_to_rails/sources/views/devise/otp/templates/otp_credentials/refresh.html.erb +19 -0
- data/lib/webamm_to_rails/sources/views/devise/otp/templates/otp_credentials/show.html.erb +70 -0
- data/lib/webamm_to_rails/sources/views/devise/otp/templates/otp_tokens/_token_secret.html.erb +21 -0
- data/lib/webamm_to_rails/sources/views/devise/otp/templates/otp_tokens/_trusted_devices.html.erb +12 -0
- data/lib/webamm_to_rails/sources/views/devise/otp/templates/otp_tokens/edit.html.erb +48 -0
- data/lib/webamm_to_rails/sources/views/devise/otp/templates/otp_tokens/recovery.html.erb +21 -0
- data/lib/webamm_to_rails/sources/views/devise/otp/templates/otp_tokens/recovery_codes.html.erb +3 -0
- data/lib/webamm_to_rails/sources/views/devise/otp/templates/otp_tokens/show.html.erb +21 -0
- data/lib/webamm_to_rails/sources/views/devise/presenter.rb +37 -0
- data/lib/webamm_to_rails/sources/views/devise/standard/presenter.rb +39 -0
- data/lib/webamm_to_rails/sources/views/devise/standard/templates/confirmations/new.html.erb +31 -0
- data/lib/webamm_to_rails/sources/views/devise/standard/templates/mailer/confirmation_instructions.html.erb +17 -0
- data/lib/webamm_to_rails/sources/views/devise/standard/templates/mailer/email_changed.html.erb +7 -0
- data/lib/webamm_to_rails/sources/views/devise/standard/templates/mailer/password_change.html.erb +3 -0
- data/lib/webamm_to_rails/sources/views/devise/standard/templates/mailer/reset_password_instructions.html.erb +22 -0
- data/lib/webamm_to_rails/sources/views/devise/standard/templates/passwords/edit.html.erb +36 -0
- data/lib/webamm_to_rails/sources/views/devise/standard/templates/passwords/new.html.erb +31 -0
- data/lib/webamm_to_rails/sources/views/devise/standard/templates/registrations/edit.html.erb +43 -0
- data/lib/webamm_to_rails/sources/views/devise/standard/templates/registrations/new.html.erb +39 -0
- data/lib/webamm_to_rails/sources/views/devise/standard/templates/sessions/new.html.erb +23 -0
- data/lib/webamm_to_rails/sources/views/devise/standard/templates/shared/_links.html.erb +27 -0
- data/lib/webamm_to_rails/sources/views/resource/edit_definition/presenter.rb +41 -0
- data/lib/webamm_to_rails/sources/views/resource/edit_definition/template.erb +1 -0
- data/lib/webamm_to_rails/sources/views/resource/form_definition/presenter.rb +50 -0
- data/lib/webamm_to_rails/sources/views/resource/form_definition/template.erb +82 -0
- data/lib/webamm_to_rails/sources/views/resource/index_definition/presenter.rb +69 -0
- data/lib/webamm_to_rails/sources/views/resource/index_definition/template.erb +78 -0
- data/lib/webamm_to_rails/sources/views/resource/new_definition/presenter.rb +41 -0
- data/lib/webamm_to_rails/sources/views/resource/new_definition/template.erb +1 -0
- data/lib/webamm_to_rails/sources/views/resource/presenter.rb +41 -0
- data/lib/webamm_to_rails/sources/views/resource/show_definition/presenter.rb +61 -0
- data/lib/webamm_to_rails/sources/views/resource/show_definition/template.erb +34 -0
- data/lib/webamm_to_rails/utils/format_code.rb +11 -0
- data/lib/webamm_to_rails/utils/format_template.rb +11 -0
- data/lib/webamm_to_rails/version.rb +5 -0
- data/lib/webamm_to_rails.rb +112 -0
- data/webamm_to_rails.gemspec +28 -0
- metadata +332 -0
@@ -0,0 +1,397 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Assuming you have not yet modified this file, each configuration option below
|
4
|
+
# is set to its default value. Note that some are commented out while others
|
5
|
+
# are not: uncommented lines are intended to protect your configuration from
|
6
|
+
# breaking changes in upgrades (i.e., in the event that future versions of
|
7
|
+
# Devise change the default values for those options).
|
8
|
+
#
|
9
|
+
# Use this hook to configure devise mailer, warden hooks and so forth.
|
10
|
+
# Many of these configuration options can be set straight in your model.
|
11
|
+
Devise.setup do |config|
|
12
|
+
# The secret key used by Devise. Devise uses this key to generate
|
13
|
+
# random tokens. Changing this key will render invalid all existing
|
14
|
+
# confirmation, reset password and unlock tokens in the database.
|
15
|
+
# Devise will use the `secret_key_base` as its `secret_key`
|
16
|
+
# by default. You can change it below and use your own secret key.
|
17
|
+
# config.secret_key = '304853067f0376eab5b9223d4ec49b27269c74db992652a4c1247b50dc6278a6c1b1a418d8f874eb9748765e2ea718e16d72f0c7000fbddb079eb1875c0e7615'
|
18
|
+
|
19
|
+
# ==> Controller configuration
|
20
|
+
# Configure the parent class to the devise controllers.
|
21
|
+
# config.parent_controller = 'DeviseController'
|
22
|
+
|
23
|
+
# ==> Mailer Configuration
|
24
|
+
# Configure the e-mail address which will be shown in Devise::Mailer,
|
25
|
+
# note that it will be overwritten if you use your own mailer class
|
26
|
+
# with default "from" parameter.
|
27
|
+
config.mailer_sender = 'please-change-me-at-config-initializers-devise@example.com'
|
28
|
+
|
29
|
+
# Configure the class responsible to send e-mails.
|
30
|
+
# config.mailer = 'Devise::Mailer'
|
31
|
+
|
32
|
+
# Configure the parent class responsible to send e-mails.
|
33
|
+
# config.parent_mailer = 'ActionMailer::Base'
|
34
|
+
|
35
|
+
# ==> ORM configuration
|
36
|
+
# Load and configure the ORM. Supports :active_record (default) and
|
37
|
+
# :mongoid (bson_ext recommended) by default. Other ORMs may be
|
38
|
+
# available as additional gems.
|
39
|
+
require 'devise/orm/active_record'
|
40
|
+
|
41
|
+
# ==> Configuration for any authentication mechanism
|
42
|
+
# Configure which keys are used when authenticating a user. The default is
|
43
|
+
# just :email. You can configure it to use [:username, :subdomain], so for
|
44
|
+
# authenticating a user, both parameters are required. Remember that those
|
45
|
+
# parameters are used only when authenticating and not when retrieving from
|
46
|
+
# session. If you need permissions, you should implement that in a before filter.
|
47
|
+
# You can also supply a hash where the value is a boolean determining whether
|
48
|
+
# or not authentication should be aborted when the value is not present.
|
49
|
+
# config.authentication_keys = [:email]
|
50
|
+
|
51
|
+
# Configure parameters from the request object used for authentication. Each entry
|
52
|
+
# given should be a request method and it will automatically be passed to the
|
53
|
+
# find_for_authentication method and considered in your model lookup. For instance,
|
54
|
+
# if you set :request_keys to [:subdomain], :subdomain will be used on authentication.
|
55
|
+
# The same considerations mentioned for authentication_keys also apply to request_keys.
|
56
|
+
# config.request_keys = []
|
57
|
+
|
58
|
+
# Configure which authentication keys should be case-insensitive.
|
59
|
+
# These keys will be downcased upon creating or modifying a user and when used
|
60
|
+
# to authenticate or find a user. Default is :email.
|
61
|
+
config.case_insensitive_keys = [:email]
|
62
|
+
|
63
|
+
# Configure which authentication keys should have whitespace stripped.
|
64
|
+
# These keys will have whitespace before and after removed upon creating or
|
65
|
+
# modifying a user and when used to authenticate or find a user. Default is :email.
|
66
|
+
config.strip_whitespace_keys = [:email]
|
67
|
+
|
68
|
+
# Tell if authentication through request.params is enabled. True by default.
|
69
|
+
# It can be set to an array that will enable params authentication only for the
|
70
|
+
# given strategies, for example, `config.params_authenticatable = [:database]` will
|
71
|
+
# enable it only for database (email + password) authentication.
|
72
|
+
# config.params_authenticatable = true
|
73
|
+
|
74
|
+
# Tell if authentication through HTTP Auth is enabled. False by default.
|
75
|
+
# It can be set to an array that will enable http authentication only for the
|
76
|
+
# given strategies, for example, `config.http_authenticatable = [:database]` will
|
77
|
+
# enable it only for database authentication.
|
78
|
+
# For API-only applications to support authentication "out-of-the-box", you will likely want to
|
79
|
+
# enable this with :database unless you are using a custom strategy.
|
80
|
+
# The supported strategies are:
|
81
|
+
# :database = Support basic authentication with authentication key + password
|
82
|
+
# config.http_authenticatable = false
|
83
|
+
|
84
|
+
# If 401 status code should be returned for AJAX requests. True by default.
|
85
|
+
# config.http_authenticatable_on_xhr = true
|
86
|
+
|
87
|
+
# The realm used in Http Basic Authentication. 'Application' by default.
|
88
|
+
# config.http_authentication_realm = 'Application'
|
89
|
+
|
90
|
+
# It will change confirmation, password recovery and other workflows
|
91
|
+
# to behave the same regardless if the e-mail provided was right or wrong.
|
92
|
+
# Does not affect registerable.
|
93
|
+
# config.paranoid = true
|
94
|
+
|
95
|
+
# By default Devise will store the user in session. You can skip storage for
|
96
|
+
# particular strategies by setting this option.
|
97
|
+
# Notice that if you are skipping storage for all authentication paths, you
|
98
|
+
# may want to disable generating routes to Devise's sessions controller by
|
99
|
+
# passing skip: :sessions to `devise_for` in your config/routes.rb
|
100
|
+
config.skip_session_storage = [:http_auth]
|
101
|
+
|
102
|
+
# By default, Devise cleans up the CSRF token on authentication to
|
103
|
+
# avoid CSRF token fixation attacks. This means that, when using AJAX
|
104
|
+
# requests for sign in and sign up, you need to get a new CSRF token
|
105
|
+
# from the server. You can disable this option at your own risk.
|
106
|
+
# config.clean_up_csrf_token_on_authentication = true
|
107
|
+
|
108
|
+
# When false, Devise will not attempt to reload routes on eager load.
|
109
|
+
# This can reduce the time taken to boot the app but if your application
|
110
|
+
# requires the Devise mappings to be loaded during boot time the application
|
111
|
+
# won't boot properly.
|
112
|
+
# config.reload_routes = true
|
113
|
+
|
114
|
+
# ==> Configuration for :database_authenticatable
|
115
|
+
# For bcrypt, this is the cost for hashing the password and defaults to 12. If
|
116
|
+
# using other algorithms, it sets how many times you want the password to be hashed.
|
117
|
+
# The number of stretches used for generating the hashed password are stored
|
118
|
+
# with the hashed password. This allows you to change the stretches without
|
119
|
+
# invalidating existing passwords.
|
120
|
+
#
|
121
|
+
# Limiting the stretches to just one in testing will increase the performance of
|
122
|
+
# your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use
|
123
|
+
# a value less than 10 in other environments. Note that, for bcrypt (the default
|
124
|
+
# algorithm), the cost increases exponentially with the number of stretches (e.g.
|
125
|
+
# a value of 20 is already extremely slow: approx. 60 seconds for 1 calculation).
|
126
|
+
config.stretches = Rails.env.test? ? 1 : 12
|
127
|
+
|
128
|
+
# Set up a pepper to generate the hashed password.
|
129
|
+
# config.pepper = '68df5eace25b3414f190b97fdf2bedcedb7719545afad5ef3218c7235bcbe94238e58467b8603542a469d9ece790e128d94a9e5b8d75f622b64d04403979df1a'
|
130
|
+
|
131
|
+
# Send a notification to the original email when the user's email is changed.
|
132
|
+
# config.send_email_changed_notification = false
|
133
|
+
|
134
|
+
# Send a notification email when the user's password is changed.
|
135
|
+
# config.send_password_change_notification = false
|
136
|
+
|
137
|
+
# ==> Configuration for :confirmable
|
138
|
+
# A period that the user is allowed to access the website even without
|
139
|
+
# confirming their account. For instance, if set to 2.days, the user will be
|
140
|
+
# able to access the website for two days without confirming their account,
|
141
|
+
# access will be blocked just in the third day.
|
142
|
+
# You can also set it to nil, which will allow the user to access the website
|
143
|
+
# without confirming their account.
|
144
|
+
# Default is 0.days, meaning the user cannot access the website without
|
145
|
+
# confirming their account.
|
146
|
+
# config.allow_unconfirmed_access_for = 2.days
|
147
|
+
|
148
|
+
# A period that the user is allowed to confirm their account before their
|
149
|
+
# token becomes invalid. For example, if set to 3.days, the user can confirm
|
150
|
+
# their account within 3 days after the mail was sent, but on the fourth day
|
151
|
+
# their account can't be confirmed with the token any more.
|
152
|
+
# Default is nil, meaning there is no restriction on how long a user can take
|
153
|
+
# before confirming their account.
|
154
|
+
# config.confirm_within = 3.days
|
155
|
+
|
156
|
+
# If true, requires any email changes to be confirmed (exactly the same way as
|
157
|
+
# initial account confirmation) to be applied. Requires additional unconfirmed_email
|
158
|
+
# db field (see migrations). Until confirmed, new email is stored in
|
159
|
+
# unconfirmed_email column, and copied to email column on successful confirmation.
|
160
|
+
config.reconfirmable = true
|
161
|
+
|
162
|
+
# Defines which key will be used when confirming an account
|
163
|
+
# config.confirmation_keys = [:email]
|
164
|
+
|
165
|
+
# ==> Configuration for :rememberable
|
166
|
+
# The time the user will be remembered without asking for credentials again.
|
167
|
+
# config.remember_for = 2.weeks
|
168
|
+
|
169
|
+
# Invalidates all the remember me tokens when the user signs out.
|
170
|
+
config.expire_all_remember_me_on_sign_out = true
|
171
|
+
|
172
|
+
# If true, extends the user's remember period when remembered via cookie.
|
173
|
+
# config.extend_remember_period = false
|
174
|
+
|
175
|
+
# Options to be passed to the created cookie. For instance, you can set
|
176
|
+
# secure: true in order to force SSL only cookies.
|
177
|
+
# config.rememberable_options = {}
|
178
|
+
|
179
|
+
# ==> Configuration for :validatable
|
180
|
+
# Range for password length.
|
181
|
+
config.password_length = 6..128
|
182
|
+
|
183
|
+
# Email regex used to validate email formats. It simply asserts that
|
184
|
+
# one (and only one) @ exists in the given string. This is mainly
|
185
|
+
# to give user feedback and not to assert the e-mail validity.
|
186
|
+
config.email_regexp = /\A[^@\s]+@[^@\s]+\z/
|
187
|
+
|
188
|
+
# ==> Configuration for :timeoutable
|
189
|
+
# The time you want to timeout the user session without activity. After this
|
190
|
+
# time the user will be asked for credentials again. Default is 30 minutes.
|
191
|
+
# config.timeout_in = 30.minutes
|
192
|
+
|
193
|
+
# ==> Configuration for :lockable
|
194
|
+
# Defines which strategy will be used to lock an account.
|
195
|
+
# :failed_attempts = Locks an account after a number of failed attempts to sign in.
|
196
|
+
# :none = No lock strategy. You should handle locking by yourself.
|
197
|
+
# config.lock_strategy = :failed_attempts
|
198
|
+
|
199
|
+
# Defines which key will be used when locking and unlocking an account
|
200
|
+
# config.unlock_keys = [:email]
|
201
|
+
|
202
|
+
# Defines which strategy will be used to unlock an account.
|
203
|
+
# :email = Sends an unlock link to the user email
|
204
|
+
# :time = Re-enables login after a certain amount of time (see :unlock_in below)
|
205
|
+
# :both = Enables both strategies
|
206
|
+
# :none = No unlock strategy. You should handle unlocking by yourself.
|
207
|
+
# config.unlock_strategy = :both
|
208
|
+
|
209
|
+
# Number of authentication tries before locking an account if lock_strategy
|
210
|
+
# is failed attempts.
|
211
|
+
# config.maximum_attempts = 20
|
212
|
+
|
213
|
+
# Time interval to unlock the account if :time is enabled as unlock_strategy.
|
214
|
+
# config.unlock_in = 1.hour
|
215
|
+
|
216
|
+
# Warn on the last attempt before the account is locked.
|
217
|
+
# config.last_attempt_warning = true
|
218
|
+
|
219
|
+
# ==> Configuration for :recoverable
|
220
|
+
#
|
221
|
+
# Defines which key will be used when recovering the password for an account
|
222
|
+
# config.reset_password_keys = [:email]
|
223
|
+
|
224
|
+
# Time interval you can reset your password with a reset password key.
|
225
|
+
# Don't put a too small interval or your users won't have the time to
|
226
|
+
# change their passwords.
|
227
|
+
config.reset_password_within = 6.hours
|
228
|
+
|
229
|
+
# When set to false, does not sign a user in automatically after their password is
|
230
|
+
# reset. Defaults to true, so a user is signed in automatically after a reset.
|
231
|
+
# config.sign_in_after_reset_password = true
|
232
|
+
|
233
|
+
# ==> Configuration for :encryptable
|
234
|
+
# Allow you to use another hashing or encryption algorithm besides bcrypt (default).
|
235
|
+
# You can use :sha1, :sha512 or algorithms from others authentication tools as
|
236
|
+
# :clearance_sha1, :authlogic_sha512 (then you should set stretches above to 20
|
237
|
+
# for default behavior) and :restful_authentication_sha1 (then you should set
|
238
|
+
# stretches to 10, and copy REST_AUTH_SITE_KEY to pepper).
|
239
|
+
#
|
240
|
+
# Require the `devise-encryptable` gem when using anything other than bcrypt
|
241
|
+
# config.encryptor = :sha512
|
242
|
+
|
243
|
+
# ==> Scopes configuration
|
244
|
+
# Turn scoped views on. Before rendering "sessions/new", it will first check for
|
245
|
+
# "users/sessions/new". It's turned off by default because it's slower if you
|
246
|
+
# are using only default views.
|
247
|
+
config.scoped_views = true
|
248
|
+
|
249
|
+
# Configure the default scope given to Warden. By default it's the first
|
250
|
+
# devise role declared in your routes (usually :user).
|
251
|
+
# config.default_scope = :user
|
252
|
+
|
253
|
+
# Set this configuration to false if you want /users/sign_out to sign out
|
254
|
+
# only the current scope. By default, Devise signs out all scopes.
|
255
|
+
# config.sign_out_all_scopes = true
|
256
|
+
|
257
|
+
# ==> Navigation configuration
|
258
|
+
# Lists the formats that should be treated as navigational. Formats like
|
259
|
+
# :html should redirect to the sign in page when the user does not have
|
260
|
+
# access, but formats like :xml or :json, should return 401.
|
261
|
+
#
|
262
|
+
# If you have any extra navigational formats, like :iphone or :mobile, you
|
263
|
+
# should add them to the navigational formats lists.
|
264
|
+
#
|
265
|
+
# The "*/*" below is required to match Internet Explorer requests.
|
266
|
+
# config.navigational_formats = ['*/*', :html, :turbo_stream]
|
267
|
+
|
268
|
+
# The default HTTP method used to sign out a resource. Default is :delete.
|
269
|
+
config.sign_out_via = :delete
|
270
|
+
|
271
|
+
# ==> OmniAuth
|
272
|
+
# Add a new OmniAuth provider. Check the wiki for more information on setting
|
273
|
+
# up on your models and hooks.
|
274
|
+
# config.omniauth :github, 'APP_ID', 'APP_SECRET', scope: 'user,public_repo'
|
275
|
+
|
276
|
+
# ==> Warden configuration
|
277
|
+
# If you want to use other strategies, that are not supported by Devise, or
|
278
|
+
# change the failure app, you can configure them inside the config.warden block.
|
279
|
+
#
|
280
|
+
# config.warden do |manager|
|
281
|
+
# manager.intercept_401 = false
|
282
|
+
# manager.default_strategies(scope: :user).unshift :some_external_strategy
|
283
|
+
# end
|
284
|
+
|
285
|
+
# ==> Mountable engine configurations
|
286
|
+
# When using Devise inside an engine, let's call it `MyEngine`, and this engine
|
287
|
+
# is mountable, there are some extra configurations to be taken into account.
|
288
|
+
# The following options are available, assuming the engine is mounted as:
|
289
|
+
#
|
290
|
+
# mount MyEngine, at: '/my_engine'
|
291
|
+
#
|
292
|
+
# The router that invoked `devise_for`, in the example above, would be:
|
293
|
+
# config.router_name = :my_engine
|
294
|
+
#
|
295
|
+
# When using OmniAuth, Devise cannot automatically set OmniAuth path,
|
296
|
+
# so you need to do it manually. For the users scope, it would be:
|
297
|
+
# config.omniauth_path_prefix = '/my_engine/users/auth'
|
298
|
+
|
299
|
+
# ==> Hotwire/Turbo configuration
|
300
|
+
# When using Devise with Hotwire/Turbo, the http status for error responses
|
301
|
+
# and some redirects must match the following. The default in Devise for existing
|
302
|
+
# apps is `200 OK` and `302 Found` respectively, but new apps are generated with
|
303
|
+
# these new defaults that match Hotwire/Turbo behavior.
|
304
|
+
# Note: These might become the new default in future versions of Devise.
|
305
|
+
config.responder.error_status = :unprocessable_entity
|
306
|
+
config.responder.redirect_status = :see_other
|
307
|
+
|
308
|
+
# ==> Configuration for :registerable
|
309
|
+
|
310
|
+
# When set to false, does not sign a user in automatically after their password is
|
311
|
+
# changed. Defaults to true, so a user is signed in automatically after changing a password.
|
312
|
+
# config.sign_in_after_change_password = true
|
313
|
+
<% if features.include?('two_factor_authentication') %>
|
314
|
+
# ==> Devise OTP Extension
|
315
|
+
# Configure OTP extension for devise
|
316
|
+
|
317
|
+
# OTP is mandatory, users are going to be asked to
|
318
|
+
# enroll OTP the next time they sign in, before they can successfully complete the session establishment.
|
319
|
+
# This is the global value, can also be set on each user.
|
320
|
+
#config.otp_mandatory = false
|
321
|
+
|
322
|
+
# Drift: a window which provides allowance for drift between a user's token device clock
|
323
|
+
# (and therefore their OTP tokens) and the authentication server's clock.
|
324
|
+
# Expressed in minutes centered at the current time. (Note: it's a number, *NOT* 3.minutes )
|
325
|
+
#config.otp_drift_window = 3
|
326
|
+
|
327
|
+
# Users that have logged in longer than this time ago, are going to be asked their password
|
328
|
+
# (and an OTP challenge, if enabled) before they can see or change their otp informations.
|
329
|
+
#config.otp_credentials_refresh = 15.minutes
|
330
|
+
|
331
|
+
# Users are given a list of one-time recovery tokens, for emergency access
|
332
|
+
# set to false to disable giving recovery tokens.
|
333
|
+
#config.otp_recovery_tokens = 10
|
334
|
+
|
335
|
+
# The user is allowed to set his browser as "trusted", no more OTP challenges will be
|
336
|
+
# asked for that browser, for a limited time.
|
337
|
+
# set to false to disable setting the browser as trusted
|
338
|
+
#config.otp_trust_persistence = 1.month
|
339
|
+
|
340
|
+
# The name of the token issuer, to be added to the provisioning
|
341
|
+
# url. Display will vary based on token application. (defaults to the Rails application class)
|
342
|
+
#config.otp_issuer = 'my_application'
|
343
|
+
|
344
|
+
# Custom view path for Devise OTP controllers
|
345
|
+
#config.otp_controller_path = 'devise'
|
346
|
+
<% end %>
|
347
|
+
<% if features.include?('invitations') %>
|
348
|
+
# ==> Configuration for :invitable
|
349
|
+
# The period the generated invitation token is valid.
|
350
|
+
# After this period, the invited resource won't be able to accept the invitation.
|
351
|
+
# When invite_for is 0 (the default), the invitation won't expire.
|
352
|
+
# config.invite_for = 2.weeks
|
353
|
+
|
354
|
+
# Number of invitations users can send.
|
355
|
+
# - If invitation_limit is nil, there is no limit for invitations, users can
|
356
|
+
# send unlimited invitations, invitation_limit column is not used.
|
357
|
+
# - If invitation_limit is 0, users can't send invitations by default.
|
358
|
+
# - If invitation_limit n > 0, users can send n invitations.
|
359
|
+
# You can change invitation_limit column for some users so they can send more
|
360
|
+
# or less invitations, even with global invitation_limit = 0
|
361
|
+
# Default: nil
|
362
|
+
# config.invitation_limit = 5
|
363
|
+
|
364
|
+
# The key to be used to check existing users when sending an invitation
|
365
|
+
# and the regexp used to test it when validate_on_invite is not set.
|
366
|
+
# config.invite_key = { email: /\A[^@]+@[^@]+\z/ }
|
367
|
+
# config.invite_key = { email: /\A[^@]+@[^@]+\z/, username: nil }
|
368
|
+
|
369
|
+
# Ensure that invited record is valid.
|
370
|
+
# The invitation won't be sent if this check fails.
|
371
|
+
# Default: false
|
372
|
+
# config.validate_on_invite = true
|
373
|
+
|
374
|
+
# Resend invitation if user with invited status is invited again
|
375
|
+
# Default: true
|
376
|
+
# config.resend_invitation = false
|
377
|
+
|
378
|
+
# The class name of the inviting model. If this is nil,
|
379
|
+
# the #invited_by association is declared to be polymorphic.
|
380
|
+
# Default: nil
|
381
|
+
# config.invited_by_class_name = 'User'
|
382
|
+
|
383
|
+
# The foreign key to the inviting model (if invited_by_class_name is set)
|
384
|
+
# Default: :invited_by_id
|
385
|
+
# config.invited_by_foreign_key = :invited_by_id
|
386
|
+
|
387
|
+
# The column name used for counter_cache column. If this is nil,
|
388
|
+
# the #invited_by association is declared without counter_cache.
|
389
|
+
# Default: nil
|
390
|
+
# config.invited_by_counter_cache = :invitations_count
|
391
|
+
|
392
|
+
# Auto-login after the user accepts the invite. If this is false,
|
393
|
+
# the user will need to manually log in after accepting the invite.
|
394
|
+
# Default: true
|
395
|
+
# config.allow_insecure_sign_in_after_accept = false
|
396
|
+
<% end %>
|
397
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module WebammToRails
|
2
|
+
module Sources
|
3
|
+
module Migrations
|
4
|
+
class ActiveStorageDefinition
|
5
|
+
class Presenter
|
6
|
+
def initialize(waml_definition:)
|
7
|
+
@waml_definition = waml_definition
|
8
|
+
end
|
9
|
+
|
10
|
+
def file_name(migration_timestamp)
|
11
|
+
"db/migrate/#{migration_timestamp}_create_active_storage_tables.rb"
|
12
|
+
end
|
13
|
+
|
14
|
+
def render
|
15
|
+
template_path = File.expand_path('template.erb', __dir__)
|
16
|
+
template_content = File.read(template_path)
|
17
|
+
raw_content = ERB.new(template_content, trim_mode: '-').result(instance_eval { binding })
|
18
|
+
|
19
|
+
::WebammToRails::Utils::FormatCode.call(raw_content)
|
20
|
+
end
|
21
|
+
|
22
|
+
def render?
|
23
|
+
@waml_definition.database.schema.any? { |table| table.columns.any? { |column| column.type == 'file' } }
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# This migration comes from active_storage (originally 20170806125915)
|
2
|
+
class CreateActiveStorageTables < ActiveRecord::Migration[7.1]
|
3
|
+
def change
|
4
|
+
# Use Active Record's configured type for primary and foreign keys
|
5
|
+
primary_key_type, foreign_key_type = primary_and_foreign_key_types
|
6
|
+
|
7
|
+
create_table :active_storage_blobs, id: primary_key_type do |t|
|
8
|
+
t.string :key, null: false
|
9
|
+
t.string :filename, null: false
|
10
|
+
t.string :content_type
|
11
|
+
t.text :metadata
|
12
|
+
t.string :service_name, null: false
|
13
|
+
t.bigint :byte_size, null: false
|
14
|
+
t.string :checksum
|
15
|
+
|
16
|
+
if connection.supports_datetime_with_precision?
|
17
|
+
t.datetime :created_at, precision: 6, null: false
|
18
|
+
else
|
19
|
+
t.datetime :created_at, null: false
|
20
|
+
end
|
21
|
+
|
22
|
+
t.index [ :key ], unique: true
|
23
|
+
end
|
24
|
+
|
25
|
+
create_table :active_storage_attachments, id: primary_key_type do |t|
|
26
|
+
t.string :name, null: false
|
27
|
+
t.references :record, null: false, polymorphic: true, index: false, type: foreign_key_type
|
28
|
+
t.references :blob, null: false, type: foreign_key_type
|
29
|
+
|
30
|
+
if connection.supports_datetime_with_precision?
|
31
|
+
t.datetime :created_at, precision: 6, null: false
|
32
|
+
else
|
33
|
+
t.datetime :created_at, null: false
|
34
|
+
end
|
35
|
+
|
36
|
+
t.index [ :record_type, :record_id, :name, :blob_id ], name: :index_active_storage_attachments_uniqueness, unique: true
|
37
|
+
t.foreign_key :active_storage_blobs, column: :blob_id
|
38
|
+
end
|
39
|
+
|
40
|
+
create_table :active_storage_variant_records, id: primary_key_type do |t|
|
41
|
+
t.belongs_to :blob, null: false, index: false, type: foreign_key_type
|
42
|
+
t.string :variation_digest, null: false
|
43
|
+
|
44
|
+
t.index [ :blob_id, :variation_digest ], name: :index_active_storage_variant_records_uniqueness, unique: true
|
45
|
+
t.foreign_key :active_storage_blobs, column: :blob_id
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
def primary_and_foreign_key_types
|
51
|
+
config = Rails.configuration.generators
|
52
|
+
setting = config.options[config.orm][:primary_key_type]
|
53
|
+
primary_key_type = setting || :primary_key
|
54
|
+
foreign_key_type = setting || :bigint
|
55
|
+
[ primary_key_type, foreign_key_type ]
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module WebammToRails
|
2
|
+
module Sources
|
3
|
+
module Migrations
|
4
|
+
class Associations
|
5
|
+
def initialize(table_definition:, waml_definition:)
|
6
|
+
@table_definition = table_definition
|
7
|
+
@waml_definition = waml_definition
|
8
|
+
end
|
9
|
+
|
10
|
+
def collection
|
11
|
+
base_associations = associations.map do |assoc|
|
12
|
+
if assoc.type == 'belongs_to'
|
13
|
+
relation_table_definition = find_table_definition(assoc.destination)
|
14
|
+
assoc_def = "t.references :#{assoc.destination}, foreign_key: true, null: #{!assoc.required}"
|
15
|
+
assoc_def += ", type: :uuid" if relation_table_definition.options&.use_uuid
|
16
|
+
assoc_def
|
17
|
+
elsif assoc.type == 'parent_children'
|
18
|
+
assoc_def = "t.references :parent, foreign_key: { to_table: :#{@table_definition.table} }, null: true"
|
19
|
+
assoc_def += ", type: :uuid" if @table_definition.options&.use_uuid
|
20
|
+
assoc_def
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
return base_associations unless @table_definition.options&.habtm
|
25
|
+
|
26
|
+
habtm_tables = @table_definition.options.habtm_tables
|
27
|
+
|
28
|
+
base_associations << "t.belongs_to :#{habtm_tables.first}"
|
29
|
+
base_associations << "t.belongs_to :#{habtm_tables.second}"
|
30
|
+
|
31
|
+
base_associations
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
def associations
|
37
|
+
@waml_definition.database.relationships.select do |relationship|
|
38
|
+
(relationship.type == 'belongs_to' || relationship.type == 'parent_children') &&
|
39
|
+
relationship.source == @table_definition.table
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def find_table_definition(table_name)
|
44
|
+
@waml_definition.database.schema.find { |table| table.table == table_name }
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module WebammToRails
|
2
|
+
module Sources
|
3
|
+
module Migrations
|
4
|
+
class ClassDefinition
|
5
|
+
class Presenter
|
6
|
+
def initialize(table_name:)
|
7
|
+
@table_name = table_name
|
8
|
+
end
|
9
|
+
|
10
|
+
def render(rails_version: '7.1')
|
11
|
+
"class Create#{@table_name.classify.pluralize} < ActiveRecord::Migration[#{rails_version}]"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module WebammToRails
|
2
|
+
module Sources
|
3
|
+
module Migrations
|
4
|
+
class ColumnDefinition
|
5
|
+
class Presenter
|
6
|
+
def initialize(column:)
|
7
|
+
@column = column
|
8
|
+
end
|
9
|
+
|
10
|
+
def render
|
11
|
+
return if @column.type == 'file'
|
12
|
+
|
13
|
+
if @column.type == 'enum_column'
|
14
|
+
base_def = "t.integer :#{@column.name}, null: #{@column.null}"
|
15
|
+
|
16
|
+
if @column.default.present?
|
17
|
+
index_of_default = @column.values.index(@column.default)
|
18
|
+
base_def += ", default: #{index_of_default}"
|
19
|
+
end
|
20
|
+
|
21
|
+
base_def
|
22
|
+
else
|
23
|
+
base_def = "t.#{@column.type} :#{@column.name}, null: #{@column.null}"
|
24
|
+
|
25
|
+
if @column.default.present? && @column.type == 'string'
|
26
|
+
base_def += ", default: '#{@column.default}'"
|
27
|
+
elsif @column.default.present?
|
28
|
+
base_def += ", default: #{@column.default}"
|
29
|
+
end
|
30
|
+
|
31
|
+
base_def
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require_relative 'column_definition/presenter'
|
2
|
+
require_relative 'devise/definition'
|
3
|
+
|
4
|
+
module WebammToRails
|
5
|
+
module Sources
|
6
|
+
module Migrations
|
7
|
+
class Columns
|
8
|
+
def initialize(waml_definition:, table_definition:)
|
9
|
+
@waml_definition = waml_definition
|
10
|
+
@table_definition = table_definition
|
11
|
+
end
|
12
|
+
|
13
|
+
def collection
|
14
|
+
columns.compact.uniq(&:name).map do |column|
|
15
|
+
::WebammToRails::Sources::Migrations::ColumnDefinition::Presenter.new(column: column).render
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def columns
|
22
|
+
@table_definition.columns + devise_columns
|
23
|
+
end
|
24
|
+
|
25
|
+
def devise_columns
|
26
|
+
::WebammToRails::Sources::Migrations::Devise::Definition.new(
|
27
|
+
waml_definition: @waml_definition, table_name: @table_definition.table
|
28
|
+
).columns_collection
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require_relative 'class_definition/presenter'
|
2
|
+
require_relative 'table_definition/presenter'
|
3
|
+
require_relative 'columns'
|
4
|
+
require_relative 'indices'
|
5
|
+
require_relative 'associations'
|
6
|
+
|
7
|
+
module WebammToRails
|
8
|
+
module Sources
|
9
|
+
module Migrations
|
10
|
+
class Definition
|
11
|
+
def initialize(table_definition:, waml_definition:)
|
12
|
+
@table_definition = table_definition
|
13
|
+
@waml_definition = waml_definition
|
14
|
+
end
|
15
|
+
|
16
|
+
def render
|
17
|
+
template_path = File.expand_path('template.erb', __dir__)
|
18
|
+
template_content = File.read(template_path)
|
19
|
+
raw_content = ERB.new(template_content, trim_mode: '-').result(instance_eval { binding })
|
20
|
+
|
21
|
+
::WebammToRails::Utils::FormatCode.call(raw_content)
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def class_definition
|
27
|
+
::WebammToRails::Sources::Migrations::ClassDefinition::Presenter.new(table_name: table_name).render
|
28
|
+
end
|
29
|
+
|
30
|
+
def table_name
|
31
|
+
@table_definition.table
|
32
|
+
end
|
33
|
+
|
34
|
+
def table_definition
|
35
|
+
::WebammToRails::Sources::Migrations::TableDefinition::Presenter.new(table_definition: @table_definition).render
|
36
|
+
end
|
37
|
+
|
38
|
+
def columns
|
39
|
+
::WebammToRails::Sources::Migrations::Columns.new(waml_definition: @waml_definition, table_definition: @table_definition).collection
|
40
|
+
end
|
41
|
+
|
42
|
+
def indices
|
43
|
+
::WebammToRails::Sources::Migrations::Indices.new(waml_definition: @waml_definition, table_definition: @table_definition).collection
|
44
|
+
end
|
45
|
+
|
46
|
+
def associations
|
47
|
+
::WebammToRails::Sources::Migrations::Associations.new(table_definition: @table_definition, waml_definition: @waml_definition).collection
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|