-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuild.rb
34 lines (27 loc) · 910 Bytes
/
build.rb
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
def pretty_file_name(name)
name.gsub('-', ' ').split.map(&:capitalize).join(' ')
end
def header
<<STRING
[This Post](https://github.com/jbranchaud/til) motivated me to start keeping track of small technology related things I learn.\n
STRING
end
subjects = Dir.glob('*').select { |f| File.directory? f }
sub_file_hash = subjects.each_with_object({}) do |sub, hsh|
hsh[sub] = Dir.entries(sub).select { |f| !File.directory? f }
end
readme = File.open('README.md', 'w+')
readme.write("# TIL \n")
readme.write("> Today I Learned \n")
readme.write("\n")
readme.write(header)
readme.write("### Categories\n")
subjects.each { |s| readme.write "- [#{s.capitalize}](##{s})\n"}
readme.write("\n")
sub_file_hash.each do |sub, files|
readme.write "\n"
readme.write "--- \n"
readme.write "### #{sub.capitalize}\n"
files.each {|f| readme.write "- [#{pretty_file_name(f)}](#{sub}/#{f})\n"}
end
readme.close