Sha256: 11de570f6a133bd9f8a6847c0f58dfe69110aef6a253ce59c451573cc0940c69

Contents?: true

Size: 1.19 KB

Versions: 16

Compression:

Stored size: 1.19 KB

Contents

require 'os'

require 'libis/tools/extend/string'
require 'libis/tools/logger'
require 'libis/tools/command'

require 'libis/format/config'

module Libis
  module Format
    module Tool

      class FopPdf
        include ::Libis::Tools::Logger

        def self.run(xml, target, options = [])
          self.new.run xml, target, options
        end

        def run(xml, target, options = [])

          if OS.java?
            # TODO: import library and execute in current VM. For now do exactly as in MRI.
          end

          timeout = Libis::Format::Config[:timeouts][:fop]
          result = Libis::Tools::Command.run(
              Libis::Format::Config[:java_path],
              "-Dfop.home=#{File.dirname(Libis::Format::Config[:fop_jar])}",
              '-jar', Libis::Format::Config[:fop_jar],
              '-fo', xml,
              '-pdf', target,
              timeout: timeout,
              kill_after: timeout * 2
          )

          raise RuntimeError, "#{self.class} took too long (> #{timeout} seconds) to complete" if result[:timeout]
          raise RuntimeError, "#{self.class} errors: #{result[:err].join("\n")}" unless result[:status] == 0

        end
      end

    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
libis-format-1.0.4 lib/libis/format/tool/fop_pdf.rb
libis-format-1.0.2 lib/libis/format/tool/fop_pdf.rb
libis-format-1.0.1 lib/libis/format/tool/fop_pdf.rb
libis-format-1.0.0 lib/libis/format/tool/fop_pdf.rb
libis-format-0.9.74 lib/libis/format/tool/fop_pdf.rb
libis-format-0.9.72 lib/libis/format/tool/fop_pdf.rb
libis-format-0.9.70 lib/libis/format/tool/fop_pdf.rb
libis-format-0.9.69 lib/libis/format/tool/fop_pdf.rb
libis-format-0.9.68 lib/libis/format/tool/fop_pdf.rb
libis-format-0.9.67 lib/libis/format/tool/fop_pdf.rb
libis-format-0.9.66 lib/libis/format/tool/fop_pdf.rb
libis-format-0.9.65 lib/libis/format/tool/fop_pdf.rb
libis-format-0.9.64 lib/libis/format/tool/fop_pdf.rb
libis-format-0.9.63 lib/libis/format/tool/fop_pdf.rb
libis-format-0.9.62 lib/libis/format/tool/fop_pdf.rb
libis-format-0.9.50 lib/libis/format/tool/fop_pdf.rb