Class: LiquidDiagrams::Renderers::GraphvizRenderer
- Inherits:
-
BasicRenderer
- Object
- BasicRenderer
- LiquidDiagrams::Renderers::GraphvizRenderer
- Defined in:
- lib/liquid_diagrams/renderers/graphviz_renderer.rb
Constant Summary collapse
- CONFIG_MAPPERS =
{ 'layout' => 'K', 'graph_attributes' => 'G', 'node_attributes' => 'N', 'edge_attributes' => 'E' }.freeze
- XML_REGEX =
/^<\?xml(([^>]|\n)*>\n?){2}/.freeze
Constants inherited from BasicRenderer
BasicRenderer::FLAGS, BasicRenderer::FLAGS_PREFIX, BasicRenderer::OPTIONS, BasicRenderer::OPTIONS_PREFIX, BasicRenderer::OPTIONS_SEPARATOR
Instance Method Summary collapse
Methods inherited from BasicRenderer
#build_command, #initialize, render
Methods included from LiquidDiagrams::Rendering
render_with_command, render_with_stdin_stdout, render_with_tempfile
Constructor Details
This class inherits a constructor from LiquidDiagrams::BasicRenderer
Instance Method Details
#arguments ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/liquid_diagrams/renderers/graphviz_renderer.rb', line 24 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 |
#executable ⇒ Object
20 21 22 |
# File 'lib/liquid_diagrams/renderers/graphviz_renderer.rb', line 20 def executable 'dot -Tsvg' end |
#render ⇒ Object
15 16 17 18 |
# File 'lib/liquid_diagrams/renderers/graphviz_renderer.rb', line 15 def render Rendering.render_with_stdin_stdout(build_command, @content) .encode('utf-8').sub(XML_REGEX, '') end |