-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathRakefile
47 lines (40 loc) · 1.03 KB
/
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
42
43
44
45
46
47
task :entry do
info = get_info(section_id: 'unique ID (intro)',
section_class: 'Section Class (h1)',
title: 'title (Introduction)',
is_parent: 'Is parent? Y/N',
parent_id: 'Parent id (eg: intro)',
number: 'Priority number (eg: 1000)')
text = "---
sectionid: #{info[:section_id]}
sectionclass: #{info[:section_class]}
title: #{info[:title]}
"
if info[:is_parent].downcase == 'y'
text = text + "is-parent: true
"
end
if info[:parent_id] != ""
text = text + "parent-id: #{info[:parent_id]}
"
end
text = text +"number: #{info[:number]}
---
"
filename = "#{info[:number]}-#{info[:section_id]}.md"
path = File.join('_entries', filename)
File.open(path, 'w') { |f| f << text }
end
task :deploy do
`git push origin master`
`git push origin master:gh-pages`
end
def get_info(qns)
qns.map { |k, qn|
[k, ask("#{qn}: ")]
}.to_h
end
def ask(qn)
STDOUT.print qn
STDIN.gets.chomp
end