Class: Draft

Inherits:
Diary::Item show all
Defined in:
lib/diary/draft.rb

Constant Summary collapse

@@base_directory =
'drafts'

Constants inherited from Diary::Item

Diary::Item::ACCENTS

Constants included from Diary::Message

Diary::Message::Create, Diary::Message::Error, Diary::Message::Exist, Diary::Message::Identical, Diary::Message::Invoke, Diary::Message::Publish, Diary::Message::Skip, Diary::Message::Update

Instance Attribute Summary

Attributes inherited from Diary::Item

#file

Instance Method Summary collapse

Methods inherited from Diary::Item

all, #data, #directory, first, #initialize, last, #path, #slug, #title

Methods included from Diary::Message

#say

Constructor Details

This class inherits a constructor from Diary::Item

Instance Method Details

#publish(date = Date.today) ⇒ Object



4
5
6
7
8
9
10
11
12
13
# File 'lib/diary/draft.rb', line 4

def publish(date = Date.today)
  to   = File.join(Post.class_variable_get(:@@base_directory), *date.to_s.split('-'))

  FileUtils.mkpath  to
  FileUtils.mv      path, to

  say Publish, File.join(to, "#{slug}.md")
rescue Errno::ENOENT
  say Error, "No draft found"
end