Class: Celebrations::Mailer

Inherits:
Celebration show all
Includes:
Announce
Defined in:
lib/release_party/celebrations/mailer.rb

Defined Under Namespace

Classes: MailEnvironment

Instance Attribute Summary collapse

Attributes inherited from Celebration

#environment

Instance Method Summary collapse

Methods included from Announce

#announce

Methods inherited from Celebration

#before_deploy, inherited, #tasks

Constructor Details

#initialize(env) ⇒ Mailer

Returns a new instance of Mailer.

Raises:

  • (ArgumentError)


44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# 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

Instance Attribute Details

#engineObject (readonly)

Returns the value of attribute engine.



42
43
44
# File 'lib/release_party/celebrations/mailer.rb', line 42

def engine
  @engine
end

Instance Method Details

#after_deployObject



76
77
78
# File 'lib/release_party/celebrations/mailer.rb', line 76

def after_deploy
  deliver_notification
end