Skip to content

Commit

Permalink
Fix the bad Rakefile.
Browse files Browse the repository at this point in the history
  • Loading branch information
moznion committed Mar 26, 2013
1 parent deaf124 commit dcea10c
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions Rakefile
Expand Up @@ -2,25 +2,27 @@ task :default => "book"

task book: [:epub, :pdf, :clean]

if File.exists?('working')
sh "rm -rf ./working"
WORKING_DIR = './working'
RELEASE_DIR = './release'

file init: FileList['./*.md'] do |task|
mkdir WORKING_DIR unless File.exists?(WORKING_DIR)
cp task.prerequisites, WORKING_DIR
mv "#{WORKING_DIR}/README.md", "#{WORKING_DIR}/000.README.md"
end
sh "mkdir ./working"
sh "cp *.md working/"
sh "mv working/README.md working/000.README.md"

file html: Dir.glob('./working/*.md') do |task|
sh "script/export_html.rb #{task.prerequisites.join(' ')} > release/process_book.html"
task html: %w[init] do
sh "script/export_html.rb #{FileList["./#{WORKING_DIR}/*.md"].join(' ')} > #{RELEASE_DIR}/process_book.html"
end

task epub: %w[html] do
sh "ebook-convert release/process_book.html release/process_book.epub --no-default-epub-cover"
sh "ebook-convert #{RELEASE_DIR}/process_book.html #{RELEASE_DIR}/process_book.epub --no-default-epub-cover"
end

task pdf: %w[html] do
sh "wkhtmltopdf release/process_book.html release/process_book.pdf --encoding utf8"
sh "wkhtmltopdf #{RELEASE_DIR}/process_book.html #{RELEASE_DIR}/process_book.pdf --encoding utf8"
end

task :clean do
sh "rm -rf working"
sh "rm -rf #{WORKING_DIR}"
end

0 comments on commit dcea10c

Please sign in to comment.