Class: Kowl::MailerGenerator
- Inherits:
-
Generators::Base
- Object
- Rails::Generators::Base
- Generators::Base
- Kowl::MailerGenerator
- Defined in:
- lib/kowl/generators/mailer_generator.rb
Instance Method Summary collapse
-
#add_mailer_assets ⇒ Object
Add the applications assets that need to be compiled for the mailer.
-
#copy_devise_mailer_config ⇒ Object
Add a devise mailer layout the application if devise is to be used.
-
#copy_mailer_layouts ⇒ Object
Add DeviseMailer layout view, to cleanup devise emails.
-
#override_application_mailer ⇒ Object
Override the applications default application_mailer file with some basic config.
-
#setup_letter_opener ⇒ Object
Setup letter_opener config and initializer to catch emails in development.
-
#setup_production_mailer ⇒ Object
Setup a mailer initializer for production, based on the application config.
Methods inherited from Generators::Base
default_source_root, source_paths
Methods included from Docker
#alpine_docker_dependencies, #app_js_volumes, #app_volumes, #db_volumes, #debian_database_dependencies, #debian_docker_dependencies, #docker_app_command, #docker_compose_database_string, #docker_databases, #docker_depends_on, #docker_port_watcher, #docker_redis_service, #docker_sidekiq_service, #docker_variables, #docker_volumes, #docker_webpacker_service, #dockerfile_database_args, #dockerfile_migration_snip, #js_volumes, #mysql_volumes, #postgresql_volumes, #redis_volumes
Methods included from Actions
#add_extension_routes, #add_package, #append_to_file, #database_route, #dev_config, #dup_file, #file_exists?, #mailer_gems, #mailer_route, #mk_dir, #move_file, #pry_gems, #rails_cmd, #remove_dir, #remove_file, #remove_gem, #replace_string_in_file, #robocop_test_engine, #sidekiq_route, #template_linter_gems
Instance Method Details
#add_mailer_assets ⇒ Object
Add the applications assets that need to be compiled for the mailer
31 32 33 34 |
# File 'lib/kowl/generators/mailer_generator.rb', line 31 def add_mailer_assets copy_file('app/assets/stylesheets/bootstrap/application-mailer.scss') add_to_assets('application-mailer.scss') end |
#copy_devise_mailer_config ⇒ Object
Add a devise mailer layout the application if devise is to be used
26 27 28 |
# File 'lib/kowl/generators/mailer_generator.rb', line 26 def copy_devise_mailer_config copy_file('app/mailers/devise_mailer.rb', 'app/mailers/devise_mailer.rb') unless [:noauth] end |
#copy_mailer_layouts ⇒ Object
Add DeviseMailer layout view, to cleanup devise emails
16 17 18 |
# File 'lib/kowl/generators/mailer_generator.rb', line 16 def copy_mailer_layouts copy_file('app/views/layouts/devise_mailer.html.erb', 'app/views/layouts/devise_mailer.html.erb') unless [:noauth] end |
#override_application_mailer ⇒ Object
Override the applications default application_mailer file with some basic config
21 22 23 |
# File 'lib/kowl/generators/mailer_generator.rb', line 21 def override_application_mailer copy_file 'app/mailers/application_mailer.rb', 'app/mailers/application_mailer.rb', force: true end |
#setup_letter_opener ⇒ Object
Setup letter_opener config and initializer to catch emails in development
37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/kowl/generators/mailer_generator.rb', line 37 def setup_letter_opener smtp_config = <<~LETTER_OPENER # Specify if you you have a preference which method you want SMTP responses to be handled in dev # config.action_mailer.delivery_method = :letter_opener config.action_mailer.delivery_method = :letter_opener_web config.action_mailer.perform_deliveries = true config.action_mailer.raise_delivery_errors = false LETTER_OPENER dev_config(smtp_config) copy_file('config/initializers/letter_opener.rb', 'config/initializers/letter_opener.rb') end |
#setup_production_mailer ⇒ Object
Setup a mailer initializer for production, based on the application config
50 51 52 53 54 55 56 |
# File 'lib/kowl/generators/mailer_generator.rb', line 50 def setup_production_mailer if [:mailer] == 'postmark' copy_file('config/initializers/postmark.rb', 'config/initializers/postmark.rb', force: true) else copy_file('config/initializers/sparkpost.rb', 'config/initializers/sparkpost.rb', force: true) end end |