Class: Asciidoctor::Diagram::PenroseConverter

Inherits:
Object
  • Object
show all
Includes:
CliGenerator, DiagramConverter
Defined in:
lib/asciidoctor-diagram/penrose/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
22
# File 'lib/asciidoctor-diagram/penrose/converter.rb', line 16

def collect_options(source)
  {
      :domain => source.attr('domain_file'),
      :style => source.attr('style_file'),
      :variation => source.attr('variation')
  }
end

#convert(source, format, options) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/asciidoctor-diagram/penrose/converter.rb', line 24

def convert(source, format, options)
  domain_path = options[:domain]
  raise "Domain file is required" unless domain_path
  style_path = options[:style]
  raise "Style file is required" unless style_path
  variation = options[:variation]

  generate_file(source.find_command('roger'), 'substance', format.to_s, source.to_s) do |tool_path, source_path, output_path|
    args = [tool_path, 'trio', '-o', Platform.native_path(output_path)]

    args << "-v" << variation if variation

    args << "--path"
    args << "/"

    args << "--trio"
    args << Platform.native_path(source_path)
    args << Platform.native_path(source.resolve_path(domain_path))
    args << Platform.native_path(source.resolve_path(style_path))
    args << "--"

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

#supported_formatsObject



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

def supported_formats
  [:svg]
end