class Asciidoctor::Diagram::PlantUmlConverter

@private

Constants

CLASSPATH_ENV
LIB_DIR
PLANTUML_JARS

Public Instance Methods

collect_options(source) click to toggle source
# File lib/asciidoctor-diagram/plantuml/converter.rb, line 35
def collect_options(source)
  {
      :size_limit => source.attr('size-limit', '4096')
  }
end
convert(source, format, options) click to toggle source
# File lib/asciidoctor-diagram/plantuml/converter.rb, line 41
def convert(source, format, options)
  Java.load

  code = source.code

  case format
  when :png
    mime_type = 'image/png'
  when :svg
    mime_type = 'image/svg+xml'
  when :txt, :utxt
    mime_type = 'text/plain;charset=utf-8'
  when :atxt
    mime_type = 'text/plain'
  else
    raise "Unsupported format: #{format}"
  end

  headers = {
      'Accept' => mime_type
  }

  size_limit = options[:size_limit]
  if size_limit
    headers['X-PlantUML-SizeLimit'] = size_limit
  end

  dot = source.find_command('dot', :alt_attrs => ['graphvizdot'], :raise_on_error => false)
  if dot
    headers['X-Graphviz'] = ::Asciidoctor::Diagram::Platform.host_os_path(dot)
  end

  response = Java.send_request(
      :url => '/plantuml',
      :body => code,
      :headers => headers
  )

  unless response[:code] == 200
    raise Java.create_error("PlantUML image generation failed", response)
  end

  response[:body]
end
supported_formats() click to toggle source
# File lib/asciidoctor-diagram/plantuml/converter.rb, line 31
def supported_formats
  [:png, :svg, :txt, :atxt, :utxt]
end
wrap_source(source) click to toggle source
# File lib/asciidoctor-diagram/plantuml/converter.rb, line 27
def wrap_source(source)
  PlantUMLPreprocessedSource.new(source, self.class.tag)
end