platex が使える事が前提。
日本語に対応しています。
namespace :c do
task :default => "all"
task :setup do
@name = "plan_booklog"
end
task :tex1 =>[:setup] do
mkdir "output" unless File.exists? "output"
sh "platex -kanji=utf8 -output-directory=output #{@name}.tex"
end
task :bibtex do
if File.exists? File.join(File.dirname(__FILE__), %w{ reference.bib }) then
if(RUBY_PLATFORM.downcase =~ /mswin(?!ce)|mingw|cygwin|bccwin/) then
sh "pbibtex -kanji=utf8 output/#{@name}"
else
sh "jbibtex -kanji=utf8 output/#{@name}"
end
sh "platex -kanji=utf8 -output-directory=output #{@name}.tex"
sh "platex -kanji=utf8 -output-directory=output #{@name}.tex"
end
end
task :tex =>[:tex1,:bibtex]
desc "compile tex files as pdf"
task :pdf =>[:tex] do
sh "dvipdfmx -o output/#{@name}.pdf output/#{@name}.dvi"
end
task :open =>[:setup] do
if(RUBY_PLATFORM.downcase =~ /mswin(?!ce)|mingw|cygwin|bccwin/) then
sh "output/#{@name}.pdf"
else
sh "open output/#{@name}.pdf"
end
end
desc "do all compiling task"
task :all =>[:setup,:tex1,:bibtex,:pdf,:open]
desc "cleanup output directory"
task :cleanup do
sh "rm -r output/*"
end
end