forked from cloudhead/dorothy
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Rakefile
42 lines (32 loc) · 883 Bytes
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
require 'toto'
@config = Toto::Config::Defaults
task :default => :new
desc "Create a new article."
task :new do
title = ask('Title: ')
slug = title.empty?? nil : title.strip.slugize
article = {'title' => title, 'date' => Time.now.strftime("%d/%m/%Y")}.to_yaml
article << "\n"
article << "Once upon a time...\n\n"
path = "#{Toto::Paths[:articles]}/#{Time.now.strftime("%Y-%m-%d")}#{'-' + slug if slug}.#{@config[:ext]}"
unless File.exist? path
File.open(path, "w") do |file|
file.write article
end
toto "an article was created for you at #{path}."
else
toto "I can't create the article, #{path} already exists."
end
end
desc "Publish my blog."
task :publish do
toto "publishing your article(s)..."
`git push heroku master`
end
def toto msg
puts "\n toto ~ #{msg}\n\n"
end
def ask message
print message
STDIN.gets.chomp
end