Class: Suspenders::Production::EmailGenerator

Inherits:
Generators::Base
  • Object
show all
Defined in:
lib/suspenders/generators/production/email_generator.rb

Instance Method Summary collapse

Methods inherited from Generators::Base

default_source_root

Methods included from Actions

#action_mailer_asset_host, #action_mailer_host, #configure_environment, #expand_json, #replace_in_file

Instance Method Details

#env_varsObject



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/suspenders/generators/production/email_generator.rb', line 24

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

#smtp_configurationObject



6
7
8
9
10
11
# File 'lib/suspenders/generators/production/email_generator.rb', line 6

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

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

#use_smtpObject



13
14
15
16
17
18
19
20
21
22
# File 'lib/suspenders/generators/production/email_generator.rb', line 13

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