Sha256: 73446aafc81d902aeb6ad3baaa7ed5e40162d43367051c3afbbda6016bd40224

Contents?: true

Size: 1.11 KB

Versions: 2

Compression:

Stored size: 1.11 KB

Contents

require "rails/generators"
require_relative "../../actions"

module Suspenders
  module Production
    class EmailGenerator < Rails::Generators::Base
      include Suspenders::Actions

      source_root File.expand_path(
        File.join("..", "..", "..", "..", "templates"),
        File.dirname(__FILE__),
      )

      def smtp_configuration
        copy_file "smtp.rb", "config/smtp.rb"

        prepend_file "config/environments/production.rb",
          %{require Rails.root.join("config/smtp")\n}
      end

      def use_smtp
        config = <<-RUBY

  config.action_mailer.delivery_method = :smtp
  config.action_mailer.smtp_settings = SMTP_SETTINGS
        RUBY

        inject_into_file "config/environments/production.rb", config,
          after: "config.action_mailer.perform_caching = false"
      end

      def env_vars
        expand_json(
          "app.json",
          env: {
            SMTP_ADDRESS: { required: true },
            SMTP_DOMAIN: { required: true },
            SMTP_PASSWORD: { required: true },
            SMTP_USERNAME: { required: true },
          },
        )
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
suspenders-1.50.0 lib/suspenders/generators/production/email_generator.rb
suspenders-1.49.0 lib/suspenders/generators/production/email_generator.rb