forked from dxw/contracts
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcompile
More file actions
executable file
·38 lines (29 loc) · 881 Bytes
/
compile
File metadata and controls
executable file
·38 lines (29 loc) · 881 Bytes
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
#! /usr/bin/env ruby
require 'kramdown'
#
# Make sure we have the directories
#
agreements = "#{File.dirname(__FILE__)}/agreements"
#puts agreements
unless File.exists?(agreements)
STDERR.puts("Couldn't find the agreements directory at: #{agreements}")
exit 1
end
build = "#{File.dirname(__FILE__)}/build"
unless File.exists?(build)
STDERR.puts("Couldn't find the build directory at: #{build}")
exit 1
end
html = "#{File.dirname(__FILE__)}/html"
unless File.exists?(html)
STDERR.puts("Couldn't find the html directory at: #{html}")
exit 1
end
Dir.entries(agreements).each do |file|
next if file[0] == '.'[0] # fix for ruby 1.8.7
content =
File.read("#{html}/top.html") +
Kramdown::Document.new(File.read("#{agreements}/#{file}")).to_html +
File.read("#{html}/bottom.html")
File.open("#{build}/#{file}.html", 'w') { |f| f.write(content) }
end