module MyEbookPub

Constants

VERSION

Public Instance Methods

acknowledgements() click to toggle source
# File lib/my_ebook_pub.rb, line 83
def acknowledgements
  @renderer_no_frills.render(vacuum { File.read("#{@location}/acknowledgements.md") })
end
content() click to toggle source
# File lib/my_ebook_pub.rb, line 103
def content
  @renderer_content.render(raw_content)
end
cover() click to toggle source
# File lib/my_ebook_pub.rb, line 79
def cover
  @renderer_no_frills.render(vacuum { File.read("#{@location}/cover.md") })
end
generate() click to toggle source
# File lib/my_ebook_pub.rb, line 107
def generate # to PDF
  @location = 'content'
  @content = cover + preface + toc + content
  html = ERB.new(@template).result(binding)
  product_name = 'render'
  File.open("output/#{product_name}.pdf", 'w+') do |f|
    f.write(Docverter::Conversion.run do |c|
      c.from    = 'html'
      c.to      = 'pdf'
      c.content = html
      Dir.glob('assets/*') do |asset|
        c.add_other_file asset
      end
    end)
  end
end
preface() click to toggle source
# File lib/my_ebook_pub.rb, line 87
def preface
  @renderer_no_frills.render(vacuum { File.read("#{@location}/preface.md") })
end
raw_content() click to toggle source
# File lib/my_ebook_pub.rb, line 95
def raw_content
  content = ""
  Dir.glob("#{@location}/chapters/*.md").sort.each do |chapter|
    content << File.read(chapter)
  end
  content
end
toc() click to toggle source
# File lib/my_ebook_pub.rb, line 91
def toc
  '<h1>Table of Contents</h1>' + @renderer_toc.render(raw_content)
end
vacuum() { || ... } click to toggle source
# File lib/my_ebook_pub.rb, line 72
def vacuum
  tmp = ""
  tmp << yield
  tmp << "\n\n"
  tmp
end