Sha256: f314f50464315e0d21c81d03e73c4577ff99ab31ebc76ad508d9ea5ac451b67c

Contents?: true

Size: 644 Bytes

Versions: 1

Compression:

Stored size: 644 Bytes

Contents

# frozen_string_literal: true

module LiquidDiagrams
  module Renderers
    class SmcatRenderer < BasicRenderer
      OPTIONS = %w[
        direction
        engine
        input-type
      ].freeze

      XML_REGEX = /^<\?xml(([^>]|\n)*>\n?){2}/.freeze

      def render
        Rendering.render_with_tempfile(build_command, @content) do |input, output|
          "#{input} --output-to #{output}"
        end.sub(XML_REGEX, '')
      end

      def build_command
        command = +'Smcat'

        @config.slice(*OPTIONS).each do |opt, value|
          command << " --#{opt} #{value}"
        end

        command
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
liquid-diagrams-0.1.0 lib/liquid_diagrams/renderers/smcat_renderer.rb