Class: Mail2FrontMatter::Writer

Inherits:
Object
  • Object
show all
Defined in:
lib/mail2frontmatter/writer.rb

Class Method Summary collapse

Class Method Details

.write(metadata, body) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/mail2frontmatter/writer.rb', line 15

def self.write(, body)
  # MAPPINGS!
  # 
  # Play nice with programs which will read this data
  # And set sensible defaults as fall throughs

  # if there is no title set, borrow the subject lines
  [:title] ||= [:subject]

  # make a sensible standard blog filename unless one is given
  [:filename] ||= [[:received].strftime("%Y-%m-%d"), '-', [:subject].parameterize, '.html.erb'].join

  data = .to_yaml + "---\n" + body

  File.write(File.join(Mail2FrontMatter.config[:data_directory], [:filename]), data)
end