class Celebrations::Mailer

Attributes

engine[R]

Public Class Methods

new(env) click to toggle source
Calls superclass method Celebration::new
# File lib/release_party/celebrations/mailer.rb, line 44
def initialize(env)
  super env
  arguments_required(:template_engine, :template, :smtp_address, :smtp_port,
                    :from_address, :email_notification_to, :subject)

  require 'mail'

  template = env.template
  raise ArgumentError, "Missing template file #{template}" unless File.exists?(template)

  @engine = \
    case environment.template_engine
    when :haml
      require 'haml'
      Haml::Engine.new(File.read(template))

    when :erb
      require 'erb'
      ERB.new(File.read(template))

    else
      raise ArgumentError, "Unsupported template engine #{environment.template_engine}"
    end

  address = environment.smtp_address
  port = environment.smtp_port
  domain = environment.smtp_domain
  Mail.defaults do
    delivery_method :smtp, :address => address, :port => port, :domain => domain
  end
end

Public Instance Methods

after_deploy() click to toggle source
# File lib/release_party/celebrations/mailer.rb, line 76
def after_deploy
  deliver_notification
end