class Asciidoctor::Diagram::VegaConverter

@private

Public Instance Methods

collect_options(source, name) click to toggle source
# File lib/asciidoctor-diagram/vega/converter.rb, line 18
def collect_options(source, name)
  {
      :vegalite => name.to_s.include?('lite') || source.attr('vegalite')
  }
end
convert(source, format, options) click to toggle source
# File lib/asciidoctor-diagram/vega/converter.rb, line 24
def convert(source, format, options)
  base_dir = source.base_dir

  code = source.to_s

  if code.include?('/schema/vega-lite/') || options[:vegalite]
    vega_code = generate_stdin_stdout(source.find_command("vl2vg"), code)
  else
    vega_code = code
  end

  generate_file(source.find_command("vg2#{format}"), "json", format.to_s, vega_code) do |tool_path, input_path, output_path|
    args = [tool_path, '--base', Platform.native_path(base_dir)]
    if format == :svg
      args << '--header'
    end

    args << Platform.native_path(input_path)
    args << Platform.native_path(output_path)
  end
end
supported_formats() click to toggle source
# File lib/asciidoctor-diagram/vega/converter.rb, line 13
def supported_formats
  [:svg, :png]
end