Class: Asciidoctor::Diagram::Renderers
- Inherits:
-
Object
- Object
- Asciidoctor::Diagram::Renderers
- Defined in:
- lib/asciidoctor-diagram/structurizr/renderers.rb
Constant Summary collapse
- D2 =
'd2'
- GRAPHVIZ =
'graphviz'
- MERMAID =
'mermaid'
- PLANTUML_C4 =
'plantuml-c4'
- PLANTUML =
'plantuml'
- DEFAULT_RENDERER =
PLANTUML_C4
Class Method Summary collapse
Instance Method Summary collapse
- #get_renderer(source) ⇒ Object
-
#initialize(name) ⇒ Renderers
constructor
A new instance of Renderers.
- #renderer(renderer_type) ⇒ Object
Constructor Details
#initialize(name) ⇒ Renderers
Returns a new instance of Renderers.
16 17 18 19 20 21 |
# File 'lib/asciidoctor-diagram/structurizr/renderers.rb', line 16 def initialize(name) @d2 = D2BlockProcessor.new(name) @graphviz = GraphvizBlockProcessor.new(name) @plantuml = PlantUmlBlockProcessor.new(name) @mermaid = MermaidBlockProcessor.new(name) end |
Class Method Details
.get_renderer_type(source) ⇒ Object
42 43 44 |
# File 'lib/asciidoctor-diagram/structurizr/renderers.rb', line 42 def self.get_renderer_type(source) source.attr('renderer', PLANTUML_C4) end |
.mime_type(renderer_type) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/asciidoctor-diagram/structurizr/renderers.rb', line 45 def self.mime_type(renderer_type) case renderer_type when D2 'text/x-d2' when GRAPHVIZ 'text/vnd.graphviz' when MERMAID 'text/x-mermaid' when PLANTUML 'text/x-plantuml' when PLANTUML_C4 'text/x-plantuml-c4' else raise "Unsupported renderer: '#{renderer_type}'" end end |
Instance Method Details
#get_renderer(source) ⇒ Object
38 39 40 |
# File 'lib/asciidoctor-diagram/structurizr/renderers.rb', line 38 def get_renderer(source) renderer(Renderers.get_renderer_type(source)) end |
#renderer(renderer_type) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/asciidoctor-diagram/structurizr/renderers.rb', line 23 def renderer(renderer_type) case renderer_type when D2 @d2 when GRAPHVIZ @graphviz when MERMAID @mermaid when PLANTUML, PLANTUML_C4 @plantuml else raise "Unsupported renderer: '#{renderer_type}'" end end |