Class: Texas::Build::Task::PublishPDF
- Inherits:
-
Script
show all
- Defined in:
- lib/texas/build/task/publish_pdf.rb
Overview
This build task compiles the generated *.tex files into a PDF.
Constant Summary
collapse
- DEFAULT_COMPILE_CMD =
'pdflatex -halt-on-error "<%= File.basename(build.master_file) %>"'
Instance Attribute Summary
Attributes inherited from Base
#build
Instance Method Summary
collapse
Methods inherited from Script
#cmd_from_config, #execute, #execute_in
Methods inherited from Base
#initialize
#trace, #verbose, #warning
Instance Method Details
#build_path ⇒ Object
9
10
11
|
# File 'lib/texas/build/task/publish_pdf.rb', line 9
def build_path
build.__path__
end
|
#compile_cmd ⇒ Object
40
41
42
|
# File 'lib/texas/build/task/publish_pdf.rb', line 40
def compile_cmd
cmd_from_config :compile, DEFAULT_COMPILE_CMD
end
|
#compile_pdf ⇒ Object
44
45
46
|
# File 'lib/texas/build/task/publish_pdf.rb', line 44
def compile_pdf
execute compile_cmd
end
|
#compile_pdf_successfull? ⇒ Boolean
28
29
30
|
# File 'lib/texas/build/task/publish_pdf.rb', line 28
def compile_pdf_successfull?
$?.to_i == 0
end
|
#copy_pdf_file_to_dest_dir ⇒ Object
32
33
34
35
36
37
38
|
# File 'lib/texas/build/task/publish_pdf.rb', line 32
def copy_pdf_file_to_dest_dir
basename = File.basename(build.master_file, '.tex')
tmp_file = File.join(build_path, "#{basename}.pdf")
FileUtils.mkdir_p File.dirname(dest_file)
FileUtils.copy tmp_file, dest_file
verbose { verbose_info }
end
|
#dest_file ⇒ Object
13
14
15
|
# File 'lib/texas/build/task/publish_pdf.rb', line 13
def dest_file
build.dest_file
end
|
#run ⇒ Object
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/texas/build/task/publish_pdf.rb', line 17
def run
latex_cmd_output = compile_pdf
if compile_pdf_successfull?
compile_pdf copy_pdf_file_to_dest_dir
else
trace latex_cmd_output
raise "Error while running: `#{compile_cmd.cyan}`"
end
end
|
#tex_log_file ⇒ Object
48
49
50
|
# File 'lib/texas/build/task/publish_pdf.rb', line 48
def tex_log_file
File.join(build_path, "master.log")
end
|
#verbose_info ⇒ Object
52
53
54
55
56
57
|
# File 'lib/texas/build/task/publish_pdf.rb', line 52
def verbose_info
output = `grep "Output written on" #{tex_log_file}`
numbers = output.scan(/\((\d+?) pages?\, (\d+?) bytes\)\./).flatten
@page_count = numbers.first.to_i
verbose { TraceInfo.new(:written, "#{dest_file.gsub(build.root, '')} (#{@page_count} pages)", :magenta) }
end
|