class Asciidoctor::Diagram::CacooBlockProcessor

Public Instance Methods

create_source(parent, reader, attributes) click to toggle source
# File lib/asciidoctor-diagram-cacoo/extension.rb, line 96
def create_source(parent, reader, attributes)
  api_key = ENV['CACOO_API_KEY'] || parent.document.attributes['cacoo_api_key']
  raise "Please specify your Cacoo API key using the CACOO_API_KEY environment variable or cacoo_api_key document attribute" unless api_key
  does_download_contents = parent.document.attributes['cacoo_does_download_contents'] || false
  contents_xml_indent = (parent.document.attributes['cacoo_contents_xml_indent'] || '2').to_i
  options = {
    does_download_contents: does_download_contents,
    contents_xml_indent: contents_xml_indent
  }
  Cacoo::Source.new(reader.read.strip, api_key, options)
end