Class: Asciidoctor::Diagram::PlantUMLPreprocessedSource

Inherits:
SimpleDelegator
  • Object
show all
Includes:
CliGenerator
Defined in:
lib/asciidoctor-diagram/plantuml/converter.rb

Instance Method Summary collapse

Methods included from CliGenerator

#generate_file, #generate_file_stdout, #generate_stdin, #generate_stdin_file, #generate_stdin_stdout

Constructor Details

#initialize(source, converter) ⇒ PlantUMLPreprocessedSource

Returns a new instance of PlantUMLPreprocessedSource.



276
277
278
279
# File 'lib/asciidoctor-diagram/plantuml/converter.rb', line 276

def initialize(source, converter)
  super(source)
  @converter = converter
end

Instance Method Details

#codeObject



281
282
283
# File 'lib/asciidoctor-diagram/plantuml/converter.rb', line 281

def code
  @code ||= load_code
end

#load_codeObject



285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
# File 'lib/asciidoctor-diagram/plantuml/converter.rb', line 285

def load_code
  code = __getobj__.code

  tag = @converter.class.tag
  code = "@start#{tag}\n#{code}\n@end#{tag}" unless code.index("@start") && code.index("@end")

  if @converter.should_preprocess(self)
    plantuml_native = PlantUmlConverter.find_plantuml_native(self)
    if plantuml_native
      code = preprocess_native(plantuml_native, code)
    else
      code = preprocess_http(code)
    end
  end

  code
end