Sha256: 597dcaee0a73a450381f6aa2a92da640308cec9b802bb23f8b19a0ddfb925e28

Contents?: true

Size: 1.31 KB

Versions: 7

Compression:

Stored size: 1.31 KB

Contents

require 'fileutils'
require 'rake/clean'

BOOK = "book"
BOOK_PDF = BOOK+".pdf"
BOOK_EPUB = BOOK+".epub"
CONFIG_FILE = "config.yml"
REVIEW_COMPILE = "review-compile-peg"

def build(mode, chapter)
  sh "#{REVIEW_COMPILE} --target=#{mode} --footnotetext --stylesheet=style.css #{chapter} > tmp"
  mode_ext = {"html" => "html", "latex" => "tex",
              "idgxml" => "xml", "inao" => "inao"}
  FileUtils.mv "tmp", chapter.gsub(/re\z/, mode_ext[mode])
end

def build_all(mode)
  sh "#{REVIEW_COMPILE} --all --target=#{mode} --footnotetext --stylesheet=style.css"
end

task :default => :html_all

desc "build html (Usage: rake build re=target.re)"
task :html do
  if ENV['re'].nil?
    puts "Usage: rake build re=target.re"
    exit
  end
  build("html", ENV['re'])
end

desc "build all html"
task :html_all do
  build_all("html")
end

desc 'generate PDF and EPUB file'
task :all => [:pdf, :epub]

desc 'generate PDF file'
task :pdf => BOOK_PDF

desc 'generate EPUB file'
task :epub => BOOK_EPUB

SRC = FileList['*.re'] + [CONFIG_FILE]

file BOOK_PDF => SRC do
  FileUtils.rm_rf [BOOK_PDF, BOOK, BOOK+"-pdf"]
  sh "review-pdfmaker #{CONFIG_FILE}"
end

file BOOK_EPUB => SRC do
  FileUtils.rm_rf [BOOK_EPUB, BOOK, BOOK+"-epub"]
  sh "review-epubmaker #{CONFIG_FILE}"
end

CLEAN.include([BOOK, BOOK_PDF, BOOK_EPUB, BOOK+"-pdf", BOOK+"-epub"])

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
review-peg-0.2.2 test/sample-book/src/Rakefile
review-peg-0.2.1 test/sample-book/src/Rakefile
review-peg-0.2.0 test/sample-book/src/Rakefile
review-peg-0.1.3 test/sample-book/src/Rakefile
review-peg-0.1.2 test/sample-book/src/Rakefile
review-peg-0.1.1 test/sample-book/src/Rakefile
review-peg-0.1.0 test/sample-book/src/Rakefile