Class: Yolo::Notify::Ios::OTAEmail

Inherits:
Email
  • Object
show all
Defined in:
lib/yolo/notify/ios/ota_email.rb

Overview

OTAEmail generates an HTML email for OTA build notifications

Author:

  • Alex Fish

Instance Attribute Summary

Attributes inherited from Email

#account, #from, #password, #port, #server, #to

Instance Method Summary collapse

Methods inherited from Email

#initialize, #send

Constructor Details

This class inherits a constructor from Yolo::Notify::Email

Instance Method Details

#body(opts) ⇒ Object

The OTA Email body content, this content is generated using release_notes.md and an HTML email template in the same directory (email.html)

Parameters:

  • opts (Hash)

    The options hash from super



18
19
20
21
22
23
24
25
26
# File 'lib/yolo/notify/ios/ota_email.rb', line 18

def body(opts)
  message = <<MESSAGE_END
MIME-Version: 1.0
Content-type: text/html
Subject: #{opts[:subject]}

#{parsed_body(opts)}
MESSAGE_END
end

#parsed_body(opts) ⇒ String

Returns HTML ready to be used in the email body, HTML is generated by parsing the email.html template and applying realease_notes.md content

Parameters:

  • opts (Hash)

    The options hash from super

Returns:

  • (String)

    HTML body content for emailing



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/yolo/notify/ios/ota_email.rb', line 34

def parsed_body(opts)
  file = File.open(File.dirname(__FILE__) + "/email.html", "r")
  content = file.read
  markdown = Yolo::Tools::Ios::ReleaseNotes.html

  content = content.gsub("YOLO.TITLE",opts[:title])
  content = content.gsub("YOLO.CONTENT",markdown)
  if opts[:ota_password] and opts[:ota_password].length > 0
    content = content.gsub("YOLO.PASSWORD","<h3>Password</h3><hr><p>#{opts[:ota_password]}</p>")
  else
    content = content.gsub("YOLO.PASSWORD","")
  end
  content = content.gsub("YOLO.LINK",opts[:ota_url])
  content
end