namespace :book do
  desc 'prepare build'
  task :prebuild do
    Dir.mkdir 'images' unless Dir.exists? 'images'
    Dir.glob("book/*/images/*").each do |image|
      FileUtils.copy(image, "images/" + File.basename(image))
    end
  end

  desc 'build basic book formats'
  task :build => :prebuild do
    puts "Converting to HTML..."
    `bundle exec asciidoctor LSDTT_general_overview.asc -o LSDTT_general_overview.html`
    puts " -- HTML output at LSDTT_general_overview.html"

    puts "Converting to PDF... (this one takes a while)"
      `bundle exec asciidoctor-pdf -r asciidoctor-mathematical LSDTT_general_overview.asc -o LSDTT_general_overview.pdf`
    puts " -- PDF  output at LSDTT_general_overview.pdf"
  end
  
  desc 'build html book formats'
  task :build_html => :prebuild do
    puts "Converting to HTML..."
    `bundle exec asciidoctor LSDTT_general_overview.asc -o LSDTT_general_overview.html`
    puts " -- HTML output at LSDTT_general_overview.html"
  end 
  
  desc 'build html with github stylesheet'
  task :build_html_gitcss => :prebuild do
      puts "Converting to HTML with github stylesheet..."
      `bundle exec asciidoctor LSDTT_general_overview.asc -a stylesheet=github.css -a stylesdir=./stylesheets -o LSDTT_general_overview_github_style.html`
      puts " -- HTML output at LSDTT_general_overview_github_style.html"
  end  
  
end

task :default => "book:build"
