Class: Mail2FrontMatter::Writer
- Inherits:
-
Object
- Object
- Mail2FrontMatter::Writer
- Defined in:
- lib/mail2frontmatter/writer.rb
Class Method Summary collapse
Class Method Details
.write(metadata, body) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/mail2frontmatter/writer.rb', line 14 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 [:filepath] ||= File.join(Mail2FrontMatter.config[:data_directory], [:filename]) data = .to_yaml + "---\n" + body File.write([:filepath], data) end |