Class: Asciidoctor::Diagram::GraphvizPyConverter

Inherits:
Object
  • Object
show all
Includes:
CliGenerator, DiagramConverter
Defined in:
lib/asciidoctor-diagram/graphviz_py/converter.rb

Instance Method Summary collapse

Methods included from CliGenerator

#generate_file, #generate_file_stdout, #generate_stdin, #generate_stdin_file, #generate_stdin_stdout

Methods included from DiagramConverter

#native_scaling?, #wrap_source

Instance Method Details

#collect_options(source) ⇒ Object



16
17
18
19
20
21
# File 'lib/asciidoctor-diagram/graphviz_py/converter.rb', line 16

def collect_options(source)
  {
      :layout => source.attr('layout'),
      :argument => source.attr('argument')
  }
end

#convert(source, format, options) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/asciidoctor-diagram/graphviz_py/converter.rb', line 23

def convert(source, format, options)
  generate_stdin(source.find_command('graphviz-py'), format.to_s, source.to_s) do |tool_path, output_path|
    args = [tool_path, "-o#{Platform.native_path(output_path)}", "-T#{format.to_s}"]

    layout = options[:layout]
    args << "-K#{layout}" if layout

    argument = options[:argument]

    if argument
      args << "-a"
      args << argument
    end

    {
      :args => args,
      :chdir => source.base_dir
    }
  end
end

#supported_formatsObject



12
13
14
# File 'lib/asciidoctor-diagram/graphviz_py/converter.rb', line 12

def supported_formats
  [:png, :pdf, :svg]
end