Module: Export::PaperCatalog

Defined in:
lib/export/paper_catalog.rb

Class Method Summary collapse

Class Method Details

.export(taxon_name, body = nil, options = {}) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/export/paper_catalog.rb', line 8

def self.export(taxon_name, body = nil, options = {})
  zip_file_path = "/tmp/_#{SecureRandom.hex(8)}_paper_catalog.zip"

  Zip::File.open(zip_file_path, Zip::File::CREATE) do |zipfile|

    zipfile.get_output_stream('catalog.md') do |f|
      f.write body
    end

    zipfile.get_output_stream('catalog.html') do |f|
      f.write (Asciidoctor.convert body, safe: :safe, header_footer: true)
    end

    # zipfile.get_output_stream('catalog.epub') do |f|
    #    f.write (Asciidoctor.convert body, backend: 'epub3', safe: :safe)
    # end
  end

  zip_file_path
end