asciidoctor-diagram 1.5.18 → 2.0.3

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of asciidoctor-diagram might be problematic. Click here for more details.

Files changed (102) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.adoc +66 -0
  3. data/README.adoc +98 -23
  4. data/examples/features.adoc +2 -2
  5. data/lib/asciidoctor-diagram.rb +8 -0
  6. data/lib/asciidoctor-diagram/a2s/converter.rb +55 -0
  7. data/lib/asciidoctor-diagram/a2s/extension.rb +6 -52
  8. data/lib/asciidoctor-diagram/blockdiag/converter.rb +37 -0
  9. data/lib/asciidoctor-diagram/blockdiag/extension.rb +9 -116
  10. data/lib/asciidoctor-diagram/bpmn.rb +7 -0
  11. data/lib/asciidoctor-diagram/bpmn/converter.rb +62 -0
  12. data/lib/asciidoctor-diagram/bpmn/extension.rb +14 -0
  13. data/lib/asciidoctor-diagram/bytefield.rb +7 -0
  14. data/lib/asciidoctor-diagram/bytefield/converter.rb +26 -0
  15. data/lib/asciidoctor-diagram/bytefield/extension.rb +14 -0
  16. data/lib/asciidoctor-diagram/diagram_converter.rb +19 -0
  17. data/lib/asciidoctor-diagram/diagram_processor.rb +345 -0
  18. data/lib/asciidoctor-diagram/diagram_source.rb +306 -0
  19. data/lib/asciidoctor-diagram/ditaa/converter.rb +86 -0
  20. data/lib/asciidoctor-diagram/ditaa/extension.rb +6 -71
  21. data/lib/asciidoctor-diagram/dpic.rb +7 -0
  22. data/lib/asciidoctor-diagram/dpic/converter.rb +30 -0
  23. data/lib/asciidoctor-diagram/dpic/extension.rb +14 -0
  24. data/lib/asciidoctor-diagram/erd/converter.rb +31 -0
  25. data/lib/asciidoctor-diagram/erd/extension.rb +6 -35
  26. data/lib/asciidoctor-diagram/gnuplot.rb +7 -0
  27. data/lib/asciidoctor-diagram/gnuplot/converter.rb +63 -0
  28. data/lib/asciidoctor-diagram/gnuplot/extension.rb +14 -0
  29. data/lib/asciidoctor-diagram/graphviz/converter.rb +32 -0
  30. data/lib/asciidoctor-diagram/graphviz/extension.rb +6 -35
  31. data/lib/asciidoctor-diagram/http/converter.rb +99 -0
  32. data/lib/asciidoctor-diagram/http/server.rb +127 -0
  33. data/lib/asciidoctor-diagram/lilypond.rb +7 -0
  34. data/lib/asciidoctor-diagram/lilypond/converter.rb +54 -0
  35. data/lib/asciidoctor-diagram/lilypond/extension.rb +14 -0
  36. data/lib/asciidoctor-diagram/meme/converter.rb +122 -0
  37. data/lib/asciidoctor-diagram/meme/extension.rb +5 -107
  38. data/lib/asciidoctor-diagram/mermaid/converter.rb +179 -0
  39. data/lib/asciidoctor-diagram/mermaid/extension.rb +6 -159
  40. data/lib/asciidoctor-diagram/msc/converter.rb +35 -0
  41. data/lib/asciidoctor-diagram/msc/extension.rb +6 -36
  42. data/lib/asciidoctor-diagram/nomnoml/converter.rb +25 -0
  43. data/lib/asciidoctor-diagram/nomnoml/extension.rb +6 -28
  44. data/lib/asciidoctor-diagram/pikchr.rb +7 -0
  45. data/lib/asciidoctor-diagram/pikchr/converter.rb +26 -0
  46. data/lib/asciidoctor-diagram/pikchr/extension.rb +14 -0
  47. data/lib/asciidoctor-diagram/plantuml/converter.rb +117 -0
  48. data/lib/asciidoctor-diagram/plantuml/extension.rb +10 -119
  49. data/lib/asciidoctor-diagram/shaape/converter.rb +25 -0
  50. data/lib/asciidoctor-diagram/shaape/extension.rb +6 -28
  51. data/lib/asciidoctor-diagram/smcat.rb +7 -0
  52. data/lib/asciidoctor-diagram/smcat/converter.rb +44 -0
  53. data/lib/asciidoctor-diagram/smcat/extension.rb +14 -0
  54. data/lib/asciidoctor-diagram/svgbob/converter.rb +49 -0
  55. data/lib/asciidoctor-diagram/svgbob/extension.rb +6 -28
  56. data/lib/asciidoctor-diagram/symbolator.rb +7 -0
  57. data/lib/asciidoctor-diagram/symbolator/converter.rb +23 -0
  58. data/lib/asciidoctor-diagram/symbolator/extension.rb +14 -0
  59. data/lib/asciidoctor-diagram/syntrax/converter.rb +55 -0
  60. data/lib/asciidoctor-diagram/syntrax/extension.rb +6 -51
  61. data/lib/asciidoctor-diagram/tikz/converter.rb +56 -0
  62. data/lib/asciidoctor-diagram/tikz/extension.rb +6 -60
  63. data/lib/asciidoctor-diagram/umlet/converter.rb +24 -0
  64. data/lib/asciidoctor-diagram/umlet/extension.rb +6 -28
  65. data/lib/asciidoctor-diagram/util/cli.rb +14 -3
  66. data/lib/asciidoctor-diagram/util/cli_generator.rb +19 -1
  67. data/lib/asciidoctor-diagram/util/gif.rb +2 -2
  68. data/lib/asciidoctor-diagram/util/java.rb +1 -1
  69. data/lib/asciidoctor-diagram/util/java_socket.rb +7 -9
  70. data/lib/asciidoctor-diagram/util/pdf.rb +2 -2
  71. data/lib/asciidoctor-diagram/util/png.rb +2 -2
  72. data/lib/asciidoctor-diagram/util/svg.rb +38 -19
  73. data/lib/asciidoctor-diagram/util/which.rb +0 -29
  74. data/lib/asciidoctor-diagram/vega/converter.rb +47 -0
  75. data/lib/asciidoctor-diagram/vega/extension.rb +6 -44
  76. data/lib/asciidoctor-diagram/version.rb +1 -1
  77. data/lib/asciidoctor-diagram/wavedrom/converter.rb +50 -0
  78. data/lib/asciidoctor-diagram/wavedrom/extension.rb +6 -46
  79. data/lib/ditaa-1.3.15.jar +0 -0
  80. data/lib/ditaamini-0.12.jar +0 -0
  81. data/lib/plantuml-1.3.15.jar +0 -0
  82. data/lib/plantuml.jar +0 -0
  83. data/lib/server-1.3.15.jar +0 -0
  84. data/spec/bpmn-example.xml +44 -0
  85. data/spec/bpmn_spec.rb +96 -0
  86. data/spec/bytefield_spec.rb +230 -0
  87. data/spec/ditaa_spec.rb +32 -0
  88. data/spec/dpic_spec.rb +74 -0
  89. data/spec/gnuplot_spec.rb +478 -0
  90. data/spec/lilypond_spec.rb +151 -0
  91. data/spec/mermaid_spec.rb +33 -1
  92. data/spec/pikchr_spec.rb +106 -0
  93. data/spec/plantuml_spec.rb +90 -1
  94. data/spec/smcat_spec.rb +164 -0
  95. data/spec/symbolator_spec.rb +200 -0
  96. data/spec/test_helper.rb +0 -18
  97. metadata +73 -11
  98. data/lib/asciidoctor-diagram/extensions.rb +0 -568
  99. data/lib/ditaa-1.3.13.jar +0 -0
  100. data/lib/ditaamini-0.11.jar +0 -0
  101. data/lib/plantuml-1.3.13.jar +0 -0
  102. data/lib/server-1.3.13.jar +0 -0
@@ -1,34 +1,53 @@
1
1
  require_relative 'binaryio'
2
+ require 'rexml/document'
3
+ require 'bigdecimal'
4
+ require 'bigdecimal/util'
2
5
 
3
6
  module Asciidoctor
4
7
  module Diagram
5
8
  # @private
6
9
  module SVG
7
- def self.get_image_size(data)
8
- if m = START_TAG_REGEX.match(data)
9
- start_tag = m[0]
10
- if (w = WIDTH_REGEX.match(start_tag)) && (h = HEIGHT_REGEX.match(start_tag))
11
- width = w[:value].to_i * to_px_factor(w[:unit])
12
- height = h[:value].to_i * to_px_factor(h[:unit])
13
- return [width.to_i, height.to_i]
14
- end
15
-
16
- if v = VIEWBOX_REGEX.match(start_tag)
17
- width = v[:width]
18
- height = v[:height]
19
- return [width.to_i, height.to_i]
20
- end
10
+ def self.post_process_image(data)
11
+ svg = REXML::Document.new(data)
12
+
13
+ root = svg.root
14
+
15
+ unless root.attributes['xmlns']
16
+ root.add_attribute('xmlns', 'http://www.w3.org/2000/svg')
17
+ end
18
+
19
+ unless root.attributes['preserveAspectRatio']
20
+ root.add_attribute('preserveAspectRatio', 'xMidYMid meet')
21
+ end
22
+
23
+ width = nil
24
+ height = nil
25
+
26
+ if (w = WIDTH_HEIGHT_REGEX.match(root.attributes['width'])) && (h = WIDTH_HEIGHT_REGEX.match(root.attributes['height']))
27
+ width = w[:value].to_d * to_px_factor(w[:unit])
28
+ height = h[:value].to_d * to_px_factor(h[:unit])
29
+ end
30
+
31
+ viewbox = root.attributes['viewBox']
32
+ if (v = VIEWBOX_REGEX.match(viewbox)) && width.nil? && height.nil?
33
+ width = v[:width].to_d
34
+ height = v[:height].to_d
21
35
  end
22
36
 
23
- nil
37
+ if viewbox.nil? && width && height
38
+ root.add_attribute('viewBox', "0 0 #{width.to_s('F')} #{height.to_s('F')}")
39
+ end
40
+
41
+ patched_svg = ""
42
+ svg.write(:output => patched_svg, :indent => 2)
43
+
44
+ [patched_svg, width, height]
24
45
  end
25
46
 
26
47
  private
27
48
 
28
- START_TAG_REGEX = /<svg[^>]*>/
29
- WIDTH_REGEX = /width="(?<value>\d+(?:\.\d+)?)(?<unit>[a-zA-Z]+)?"/
30
- HEIGHT_REGEX = /height="(?<value>\d+(?:\.\d+)?)(?<unit>[a-zA-Z]+)?"/
31
- VIEWBOX_REGEX = /viewBox="\d+(?:\.\d+)? \d+(?:\.\d+)? (?<width>\d+(?:\.\d+)?) (?<height>\d+(?:\.\d+)?)"/
49
+ WIDTH_HEIGHT_REGEX = /^\s*(?<value>\d+(?:\.\d+)?)\s*(?<unit>[a-zA-Z]+)?\s*$/
50
+ VIEWBOX_REGEX = /^\s*\d+(?:\.\d+)?\s*\d+(?:\.\d+)?\s*(?<width>\d+(?:\.\d+)?)\s*(?<height>\d+(?:\.\d+)?)\s*$/
32
51
 
33
52
  def self.to_px_factor(unit)
34
53
  case unit
@@ -15,35 +15,6 @@ module Asciidoctor
15
15
 
16
16
  nil
17
17
  end
18
-
19
- def which(parent_block, cmd, options = {})
20
- attr_names = options[:attrs] || options.fetch(:alt_attrs, []) + [cmd]
21
- cmd_names = [cmd] + options.fetch(:alt_cmds, [])
22
-
23
- cmd_var = 'cmd-' + attr_names[0]
24
-
25
- if config.key? cmd_var
26
- cmd_path = config[cmd_var]
27
- else
28
- cmd_path = attr_names.map { |attr_name| parent_block.attr(attr_name, nil, true) }.find { |attr| !attr.nil? }
29
-
30
- unless cmd_path && File.executable?(cmd_path)
31
- cmd_paths = cmd_names.map do |c|
32
- ::Asciidoctor::Diagram::Which.which(c, :path => options[:path])
33
- end
34
-
35
- cmd_path = cmd_paths.reject { |c| c.nil? }.first
36
- end
37
-
38
- config[cmd_var] = cmd_path
39
-
40
- if cmd_path.nil? && options.fetch(:raise_on_error, true)
41
- raise "Could not find the #{cmd_names.map { |c| "'#{c}'" }.join(', ')} executable in PATH; add it to the PATH or specify its location using the '#{attr_names[0]}' document attribute"
42
- end
43
- end
44
-
45
- cmd_path
46
- end
47
18
  end
48
19
  end
49
20
  end
@@ -0,0 +1,47 @@
1
+ require_relative '../diagram_converter'
2
+ require_relative '../util/cli_generator'
3
+ require_relative '../util/platform'
4
+
5
+ module Asciidoctor
6
+ module Diagram
7
+ # @private
8
+ class VegaConverter
9
+ include DiagramConverter
10
+ include CliGenerator
11
+
12
+
13
+ def supported_formats
14
+ [:svg, :png]
15
+ end
16
+
17
+
18
+ def collect_options(source, name)
19
+ {
20
+ :vegalite => name.to_s.include?('lite') || source.attr('vegalite')
21
+ }
22
+ end
23
+
24
+ def convert(source, format, options)
25
+ base_dir = source.base_dir
26
+
27
+ code = source.to_s
28
+
29
+ if code.include?('/schema/vega-lite/') || options[:vegalite]
30
+ vega_code = generate_stdin_stdout(source.find_command("vl2vg"), code)
31
+ else
32
+ vega_code = code
33
+ end
34
+
35
+ generate_file(source.find_command("vg2#{format}"), "json", format.to_s, vega_code) do |tool_path, input_path, output_path|
36
+ args = [tool_path, '--base', Platform.native_path(base_dir)]
37
+ if format == :svg
38
+ args << '--header'
39
+ end
40
+
41
+ args << Platform.native_path(input_path)
42
+ args << Platform.native_path(output_path)
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -1,52 +1,14 @@
1
- require_relative '../extensions'
2
- require_relative '../util/cli_generator'
3
- require_relative '../util/platform'
4
- require_relative '../util/which'
1
+ require_relative '../diagram_processor'
2
+ require_relative 'converter'
5
3
 
6
4
  module Asciidoctor
7
5
  module Diagram
8
- # @private
9
- module Vega
10
- include CliGenerator
11
- include Which
12
-
13
- def self.included(mod)
14
- [:svg, :png].each do |f|
15
- mod.register_format(f, :image) do |parent, source|
16
- vega(parent, source, f)
17
- end
18
- end
19
- end
20
-
21
- def vega(parent, source, format)
22
- base_dir = source.base_dir
23
-
24
- code = source.to_s
25
-
26
- if code.include?('/schema/vega-lite/') || name.to_s.include?('lite') || source.attr('vegalite')
27
- vega_code = generate_stdin_stdout(which(parent, "vl2vg"), code)
28
- else
29
- vega_code = code
30
- end
31
-
32
- generate_file(which(parent, "vg2#{format}"), "json", format.to_s, vega_code) do |tool_path, input_path, output_path|
33
- args = [tool_path, '--base', Platform.native_path(base_dir)]
34
- if format == :svg
35
- args << '--header'
36
- end
37
-
38
- args << Platform.native_path(input_path)
39
- args << Platform.native_path(output_path)
40
- end
41
- end
42
- end
43
-
44
- class VegaBlockProcessor < Extensions::DiagramBlockProcessor
45
- include Vega
6
+ class VegaBlockProcessor < DiagramBlockProcessor
7
+ use_converter VegaConverter
46
8
  end
47
9
 
48
- class VegaBlockMacroProcessor < Extensions::DiagramBlockMacroProcessor
49
- include Vega
10
+ class VegaBlockMacroProcessor < DiagramBlockMacroProcessor
11
+ use_converter VegaConverter
50
12
  end
51
13
  end
52
14
  end
@@ -1,5 +1,5 @@
1
1
  module Asciidoctor
2
2
  module Diagram
3
- VERSION = "1.5.18"
3
+ VERSION = "2.0.3"
4
4
  end
5
5
  end
@@ -0,0 +1,50 @@
1
+ require_relative '../diagram_converter'
2
+ require_relative '../util/cli_generator'
3
+ require_relative '../util/platform'
4
+
5
+ module Asciidoctor
6
+ module Diagram
7
+ # @private
8
+ class WavedromConverter
9
+ include DiagramConverter
10
+ include CliGenerator
11
+
12
+
13
+ def supported_formats
14
+ [:png, :svg]
15
+ end
16
+
17
+
18
+ def convert(source, format, options)
19
+ wavedrom_cli = source.find_command('wavedrom-cli', :raise_on_error => false)
20
+ if wavedrom_cli
21
+ generate_file(wavedrom_cli, 'wvd', format.to_s, source.to_s) do |tool_path, input_path, output_path|
22
+ [Platform.native_path(tool_path), '--input', Platform.native_path(input_path), "--#{format.to_s}", Platform.native_path(output_path)]
23
+ end
24
+ else
25
+ wavedrom_cli = source.find_command('wavedrom', :raise_on_error => false)
26
+ phantomjs = source.find_command('phantomjs', :alt_attrs => ['phantomjs_2'], :raise_on_error => false)
27
+
28
+ if wavedrom_cli && !wavedrom_cli.include?('WaveDromEditor') && phantomjs
29
+ generate_file(wavedrom_cli, 'wvd', format.to_s, source.to_s) do |tool_path, input_path, output_path|
30
+ [phantomjs, Platform.native_path(tool_path), '-i', Platform.native_path(input_path), "-#{format.to_s[0]}", Platform.native_path(output_path)]
31
+ end
32
+ else
33
+ if ::Asciidoctor::Diagram::Platform.os == :macosx
34
+ wavedrom = source.find_command('WaveDromEditor.app', :alt_cmds => ['wavedrom-editor.app'], :attrs => ['WaveDromEditorApp'], :path => ['/Applications'])
35
+ if wavedrom
36
+ wavedrom = File.join(wavedrom, 'Contents/MacOS/nwjs')
37
+ end
38
+ else
39
+ wavedrom = source.find_command('WaveDromEditor')
40
+ end
41
+
42
+ generate_file(wavedrom, 'wvd', format.to_s, source.to_s) do |tool_path, input_path, output_path|
43
+ [tool_path, 'source', Platform.native_path(input_path), format.to_s, Platform.native_path(output_path)]
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
@@ -1,54 +1,14 @@
1
- require_relative '../extensions'
2
- require_relative '../util/cli_generator'
3
- require_relative '../util/platform'
4
- require_relative '../util/which'
1
+ require_relative '../diagram_processor'
2
+ require_relative 'converter'
5
3
 
6
4
  module Asciidoctor
7
5
  module Diagram
8
- # @private
9
- module Wavedrom
10
- include CliGenerator
11
- include Which
12
-
13
- def self.included(mod)
14
- [:png, :svg].each do |f|
15
- mod.register_format(f, :image) do |parent, source|
16
- wavedrom(parent, source, f)
17
- end
18
- end
19
- end
20
-
21
- def wavedrom(parent, source, format)
22
- wavedrom_cli = which(parent, 'wavedrom', :raise_on_error => false)
23
- phantomjs = which(parent, 'phantomjs', :alt_attrs => ['phantomjs_2'], :raise_on_error => false)
24
-
25
- if wavedrom_cli && !wavedrom_cli.include?('WaveDromEditor') && phantomjs
26
- generate_file(wavedrom_cli, 'wvd', format.to_s, source.to_s) do |tool_path, input_path, output_path|
27
- [phantomjs, Platform.native_path(tool_path), '-i', Platform.native_path(input_path), "-#{format.to_s[0]}", Platform.native_path(output_path)]
28
- end
29
- else
30
- if ::Asciidoctor::Diagram::Platform.os == :macosx
31
- wavedrom = which(parent, 'WaveDromEditor.app', :alt_cmds => ['wavedrom-editor.app'], :attrs => ['WaveDromEditorApp'],:path => ['/Applications'])
32
- if wavedrom
33
- wavedrom = File.join(wavedrom, 'Contents/MacOS/nwjs')
34
- end
35
- else
36
- wavedrom = which(parent, 'WaveDromEditor')
37
- end
38
-
39
- generate_file(wavedrom, 'wvd', format.to_s, source.to_s) do |tool_path, input_path, output_path|
40
- [tool_path, 'source', Platform.native_path(input_path), format.to_s, Platform.native_path(output_path)]
41
- end
42
- end
43
- end
44
- end
45
-
46
- class WavedromBlockProcessor < Extensions::DiagramBlockProcessor
47
- include Wavedrom
6
+ class WavedromBlockProcessor < DiagramBlockProcessor
7
+ use_converter WavedromConverter
48
8
  end
49
9
 
50
- class WavedromBlockMacroProcessor < Extensions::DiagramBlockMacroProcessor
51
- include Wavedrom
10
+ class WavedromBlockMacroProcessor < DiagramBlockMacroProcessor
11
+ use_converter WavedromConverter
52
12
  end
53
13
  end
54
14
  end
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,44 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <bpmn:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_0zt4mn9" targetNamespace="http://bpmn.io/schema/bpmn" exporter="bpmn-js (https://demo.bpmn.io)" exporterVersion="5.1.2">
3
+ <bpmn:process id="Process_081h9u7" isExecutable="false">
4
+ <bpmn:startEvent id="StartEvent_00w25dz" name="Start">
5
+ <bpmn:outgoing>SequenceFlow_11u0n1f</bpmn:outgoing>
6
+ </bpmn:startEvent>
7
+ <bpmn:task id="Task_0yx8j7s" name="Task">
8
+ <bpmn:incoming>SequenceFlow_11u0n1f</bpmn:incoming>
9
+ <bpmn:outgoing>SequenceFlow_104th5x</bpmn:outgoing>
10
+ </bpmn:task>
11
+ <bpmn:sequenceFlow id="SequenceFlow_11u0n1f" sourceRef="StartEvent_00w25dz" targetRef="Task_0yx8j7s" />
12
+ <bpmn:endEvent id="EndEvent_0jxehtp" name="End">
13
+ <bpmn:incoming>SequenceFlow_104th5x</bpmn:incoming>
14
+ </bpmn:endEvent>
15
+ <bpmn:sequenceFlow id="SequenceFlow_104th5x" sourceRef="Task_0yx8j7s" targetRef="EndEvent_0jxehtp" />
16
+ </bpmn:process>
17
+ <bpmndi:BPMNDiagram id="BPMNDiagram_1">
18
+ <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_081h9u7">
19
+ <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_00w25dz">
20
+ <dc:Bounds x="156" y="81" width="36" height="36" />
21
+ <bpmndi:BPMNLabel>
22
+ <dc:Bounds x="162" y="124" width="24" height="14" />
23
+ </bpmndi:BPMNLabel>
24
+ </bpmndi:BPMNShape>
25
+ <bpmndi:BPMNShape id="Task_0yx8j7s_di" bpmnElement="Task_0yx8j7s">
26
+ <dc:Bounds x="250" y="59" width="100" height="80" />
27
+ </bpmndi:BPMNShape>
28
+ <bpmndi:BPMNEdge id="SequenceFlow_11u0n1f_di" bpmnElement="SequenceFlow_11u0n1f">
29
+ <di:waypoint x="192" y="99" />
30
+ <di:waypoint x="250" y="99" />
31
+ </bpmndi:BPMNEdge>
32
+ <bpmndi:BPMNShape id="EndEvent_0jxehtp_di" bpmnElement="EndEvent_0jxehtp">
33
+ <dc:Bounds x="412" y="81" width="36" height="36" />
34
+ <bpmndi:BPMNLabel>
35
+ <dc:Bounds x="420" y="124" width="20" height="14" />
36
+ </bpmndi:BPMNLabel>
37
+ </bpmndi:BPMNShape>
38
+ <bpmndi:BPMNEdge id="SequenceFlow_104th5x_di" bpmnElement="SequenceFlow_104th5x">
39
+ <di:waypoint x="350" y="99" />
40
+ <di:waypoint x="412" y="99" />
41
+ </bpmndi:BPMNEdge>
42
+ </bpmndi:BPMNPlane>
43
+ </bpmndi:BPMNDiagram>
44
+ </bpmn:definitions>
@@ -0,0 +1,96 @@
1
+ require_relative 'test_helper'
2
+
3
+ describe Asciidoctor::Diagram::BpmnBlockMacroProcessor do
4
+ it "should generate SVG images when format is set to 'svg'" do
5
+ FileUtils.cp(
6
+ File.expand_path('bpmn-example.xml', File.dirname(__FILE__)),
7
+ File.expand_path('bpmn-example.xml', Dir.getwd)
8
+ )
9
+
10
+ doc = <<-eos
11
+ = Hello, BPMN!
12
+ Doc Writer <doc@example.com>
13
+
14
+ == First Section
15
+
16
+ bpmn::bpmn-example.xml[format="svg"]
17
+ eos
18
+
19
+ d = load_asciidoc doc
20
+ expect(d).to_not be_nil
21
+
22
+ b = d.find { |bl| bl.context == :image }
23
+ expect(b).to_not be_nil
24
+
25
+ expect(b.content_model).to eq :empty
26
+
27
+ target = b.attributes['target']
28
+ expect(target).to_not be_nil
29
+ expect(target).to match(/\.svg/)
30
+ expect(File.exist?(target)).to be true
31
+
32
+ expect(b.attributes['width']).to_not be_nil
33
+ expect(b.attributes['height']).to_not be_nil
34
+ end
35
+
36
+ it "should generate PNG images when format is set to 'png'" do
37
+ FileUtils.cp(
38
+ File.expand_path('bpmn-example.xml', File.dirname(__FILE__)),
39
+ File.expand_path('bpmn-example.xml', Dir.getwd)
40
+ )
41
+
42
+ doc = <<-eos
43
+ = Hello, BPMN!
44
+ Doc Writer <doc@example.com>
45
+
46
+ == First Section
47
+
48
+ bpmn::bpmn-example.xml[format="png"]
49
+ eos
50
+
51
+ d = load_asciidoc doc
52
+ expect(d).to_not be_nil
53
+
54
+ b = d.find { |bl| bl.context == :image }
55
+ expect(b).to_not be_nil
56
+
57
+ expect(b.content_model).to eq :empty
58
+
59
+ target = b.attributes['target']
60
+ expect(target).to_not be_nil
61
+ expect(target).to match(/\.png$/)
62
+ expect(File.exist?(target)).to be true
63
+
64
+ expect(b.attributes['width']).to_not be_nil
65
+ expect(b.attributes['height']).to_not be_nil
66
+ end
67
+
68
+ it "should generate PDF images when format is set to 'pdf'" do
69
+ FileUtils.cp(
70
+ File.expand_path('bpmn-example.xml', File.dirname(__FILE__)),
71
+ File.expand_path('bpmn-example.xml', Dir.getwd)
72
+ )
73
+
74
+ doc = <<-eos
75
+ = Hello, BPMN!
76
+ Doc Writer <doc@example.com>
77
+
78
+ == First Section
79
+
80
+ bpmn::bpmn-example.xml[format="pdf"]
81
+ eos
82
+
83
+ d = load_asciidoc doc
84
+ expect(d).to_not be_nil
85
+
86
+ b = d.find { |bl| bl.context == :image }
87
+ expect(b).to_not be_nil
88
+
89
+ expect(b.content_model).to eq :empty
90
+
91
+ target = b.attributes['target']
92
+ expect(target).to_not be_nil
93
+ expect(target).to match(/\.pdf$/)
94
+ expect(File.exist?(target)).to be true
95
+ end
96
+ end