Class: Postmortem::Delivery

Inherits:
Object
  • Object
show all
Defined in:
lib/postmortem/delivery.rb

Overview

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(mail) ⇒ Delivery

Returns a new instance of Delivery.



8
9
10
11
12
13
# 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

Instance Attribute Details

#index_pathObject (readonly)

Returns the value of attribute index_path.



6
7
8
# File 'lib/postmortem/delivery.rb', line 6

def index_path
  @index_path
end

#pathObject (readonly)

Returns the value of attribute path.



6
7
8
# File 'lib/postmortem/delivery.rb', line 6

def path
  @path
end

Instance Method Details

#recordObject



15
16
17
18
19
20
21
# 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

#uriObject



23
24
25
# File 'lib/postmortem/delivery.rb', line 23

def uri
  "file://#{path}##{@mail.id}"
end