class Asciidoctor::Diagram::DitaaConverter
@private
Constants
- CLASSPATH_ENV
- DITAA_JARS
- OPTIONS
Public Instance Methods
collect_options(source)
click to toggle source
# File lib/asciidoctor-diagram/ditaa/converter.rb, line 48 def collect_options(source) options = {} OPTIONS.keys.each do |option| attr_name = option.to_s.tr('_', '-') options[option] = source.attr(attr_name) || source.attr(attr_name, nil, 'ditaa-option') end options end
convert(source, format, options)
click to toggle source
# File lib/asciidoctor-diagram/ditaa/converter.rb, line 63 def convert(source, format, options) return source.to_s if format == :txt unless DITAA_JARS raise "Could not load Ditaa. Either require 'asciidoctor-diagram-ditaamini' or specify the location of the Ditaa JAR(s) using the 'DIAGRAM_DITAA_CLASSPATH' environment variable." end Java.load flags = [] options.each do |option, value| OPTIONS[option].call(flags, value) end options_string = flags.join(' ') case format when :png mime_type = 'image/png' when :svg mime_type = 'image/svg+xml' else raise "Unsupported format: #{format}" end headers = { 'Accept' => mime_type, 'X-Options' => options_string } response = Java.send_request( :url => '/ditaa', :body => source.to_s, :headers => headers ) unless response[:code] == 200 raise Java.create_error("Ditaa image generation failed", response) end response[:body] end
native_scaling?()
click to toggle source
# File lib/asciidoctor-diagram/ditaa/converter.rb, line 59 def native_scaling? true end
supported_formats()
click to toggle source
# File lib/asciidoctor-diagram/ditaa/converter.rb, line 44 def supported_formats [:png, :svg, :txt] end