Sha256: 6238ec52741b6763fa8477e8a04992896f97b2f1f340c4d812e8e4bd81de3f32
Contents?: true
Size: 793 Bytes
Versions: 1
Compression:
Stored size: 793 Bytes
Contents
# frozen_string_literal: true module LiquidDiagrams module Renderers class GraphvizRenderer < BasicRenderer CONFIG_MAPPERS = { 'layout' => 'K', 'graph_attributes' => 'G', 'node_attributes' => 'N', 'edge_attributes' => 'E' }.freeze XML_REGEX = /^<\?xml(([^>]|\n)*>\n?){2}/.freeze def render Rendering.render_with_stdin_stdout(build_command, @content) .encode('utf-8').sub(XML_REGEX, '') end def executable 'dot -Tsvg' end def arguments @config.slice(*CONFIG_MAPPERS.keys).map do |opt, attrs| Utils.join(attrs, with: " -#{CONFIG_MAPPERS[opt]}") do |attr| Array(attr).join('=') end end.join(' ') end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
liquid-diagrams-0.4.0 | lib/liquid_diagrams/renderers/graphviz_renderer.rb |