forked from vmware-archive/glossary
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
40 lines (32 loc) · 786 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
require 'fileutils'
require 'yaml'
task default: %w[build]
task :build do
FileUtils.rm_rf('build')
FileUtils.mkdir_p('build')
`ruby ./build.rb > build/index.html`
`ruby ./build_words_json.rb > build/words.json`
`sass "src/scss/styles.scss" "build/styles.css"`
end
task :add_word, [:word] do |t, args|
word = args[:word]
outfile = "entries/#{word}.yml"
if word.nil? || word.empty?
puts "word cannot be empty. Try `rake add_word[\"Pair Programming\"]`"
exit 1
end
if File.file?(outfile)
puts "File #{outfile} already exists."
exit 1
end
template = <<-TEMP
---
headword: #{word}
expansion:
definition:
links:
see_also:
TEMP
File.open(outfile, 'w') { |f| f.write(template) }
puts "New entry template created in #{outfile}"
end