Class: Asciidoctor::Diagram::Extensions::BasicSource
- Inherits:
-
Object
- Object
- Asciidoctor::Diagram::Extensions::BasicSource
- Includes:
- DiagramSource
- Defined in:
- lib/asciidoctor-diagram/extensions.rb
Overview
Base class for diagram source implementations that uses an md5 checksum of the source code of a diagram to determine if it has been updated or not.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
Instance Method Summary collapse
- #attr(name, default_value = nil, inherit = nil) ⇒ Object
- #checksum ⇒ Object
- #create_image_metadata ⇒ Object
- #image_name ⇒ Object
-
#initialize(parent_block, attributes) ⇒ BasicSource
constructor
A new instance of BasicSource.
- #should_process?(image_file, image_metadata) ⇒ Boolean
Methods included from DiagramSource
Constructor Details
#initialize(parent_block, attributes) ⇒ BasicSource
Returns a new instance of BasicSource.
371 372 373 374 |
# File 'lib/asciidoctor-diagram/extensions.rb', line 371 def initialize(parent_block, attributes) @parent_block = parent_block @attributes = attributes end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
369 370 371 |
# File 'lib/asciidoctor-diagram/extensions.rb', line 369 def attributes @attributes end |
Instance Method Details
#attr(name, default_value = nil, inherit = nil) ⇒ Object
380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 |
# File 'lib/asciidoctor-diagram/extensions.rb', line 380 def attr(name, default_value=nil, inherit=nil) name = name.to_s if ::Symbol === name value = @attributes[name] if value.nil? && inherit case inherit when String value = @parent_block.attr("#{inherit}-#{name}", default_value, true) else value = @parent_block.attr(name, default_value, true) end end value || default_value end |
#checksum ⇒ Object
405 406 407 |
# File 'lib/asciidoctor-diagram/extensions.rb', line 405 def checksum @checksum ||= compute_checksum(code) end |
#create_image_metadata ⇒ Object
401 402 403 |
# File 'lib/asciidoctor-diagram/extensions.rb', line 401 def {'checksum' => checksum} end |
#image_name ⇒ Object
376 377 378 |
# File 'lib/asciidoctor-diagram/extensions.rb', line 376 def image_name attr('target', 'diag-' + checksum) end |
#should_process?(image_file, image_metadata) ⇒ Boolean
397 398 399 |
# File 'lib/asciidoctor-diagram/extensions.rb', line 397 def should_process?(image_file, ) ['checksum'] != checksum end |