Module: Asciidoctor::Diagram::Extensions::DiagramSource

Included in:
BasicSource, ReaderSource
Defined in:
lib/asciidoctor-diagram/extensions.rb

Overview

This module describes the duck-typed interface that diagram sources must implement. Implementations may include this module but it is not required.

Instance Method Summary collapse

Instance Method Details

#codeString

This method is abstract.

Returns the String representation of the source code for the diagram.

Returns:

  • (String)

    the String representation of the source code for the diagram

Raises:

  • (NotImplementedError)


272
273
274
# File 'lib/asciidoctor-diagram/extensions.rb', line 272

def code
  raise NotImplementedError.new
end

#create_image_metadataHash

Creates an image metadata Hash that will be stored to disk alongside the generated image file. The contents of this Hash are reread during subsequent document processing and then passed to the should_process? method where it can be used to determine if the diagram should be regenerated or not. The default implementation returns an empty Hash.

Returns:

  • (Hash)

    a Hash containing metadata



296
297
298
# File 'lib/asciidoctor-diagram/extensions.rb', line 296

def 
  {}
end

#image_nameString

This method is abstract.

Returns the base name for the image file that will be produced.

Returns:

  • (String)

    the base name for the image file that will be produced

Raises:

  • (NotImplementedError)


266
267
268
# File 'lib/asciidoctor-diagram/extensions.rb', line 266

def image_name
  raise NotImplementedError.new
end

#should_process?(image_file, image_metadata) ⇒ Boolean

Determines if the diagram should be regenerated or not. The default implementation of this method simply returns true.

Parameters:

  • image_file (String)

    the path to the previously generated version of the image

  • image_metadata (Hash)

    the image metadata Hash that was stored during the previous diagram generation pass

Returns:

  • (Boolean)

    true if the diagram should be regenerated; false otherwise



287
288
289
# File 'lib/asciidoctor-diagram/extensions.rb', line 287

def should_process?(image_file, )
  true
end

#to_sObject

Alias for code



277
278
279
# File 'lib/asciidoctor-diagram/extensions.rb', line 277

def to_s
  code
end