class Mail2FrontMatter::Writer
Public Class Methods
write(metadata, body)
click to toggle source
# File lib/mail2frontmatter/writer.rb, line 14 def self.write(metadata, 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 metadata[:title] ||= metadata[:subject] # make a sensible standard blog filename unless one is given metadata[:filename] ||= [metadata[:received].strftime('%Y-%m-%d'), '-', metadata[:subject].parameterize, '.html.erb'].join metadata[:filepath] ||= File.join(Mail2FrontMatter.config[:data_directory], metadata[:filename]) data = metadata.to_yaml + "---\n" + body File.write(metadata[:filepath], data) end