Class: IPASend::SESNotifier

Inherits:
Object
  • Object
show all
Defined in:
lib/ipasend/ses_notifier.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ SESNotifier

Returns a new instance of SESNotifier.



8
9
10
11
12
13
14
15
# File 'lib/ipasend/ses_notifier.rb', line 8

def initialize(options)
  @ses = AWS::SimpleEmailService.new(
    :access_key_id => options.aws_key,
    :secret_access_key => options.aws_secret
  )
  @from = options.from
  @emails = options.notify
end

Instance Attribute Details

#display_nameObject

Returns the value of attribute display_name.



6
7
8
# File 'lib/ipasend/ses_notifier.rb', line 6

def display_name
  @display_name
end

Instance Method Details

#notify(ipa, url) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/ipasend/ses_notifier.rb', line 17

def notify(ipa, url)
  subject = "New build of #{display_name || ipa.name} #{ipa.bundle_short_version} (#{ipa.bundle_version})"

  template = ERB.new(open(File.join(IPASend.template_dir, 'email.txt.erb')).read)
  message = template.result(binding)
  for email in @emails do
    begin
      @ses.send_email(:subject => subject, :from => @from, :to => email, :body_text => message)
      puts "### Notified #{email}"
    rescue => e
      puts "!!! Cannot send email to #{email}: #{e.message}"
    end
  end
end