This repository has been archived by the owner on Nov 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Rakefile
62 lines (51 loc) · 1.62 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
version_string = `git describe --tag | cut -d "-" -f 1,2 | tr - .`.chomp
if version_string.empty?
version_string = '0'
end
date_string = Time.now.strftime("%Y-%m-%d")
params = "--attribute revnumber='#{version_string}' --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"