-
Notifications
You must be signed in to change notification settings - Fork 1
/
Rakefile
62 lines (51 loc) · 1.67 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# Attempt to grab the date of the latest commit. If unable to, fail.
date_string = `git log -1 --pretty='format:%cd' --date=format:'%Y-%m-%d'`.chomp
if date_string.empty?
raise "Failed to get the date from the latest commit. Do you have access to the Git log?"
end
params = "--attribute revdate='#{date_string}'"
image_files = Rake::FileList.new("src/images/*.png", "src/images/*.svg") do |fl|
fl.exclude("~*")
fl.exclude(/^scratch\//)
end
namespace :spec do
directory 'build/images'
desc 'copy images to build dir'
task :images => 'build/images'
image_files.each do |source|
target = source.sub(/^src\/images/, 'build/images')
file target => source do
cp source, target, :verbose => true
`pngquant -f #{target}`
end
desc "copies all data files"
task :images => target
end
task :prereqs => [:images]
desc 'build basic spec formats'
task :html => :prereqs do
begin
puts "Converting to HTML..."
`bundle exec asciidoctor -b html5 #{params} src/main.adoc -o build/PartiQL-Specification.html`
end
end
task :pdf => :prereqs do
begin
theming = "-a pdf-themesdir=src/themes -a pdf-theme=basic -a pdf-fontsdir=fonts"
stem = "-r asciidoctor-mathematical -a mathematical-format=svg"
pdf_params = "-a compress"
puts "Converting to PDF..."
`bundle exec asciidoctor-pdf -v #{params} #{theming} #{stem} #{pdf_params} src/main.adoc -o build/PartiQL-Specification.pdf --trace`
end
end
task :build => [:html, :pdf]
task :watch do
begin
`bundle exec guard`
end
end
require 'rake/clean'
CLEAN.include('build/*')
CLOBBER.include('build/*')
end
task :default => "spec:build"