22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/diary/item/creator.rb', line 22
def create(title_or_path)
path_fragments = title_or_path.split("/")
title = path_fragments.pop
path_fragments << title.parameterize
path = resolve_path(path_fragments.join("/"))
ensure_directories_exists!(path)
unless File.exists?(path)
File.open(path, "w+") do |f|
f.puts "---\n"
f.puts "title: #{title}"
f.puts "\n---\n"
end
Diary.message :create, path, :green
else
Diary.message :exist, path, :yellow
end
self.new(path)
end
|