Class: Middleman::PDFKit::Extension

Inherits:
Extension
  • Object
show all
Defined in:
lib/middleman-pdfkit/extension.rb

Instance Method Summary collapse

Constructor Details

#initialize(klass, options_hash = {}, &block) ⇒ Extension

Returns a new instance of Extension.



16
17
18
19
# File 'lib/middleman-pdfkit/extension.rb', line 16

def initialize(klass, options_hash={}, &block)
  super
  setup_filenames
end

Instance Method Details

#after_build(builder) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/middleman-pdfkit/extension.rb', line 21

def after_build(builder)
  @filenames.each do |pdfkit_filename|
    html_filename = "build/#{pdfkit_filename}.html"
    pdf_filename  = "build/#{pdfkit_filename}.pdf"
    if File.exist?(html_filename)
      generate_pdf(html_filename, pdf_filename)
      builder.say_status "create", pdf_filename
    else
      builder.say_status "error", "#{pdf_filename} (HTML-File not found )", :red
    end
  end
end