Sha256: f2e399902cb67d0715064bee2ebce1820d6a61362621e4c240af7c290f55b6a7

Contents?: true

Size: 1.23 KB

Versions: 47

Compression:

Stored size: 1.23 KB

Contents

require "isodoc"
require "mnconvert"

module IsoDoc
  module Iso
    # A {Converter} implementation that generates HTML output, and a document
    # schema encapsulation of the document for validation
    #
    class IsoStsConvert < IsoDoc::XslfoPdfConvert
      def initialize(_options)
        @libdir = File.dirname(__FILE__)
        @format = :isosts
        @suffix = "isosts.xml"
      end

      def get_input_fname(input_fname)
        /\.xml$/.match(input_fname) or
          input_fname = Tempfile.open([fname, ".xml"], encoding: "utf-8") do |f|
            f.write file
            f.path
          end
        input_fname
      end

      def convert(input_fname, file = nil, debug = false, output_fname = nil)
        file = File.read(input_fname, encoding: "utf-8") if file.nil?
        _, fname, dir = convert_init(file, input_fname, debug)
        input_fname = get_input_fname(input_fname)
        FileUtils.rm_rf dir
        MnConvert.convert(input_fname,
                          {
                            input_format: MnConvert::InputFormat::MN,
                            output_file: output_fname || "#{fname}.#{@suffix}",
                            output_format: :iso,
                          })
      end
    end
  end
end

Version data entries

47 entries across 47 versions & 1 rubygems

Version Path
metanorma-iso-2.9.0 lib/isodoc/iso/isosts_convert.rb
metanorma-iso-2.8.9 lib/isodoc/iso/isosts_convert.rb
metanorma-iso-2.8.8 lib/isodoc/iso/isosts_convert.rb
metanorma-iso-2.8.7 lib/isodoc/iso/isosts_convert.rb
metanorma-iso-2.8.6 lib/isodoc/iso/isosts_convert.rb
metanorma-iso-2.8.5 lib/isodoc/iso/isosts_convert.rb
metanorma-iso-2.8.4 lib/isodoc/iso/isosts_convert.rb
metanorma-iso-2.8.3 lib/isodoc/iso/isosts_convert.rb
metanorma-iso-2.8.2 lib/isodoc/iso/isosts_convert.rb
metanorma-iso-2.8.1 lib/isodoc/iso/isosts_convert.rb
metanorma-iso-2.8.0 lib/isodoc/iso/isosts_convert.rb
metanorma-iso-2.7.10 lib/isodoc/iso/isosts_convert.rb
metanorma-iso-2.7.9 lib/isodoc/iso/isosts_convert.rb
metanorma-iso-2.7.8 lib/isodoc/iso/isosts_convert.rb
metanorma-iso-2.7.7 lib/isodoc/iso/isosts_convert.rb
metanorma-iso-2.7.6 lib/isodoc/iso/isosts_convert.rb
metanorma-iso-2.7.5 lib/isodoc/iso/isosts_convert.rb
metanorma-iso-2.7.4 lib/isodoc/iso/isosts_convert.rb
metanorma-iso-2.7.3 lib/isodoc/iso/isosts_convert.rb
metanorma-iso-2.7.2 lib/isodoc/iso/isosts_convert.rb