class Postmortem::Delivery

Abstraction of an email delivery. Capable of writing email HTML body to disk.

Attributes

index_path[R]
path[R]

Public Class Methods

new(mail) click to toggle source
# File lib/postmortem/delivery.rb, line 8
def initialize(mail)
  @mail = mail
  @path = Postmortem.config.preview_directory.join('index.html')
  @index_path = Postmortem.config.preview_directory.join('postmortem_index.html')
  @identity_path = Postmortem.config.preview_directory.join('postmortem_identity.html')
end

Public Instance Methods

record() click to toggle source
# File lib/postmortem/delivery.rb, line 15
def record
  path.parent.mkpath
  content = Layout.new(@mail).content
  path.write(content)
  index_path.write(index.content)
  @identity_path.write(identity.content)
end
uri() click to toggle source
# File lib/postmortem/delivery.rb, line 23
def uri
  "file://#{path}##{@mail.id}"
end

Private Instance Methods

identity() click to toggle source
# File lib/postmortem/delivery.rb, line 33
def identity
  @identity ||= Identity.new
end
index() click to toggle source
# File lib/postmortem/delivery.rb, line 29
def index
  @index ||= Index.new(index_path, path, @mail)
end
safe_chars() click to toggle source
# File lib/postmortem/delivery.rb, line 47
def safe_chars
  ('a'..'z').to_a + ('A'..'Z').to_a + ('0'..'9').to_a + ['-', '_']
end
safe_subject() click to toggle source
# File lib/postmortem/delivery.rb, line 43
def safe_subject
  subject.tr(' ', '_').split('').select { |char| safe_chars.include?(char) }.join
end
subject() click to toggle source
# File lib/postmortem/delivery.rb, line 37
def subject
  return 'no-subject' if @mail.subject.nil? || @mail.subject.empty?

  @mail.subject
end