Sha256: 78cf1b0cdf64ed5714766746ac9ec5e848966d64cfdd68f3b5f173f4e1f987c7

Contents?: true

Size: 1.12 KB

Versions: 5

Compression:

Stored size: 1.12 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.raise_delivery_errors = 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

5 entries across 5 versions & 2 rubygems

Version Path
welaika-suspenders-2.29.0 lib/suspenders/generators/production/email_generator.rb
suspenders-1.48.0 lib/suspenders/generators/production/email_generator.rb
welaika-suspenders-2.29.0.alpha.3 lib/suspenders/generators/production/email_generator.rb
welaika-suspenders-2.29.0.alpha.2 lib/suspenders/generators/production/email_generator.rb
welaika-suspenders-2.29.0.alpha.1 lib/suspenders/generators/production/email_generator.rb