Sha256: e5d89358122d173228b543a991693da91279d3fd264899e33b79a7293378a02a

Contents?: true

Size: 1.4 KB

Versions: 3

Compression:

Stored size: 1.4 KB

Contents

module DiscoApp
  module Generators
    class MailifyGenerator < Rails::Generators::Base

      source_root File.expand_path('../templates', __FILE__)

      def install_gem
        # Add premailer gem to Gemfile.
        gem 'premailer-rails', '~> 1.8.2'

        # Add explicit dependency on Nokogiri
        gem 'nokogiri', '~> 1.6.6.1'

        # Add the Mailgun rails gem (production only)
        gem_group :production do
          gem 'mailgun_rails', '~> 0.7.0'
        end

        # Install gem.
        Bundler.with_clean_env do
          run 'bundle install'
        end
      end

      # Set application configuration
      def configure_application
        configuration = <<-CONFIG.strip_heredoc

          # Configure ActionMailer to use MailGun
          if ENV['MAILGUN_API_KEY']
            config.action_mailer.delivery_method = :mailgun
            config.action_mailer.mailgun_settings = {
              api_key: ENV['MAILGUN_API_KEY'],
              domain: ENV['MAILGUN_API_DOMAIN']
            }
          end
        CONFIG
        application configuration, env: :production
      end

      # Add entries to .env and .env.sample
      def add_env_variables
        configuration = <<-CONFIG.strip_heredoc

          MAILGUN_API_KEY=
          MAILGUN_API_DOMAIN=
        CONFIG
        append_to_file '.env', configuration
        append_to_file '.env.sample', configuration
      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
disco_app-0.6.3 lib/generators/disco_app/mailify/mailify_generator.rb
disco_app-0.6.4 lib/generators/disco_app/mailify/mailify_generator.rb
disco_app-0.6.5 lib/generators/disco_app/mailify/mailify_generator.rb