drawio_dsl 0.8.8 → 0.8.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +7 -0
  3. data/{.builders/.data/shapes.json → config/configuration.json} +49 -49
  4. data/docs/domain-modal/domain_model_custom.drawio +134 -134
  5. data/docs/domain-modal/domain_model_custom.svg +1 -1
  6. data/docs/domain_model.drawio +89 -89
  7. data/docs/domain_model.json +178 -178
  8. data/docs/parking_app.drawio +24 -24
  9. data/docs/parking_app.svg +1 -1
  10. data/docs/printspeak-architecture-generator.drawio +42 -30
  11. data/docs/printspeak-architecture-generator.svg +1 -1
  12. data/docs/project-plan/project.drawio +72 -60
  13. data/docs/project-plan/project_done.svg +1 -1
  14. data/docs/project-plan/project_in_progress.svg +1 -1
  15. data/lib/drawio_dsl/configuration.rb +99 -0
  16. data/lib/drawio_dsl/version.rb +1 -1
  17. data/lib/drawio_dsl.rb +2 -0
  18. data/package-lock.json +2 -2
  19. data/package.json +1 -1
  20. metadata +3 -31
  21. data/.builders/.templates/basic/configuration_shapes.rb +0 -27
  22. data/.builders/.templates/basic/dom_builder_shapes.rb +0 -17
  23. data/.builders/.templates/basic/drawio_extensions.rb +0 -58
  24. data/.builders/.templates/basic/drawio_shapes.rb +0 -23
  25. data/.builders/.templates/basic/schema_require.rb +0 -19
  26. data/.builders/.templates/basic/schema_shape.rb +0 -9
  27. data/.builders/.templates/basic/schema_shape_spec.rb +0 -13
  28. data/.builders/_.rb +0 -1
  29. data/.builders/blueprint/shapes.rb +0 -173
  30. data/.builders/boot.rb +0 -72
  31. data/.builders/generators/01-bootstrap.rb +0 -130
  32. data/.builders/generators/02-generate-app.rb +0 -47
  33. data/.builders/generators/10-transform-drawio-js.rb +0 -195
  34. data/.builders/generators/20-drawio-extensions.rb +0 -41
  35. data/.builders/generators/domain_diagram.rb +0 -474
  36. data/.builders/generators/parking-map.png +0 -0
  37. data/.builders/generators/parking_app.rb +0 -110
  38. data/.builders/generators/printspeak-architecture-generator.rb +0 -45
  39. data/.builders/generators/project-plan.rb +0 -85
  40. data/.builders/generators/sample_diagrams/05-samples.rb +0 -36
  41. data/.builders/generators/sample_diagrams/10-page-margin.rb +0 -42
  42. data/.builders/generators/sample_diagrams/15-grid-direction.rb +0 -34
  43. data/.builders/generators/sample_diagrams/16-grid-alignment.rb +0 -70
  44. data/.builders/generators/sample_diagrams/20-styles.rb +0 -61
  45. data/.builders/generators/sample_diagrams/25-themes.rb +0 -37
  46. data/.builders/generators/sample_diagrams/30-html-shapes.rb +0 -70
  47. data/.builders/generators/sample_diagrams/35-ids-and-arrows.rb +0 -28
  48. data/.builders/generators/sample_diagrams/50-willoughby-council.rb +0 -51
@@ -1,3 +1,3 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
2
  <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
3
- <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="942px" height="222px" viewBox="-0.5 -0.5 942 222"><defs><linearGradient x1="0%" y1="0%" x2="0%" y2="100%" id="mx-gradient-ffffff-0.9-ffffff-0.1-s-0"><stop offset="0%" style="stop-color: rgb(255, 255, 255); stop-opacity: 0.9;"/><stop offset="100%" style="stop-color: rgb(255, 255, 255); stop-opacity: 0.1;"/></linearGradient></defs><g><rect x="0" y="0" width="300" height="60" rx="9" ry="9" fill="#d5e8d4" stroke="#82b366" pointer-events="all"/><path d="M 10.15 -1 Q -1 -1 -1 10.15 L -1 24 Q 150 42 301 24 L 301 10.15 Q 301 -1 289.85 -1 Z" fill="url(#mx-gradient-ffffff-0.9-ffffff-0.1-s-0)" stroke="none" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility" style="overflow: visible; text-align: left;"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 298px; height: 1px; padding-top: 30px; margin-left: 1px;"><div data-drawio-colors="color: #333333; " style="box-sizing: border-box; font-size: 0px; text-align: center;"><div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(51, 51, 51); line-height: 1.2; pointer-events: all; white-space: normal; overflow-wrap: normal;">improve coverage</div></div></div></foreignObject><text x="150" y="34" fill="#333333" font-family="Helvetica" font-size="12px" text-anchor="middle">improve coverage</text></switch></g><rect x="320" y="0" width="300" height="60" rx="9" ry="9" fill="#d5e8d4" stroke="#82b366" pointer-events="all"/><path d="M 330.15 -1 Q 319 -1 319 10.15 L 319 24 Q 470 42 621 24 L 621 10.15 Q 621 -1 609.85 -1 Z" fill="url(#mx-gradient-ffffff-0.9-ffffff-0.1-s-0)" stroke="none" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility" style="overflow: visible; text-align: left;"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 298px; height: 1px; padding-top: 30px; margin-left: 321px;"><div data-drawio-colors="color: #333333; " style="box-sizing: border-box; font-size: 0px; text-align: center;"><div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(51, 51, 51); line-height: 1.2; pointer-events: all; white-space: normal; overflow-wrap: normal;">class html builder to support include/extend modules, class methods</div></div></div></foreignObject><text x="470" y="34" fill="#333333" font-family="Helvetica" font-size="12px" text-anchor="middle">class html builder to support include/extend modul...</text></switch></g><rect x="640" y="0" width="300" height="60" rx="9" ry="9" fill="#d5e8d4" stroke="#82b366" pointer-events="all"/><path d="M 650.15 -1 Q 639 -1 639 10.15 L 639 24 Q 790 42 941 24 L 941 10.15 Q 941 -1 929.85 -1 Z" fill="url(#mx-gradient-ffffff-0.9-ffffff-0.1-s-0)" stroke="none" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility" style="overflow: visible; text-align: left;"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 298px; height: 1px; padding-top: 30px; margin-left: 641px;"><div data-drawio-colors="color: #333333; " style="box-sizing: border-box; font-size: 0px; text-align: center;"><div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(51, 51, 51); line-height: 1.2; pointer-events: all; white-space: normal; overflow-wrap: normal;">add new shapes related to line connectors</div></div></div></foreignObject><text x="790" y="34" fill="#333333" font-family="Helvetica" font-size="12px" text-anchor="middle">add new shapes related to line connectors</text></switch></g><rect x="0" y="80" width="300" height="60" rx="9" ry="9" fill="#d5e8d4" stroke="#82b366" pointer-events="all"/><path d="M 10.15 79 Q -1 79 -1 90.15 L -1 104 Q 150 122 301 104 L 301 90.15 Q 301 79 289.85 79 Z" fill="url(#mx-gradient-ffffff-0.9-ffffff-0.1-s-0)" stroke="none" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility" style="overflow: visible; text-align: left;"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 298px; height: 1px; padding-top: 110px; margin-left: 1px;"><div data-drawio-colors="color: #333333; " style="box-sizing: border-box; font-size: 0px; text-align: center;"><div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(51, 51, 51); line-height: 1.2; pointer-events: all; white-space: normal; overflow-wrap: normal;">line connector aliases gives a simple way to use predefined line configurations</div></div></div></foreignObject><text x="150" y="114" fill="#333333" font-family="Helvetica" font-size="12px" text-anchor="middle">line connector aliases gives a simple way to use p...</text></switch></g><rect x="320" y="80" width="300" height="60" rx="9" ry="9" fill="#d5e8d4" stroke="#82b366" pointer-events="all"/><path d="M 330.15 79 Q 319 79 319 90.15 L 319 104 Q 470 122 621 104 L 621 90.15 Q 621 79 609.85 79 Z" fill="url(#mx-gradient-ffffff-0.9-ffffff-0.1-s-0)" stroke="none" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility" style="overflow: visible; text-align: left;"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 298px; height: 1px; padding-top: 110px; margin-left: 321px;"><div data-drawio-colors="color: #333333; " style="box-sizing: border-box; font-size: 0px; text-align: center;"><div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(51, 51, 51); line-height: 1.2; pointer-events: all; white-space: normal; overflow-wrap: normal;">line connectors need to support autolinking using ids</div></div></div></foreignObject><text x="470" y="114" fill="#333333" font-family="Helvetica" font-size="12px" text-anchor="middle">line connectors need to support autolinking using...</text></switch></g><rect x="640" y="80" width="300" height="60" rx="9" ry="9" fill="#d5e8d4" stroke="#82b366" pointer-events="all"/><path d="M 650.15 79 Q 639 79 639 90.15 L 639 104 Q 790 122 941 104 L 941 90.15 Q 941 79 929.85 79 Z" fill="url(#mx-gradient-ffffff-0.9-ffffff-0.1-s-0)" stroke="none" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility" style="overflow: visible; text-align: left;"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 298px; height: 1px; padding-top: 110px; margin-left: 641px;"><div data-drawio-colors="color: #333333; " style="box-sizing: border-box; font-size: 0px; text-align: center;"><div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(51, 51, 51); line-height: 1.2; pointer-events: all; white-space: normal; overflow-wrap: normal;">line connectors should not effect the grid positioning systems</div></div></div></foreignObject><text x="790" y="114" fill="#333333" font-family="Helvetica" font-size="12px" text-anchor="middle">line connectors should not effect the grid positio...</text></switch></g><rect x="0" y="160" width="300" height="60" rx="9" ry="9" fill="#d5e8d4" stroke="#82b366" pointer-events="all"/><path d="M 10.15 159 Q -1 159 -1 170.15 L -1 184 Q 150 202 301 184 L 301 170.15 Q 301 159 289.85 159 Z" fill="url(#mx-gradient-ffffff-0.9-ffffff-0.1-s-0)" stroke="none" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility" style="overflow: visible; text-align: left;"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 298px; height: 1px; padding-top: 190px; margin-left: 1px;"><div data-drawio-colors="color: #333333; " style="box-sizing: border-box; font-size: 0px; text-align: center;"><div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(51, 51, 51); line-height: 1.2; pointer-events: all; white-space: normal; overflow-wrap: normal;">export diagram json for use with a different DSL builder</div></div></div></foreignObject><text x="150" y="194" fill="#333333" font-family="Helvetica" font-size="12px" text-anchor="middle">export diagram json for use with a different DSL b...</text></switch></g></g><switch><g requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"/><a transform="translate(0,-5)" xlink:href="https://www.diagrams.net/doc/faq/svg-export-text-problems" target="_blank"><text text-anchor="middle" font-size="10px" x="50%" y="100%">Text is not SVG - cannot display</text></a></switch></svg>
3
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="942px" height="142px" viewBox="-0.5 -0.5 942 142"><defs><linearGradient x1="0%" y1="0%" x2="0%" y2="100%" id="mx-gradient-ffffff-0.9-ffffff-0.1-s-0"><stop offset="0%" style="stop-color: rgb(255, 255, 255); stop-opacity: 0.9;"/><stop offset="100%" style="stop-color: rgb(255, 255, 255); stop-opacity: 0.1;"/></linearGradient></defs><g><rect x="0" y="0" width="300" height="60" rx="9" ry="9" fill="#d5e8d4" stroke="#82b366" pointer-events="all"/><path d="M 10.15 -1 Q -1 -1 -1 10.15 L -1 24 Q 150 42 301 24 L 301 10.15 Q 301 -1 289.85 -1 Z" fill="url(#mx-gradient-ffffff-0.9-ffffff-0.1-s-0)" stroke="none" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility" style="overflow: visible; text-align: left;"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 298px; height: 1px; padding-top: 30px; margin-left: 1px;"><div data-drawio-colors="color: #333333; " style="box-sizing: border-box; font-size: 0px; text-align: center;"><div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(51, 51, 51); line-height: 1.2; pointer-events: all; white-space: normal; overflow-wrap: normal;">add new shapes related to line connectors</div></div></div></foreignObject><text x="150" y="34" fill="#333333" font-family="Helvetica" font-size="12px" text-anchor="middle">add new shapes related to line connectors</text></switch></g><rect x="320" y="0" width="300" height="60" rx="9" ry="9" fill="#d5e8d4" stroke="#82b366" pointer-events="all"/><path d="M 330.15 -1 Q 319 -1 319 10.15 L 319 24 Q 470 42 621 24 L 621 10.15 Q 621 -1 609.85 -1 Z" fill="url(#mx-gradient-ffffff-0.9-ffffff-0.1-s-0)" stroke="none" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility" style="overflow: visible; text-align: left;"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 298px; height: 1px; padding-top: 30px; margin-left: 321px;"><div data-drawio-colors="color: #333333; " style="box-sizing: border-box; font-size: 0px; text-align: center;"><div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(51, 51, 51); line-height: 1.2; pointer-events: all; white-space: normal; overflow-wrap: normal;">line connector aliases gives a simple way to use predefined line configurations</div></div></div></foreignObject><text x="470" y="34" fill="#333333" font-family="Helvetica" font-size="12px" text-anchor="middle">line connector aliases gives a simple way to use p...</text></switch></g><rect x="640" y="0" width="300" height="60" rx="9" ry="9" fill="#d5e8d4" stroke="#82b366" pointer-events="all"/><path d="M 650.15 -1 Q 639 -1 639 10.15 L 639 24 Q 790 42 941 24 L 941 10.15 Q 941 -1 929.85 -1 Z" fill="url(#mx-gradient-ffffff-0.9-ffffff-0.1-s-0)" stroke="none" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility" style="overflow: visible; text-align: left;"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 298px; height: 1px; padding-top: 30px; margin-left: 641px;"><div data-drawio-colors="color: #333333; " style="box-sizing: border-box; font-size: 0px; text-align: center;"><div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(51, 51, 51); line-height: 1.2; pointer-events: all; white-space: normal; overflow-wrap: normal;">line connectors need to support autolinking using ids</div></div></div></foreignObject><text x="790" y="34" fill="#333333" font-family="Helvetica" font-size="12px" text-anchor="middle">line connectors need to support autolinking using...</text></switch></g><rect x="0" y="80" width="300" height="60" rx="9" ry="9" fill="#d5e8d4" stroke="#82b366" pointer-events="all"/><path d="M 10.15 79 Q -1 79 -1 90.15 L -1 104 Q 150 122 301 104 L 301 90.15 Q 301 79 289.85 79 Z" fill="url(#mx-gradient-ffffff-0.9-ffffff-0.1-s-0)" stroke="none" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility" style="overflow: visible; text-align: left;"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 298px; height: 1px; padding-top: 110px; margin-left: 1px;"><div data-drawio-colors="color: #333333; " style="box-sizing: border-box; font-size: 0px; text-align: center;"><div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(51, 51, 51); line-height: 1.2; pointer-events: all; white-space: normal; overflow-wrap: normal;">line connectors should not effect the grid positioning systems</div></div></div></foreignObject><text x="150" y="114" fill="#333333" font-family="Helvetica" font-size="12px" text-anchor="middle">line connectors should not effect the grid positio...</text></switch></g><rect x="320" y="80" width="300" height="60" rx="9" ry="9" fill="#d5e8d4" stroke="#82b366" pointer-events="all"/><path d="M 330.15 79 Q 319 79 319 90.15 L 319 104 Q 470 122 621 104 L 621 90.15 Q 621 79 609.85 79 Z" fill="url(#mx-gradient-ffffff-0.9-ffffff-0.1-s-0)" stroke="none" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility" style="overflow: visible; text-align: left;"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 298px; height: 1px; padding-top: 110px; margin-left: 321px;"><div data-drawio-colors="color: #333333; " style="box-sizing: border-box; font-size: 0px; text-align: center;"><div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(51, 51, 51); line-height: 1.2; pointer-events: all; white-space: normal; overflow-wrap: normal;">improve coverage</div></div></div></foreignObject><text x="470" y="114" fill="#333333" font-family="Helvetica" font-size="12px" text-anchor="middle">improve coverage</text></switch></g><rect x="640" y="80" width="300" height="60" rx="9" ry="9" fill="#d5e8d4" stroke="#82b366" pointer-events="all"/><path d="M 650.15 79 Q 639 79 639 90.15 L 639 104 Q 790 122 941 104 L 941 90.15 Q 941 79 929.85 79 Z" fill="url(#mx-gradient-ffffff-0.9-ffffff-0.1-s-0)" stroke="none" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility" style="overflow: visible; text-align: left;"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 298px; height: 1px; padding-top: 110px; margin-left: 641px;"><div data-drawio-colors="color: #333333; " style="box-sizing: border-box; font-size: 0px; text-align: center;"><div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(51, 51, 51); line-height: 1.2; pointer-events: all; white-space: normal; overflow-wrap: normal;">class html builder to support include/extend modules, class methods</div></div></div></foreignObject><text x="790" y="114" fill="#333333" font-family="Helvetica" font-size="12px" text-anchor="middle">class html builder to support include/extend modul...</text></switch></g></g><switch><g requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"/><a transform="translate(0,-5)" xlink:href="https://www.diagrams.net/doc/faq/svg-export-text-problems" target="_blank"><text text-anchor="middle" font-size="10px" x="50%" y="100%">Text is not SVG - cannot display</text></a></switch></svg>
@@ -29,6 +29,105 @@ module DrawioDsl
29
29
  def random_theme
30
30
  themes.keys.sample
31
31
  end
32
+
33
+ def stroke(type)
34
+ strokes[type] || ''
35
+ end
36
+
37
+ def strokes
38
+ return @strokes if defined? @strokes
39
+
40
+ @strokes = {}
41
+ source_config['strokes'].each do |stroke|
42
+ @strokes[stroke['type'].to_sym] = stroke['style']
43
+ end
44
+
45
+ @strokes
46
+ end
47
+
48
+ def connector
49
+ @connector ||= Connector.new(source_config['connector'])
50
+ end
51
+
52
+ def source_config
53
+ return @source_config if defined? @source_config
54
+
55
+ @source_config = begin
56
+ file = File.join(DrawioDsl::ROOT_PATH, 'config/configuration.json')
57
+ JSON.parse(File.read(file))
58
+ end
59
+ end
60
+
61
+ # Configuration for line connections between shapes
62
+ class Connector
63
+ attr_reader :source_config
64
+
65
+ XyConfig = Struct.new(:x, :y, keyword_init: true)
66
+
67
+ def initialize(source_config)
68
+ @source_config = source_config
69
+ end
70
+
71
+ def compass_point(type)
72
+ compass_points[type] || XyConfig.new(x: 0, y: 0)
73
+ end
74
+
75
+ def compass_points
76
+ return @compass_points if defined? @compass_points
77
+
78
+ @compass_points = {}
79
+ source_config['compass_points'].each do |compass_point|
80
+ @compass_points[compass_point['type'].to_sym] = XyConfig.new(x: compass_point['x'], y: compass_point['y'])
81
+ end
82
+
83
+ @compass_points
84
+ end
85
+
86
+ def waypoint(type)
87
+ waypoints[type] || ''
88
+ end
89
+
90
+ def waypoints
91
+ return @waypoints if defined? @waypoints
92
+
93
+ @waypoints = {}
94
+ source_config['waypoints'].each do |waypoint|
95
+ @waypoints[waypoint['type'].to_sym] = waypoint['style']
96
+ end
97
+
98
+ @waypoints
99
+ end
100
+
101
+ def arrow(type)
102
+ arrows[type] || 'open'
103
+ end
104
+
105
+ def arrows
106
+ return @arrows if defined? @arrows
107
+
108
+ @arrows = {}
109
+ source_config['arrows'].each do |arrow|
110
+ @arrows[arrow['type'].to_sym] = arrow['style']
111
+ end
112
+
113
+ @arrows
114
+ end
115
+
116
+ def design(type)
117
+ designs[type] || ''
118
+ end
119
+
120
+ def designs
121
+ return @designs if defined? @designs
122
+
123
+ @designs = {}
124
+ source_config['designs'].each do |design|
125
+ @designs[design['type'].to_sym] = design['style']
126
+ end
127
+
128
+ @designs
129
+ end
130
+ end
32
131
  end
33
132
  end
34
133
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DrawioDsl
4
- VERSION = '0.8.8'
4
+ VERSION = '0.8.9'
5
5
  end
data/lib/drawio_dsl.rb CHANGED
@@ -28,6 +28,8 @@ module DrawioDsl
28
28
  # raise DrawioDsl::Error, 'Sample message'
29
29
  Error = Class.new(StandardError)
30
30
 
31
+ ROOT_PATH = File.expand_path('..', __dir__)
32
+
31
33
  # Your code goes here...
32
34
  end
33
35
 
data/package-lock.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "drawio_dsl",
3
- "version": "0.8.8",
3
+ "version": "0.8.9",
4
4
  "lockfileVersion": 2,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "drawio_dsl",
9
- "version": "0.8.8",
9
+ "version": "0.8.9",
10
10
  "devDependencies": {
11
11
  "@klueless-js/semantic-release-rubygem": "github:klueless-js/semantic-release-rubygem",
12
12
  "@semantic-release/changelog": "^6.0.1",
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "drawio_dsl",
3
- "version": "0.8.8",
3
+ "version": "0.8.9",
4
4
  "description": "DrawIO DSL can build DrawIO diagrams using a Domain Specific Language",
5
5
  "scripts": {
6
6
  "release": "semantic-release"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: drawio_dsl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.8
4
+ version: 0.8.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Cruwys
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-03-21 00:00:00.000000000 Z
11
+ date: 2022-03-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: k_config
@@ -73,35 +73,6 @@ executables: []
73
73
  extensions: []
74
74
  extra_rdoc_files: []
75
75
  files:
76
- - ".builders/.data/shapes.json"
77
- - ".builders/.templates/basic/configuration_shapes.rb"
78
- - ".builders/.templates/basic/dom_builder_shapes.rb"
79
- - ".builders/.templates/basic/drawio_extensions.rb"
80
- - ".builders/.templates/basic/drawio_shapes.rb"
81
- - ".builders/.templates/basic/schema_require.rb"
82
- - ".builders/.templates/basic/schema_shape.rb"
83
- - ".builders/.templates/basic/schema_shape_spec.rb"
84
- - ".builders/_.rb"
85
- - ".builders/blueprint/shapes.rb"
86
- - ".builders/boot.rb"
87
- - ".builders/generators/01-bootstrap.rb"
88
- - ".builders/generators/02-generate-app.rb"
89
- - ".builders/generators/10-transform-drawio-js.rb"
90
- - ".builders/generators/20-drawio-extensions.rb"
91
- - ".builders/generators/domain_diagram.rb"
92
- - ".builders/generators/parking-map.png"
93
- - ".builders/generators/parking_app.rb"
94
- - ".builders/generators/printspeak-architecture-generator.rb"
95
- - ".builders/generators/project-plan.rb"
96
- - ".builders/generators/sample_diagrams/05-samples.rb"
97
- - ".builders/generators/sample_diagrams/10-page-margin.rb"
98
- - ".builders/generators/sample_diagrams/15-grid-direction.rb"
99
- - ".builders/generators/sample_diagrams/16-grid-alignment.rb"
100
- - ".builders/generators/sample_diagrams/20-styles.rb"
101
- - ".builders/generators/sample_diagrams/25-themes.rb"
102
- - ".builders/generators/sample_diagrams/30-html-shapes.rb"
103
- - ".builders/generators/sample_diagrams/35-ids-and-arrows.rb"
104
- - ".builders/generators/sample_diagrams/50-willoughby-council.rb"
105
76
  - ".releaserc.json"
106
77
  - ".rspec"
107
78
  - ".rubocop.yml"
@@ -115,6 +86,7 @@ files:
115
86
  - Rakefile
116
87
  - bin/console
117
88
  - bin/setup
89
+ - config/configuration.json
118
90
  - docs/domain-modal.md
119
91
  - docs/domain-modal/domain_model.drawio
120
92
  - docs/domain-modal/domain_model.svg
@@ -1,27 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Attach configuration to the DrawIO DSL module
4
- # :nocov:
5
- module DrawioDsl
6
- # Used to attach configuration to KConfig module
7
- module ConfigurationShapes
8
- ShapeDefaults = Struct.new(:type, :category, :x, :y, :w, :h, :style_modifiers, keyword_init: true)
9
- Shapes = Struct.new(
10
- :shape,
11
- {{#each shapes}}
12
- :{{snake ./type}},
13
- {{/each}}
14
- keyword_init: true
15
- )
16
-
17
- def add_shapes
18
- @shapes = Shapes.new(
19
- shape: ShapeDefaults.new(type: :shape, category: :element, x: 0, y: 0, w: 20, h: 20, style_modifiers: ''),
20
- {{#each shapes}}
21
- {{snake ./type}}: ShapeDefaults.new(type: :{{snake ./type}}, x: {{./x}}, category: :{{./category}}, y: {{./y}}, w: {{./w}}, h: {{./h}}, style_modifiers: '{{{./style_modifiers}}}'){{#if @last}}{{^}},{{/if}}
22
- {{/each}}
23
- )
24
- end
25
- end
26
- end
27
- # :nocov:
@@ -1,17 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # :nocov:
4
- module DrawioDsl
5
- # DrawioDsl is a DSL for draw-io diagrams.
6
- module DomBuilderShapes
7
- {{#each shapes}}
8
-
9
- def add_{{snake ./type}}(id = nil, **opts, &block)
10
- opts = { id: id }.merge(opts) if id
11
- {{snake ./type}} = DrawioDsl::Schema::{{camel ./type}}.new(current_page, **opts, &block)
12
- add_shape({{snake ./type}})
13
- end
14
- {{/each}}
15
- end
16
- end
17
- # :nocov:
@@ -1,58 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module DrawioDsl
4
- # :nocov:
5
- # 1000's of extension shapes derived from Extensions.js that can be used via the add_shape method
6
- class DrawioExtensions
7
-
8
- attr_reader :sections
9
- attr_reader :current_section
10
-
11
- def initialize
12
- @sections = []
13
- end
14
-
15
- def section(name)
16
- @current_section = {
17
- name: name,
18
- shapes: []
19
- }
20
- @sections << current_section
21
-
22
- yield if block_given?
23
- end
24
-
25
- def shape(name, style, original_name)
26
- shape = {
27
- name: name,
28
- style: style,
29
- original_name: original_name
30
- }
31
- current_section[:shapes] << shape
32
- shape
33
- end
34
-
35
- def to_h
36
- {
37
- sections: @sections.map(&:to_h)
38
- }
39
- end
40
-
41
- # This methods was generated using Extensions.js
42
- # This generation can be improved over time and the code to do the generation
43
- # can be found in the .builders/generators/10-transform-drawio-js.rb.
44
- # original source: ~/dev/tools/drawio-desktop/drawio/src/main/webapp/js/diagramly/Extensions.js
45
- def build_extensions
46
- # Constants
47
- {{{constants}}}
48
- {{#each sections}}
49
- section :{{snake ./name}} do
50
- {{#each ./shapes}}
51
- shape :{{padr (snake ./name) 60}}, "{{{./style}}}", "{{./name}}"
52
- {{/each}}
53
- end
54
- {{/each}}
55
- end
56
- end
57
- # :nocov:
58
- end
@@ -1,23 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module DrawioDsl
4
- # List of DSL methods for each common shape
5
- # :nocov:
6
- module DrawioShapes
7
- def random(**opts)
8
- case rand({{shape_length}})
9
- {{#each shapes}}
10
- when {{@index}}
11
- {{snake ./type}}(**opts)
12
- {{/each}}
13
- end
14
- end
15
- {{#each shapes}}
16
-
17
- def {{snake ./type}}(id = nil, **opts, &block)
18
- builder.add_{{snake ./type}}(id, **opts, &block)
19
- end
20
- {{/each}}
21
- end
22
- # :nocov:
23
- end
@@ -1,19 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative 'common_style'
4
- require_relative 'default_palette'
5
- require_relative 'diagram'
6
- require_relative 'node'
7
- require_relative 'node_list'
8
- require_relative 'page'
9
-
10
- require_relative 'layouts/layout'
11
- require_relative 'layouts/flex_layout'
12
- require_relative 'layouts/grid_layout'
13
-
14
- require_relative 'shapes/shape'
15
- {{#each shapes}}
16
- require_relative 'shapes/{{snake ./type}}'
17
- {{/each}}
18
-
19
- require_relative 'virtual/anchor'
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module DrawioDsl
4
- module Schema
5
- class {{camel shape.type}} < Shape
6
- configure_shape(:{{snake shape.type}})
7
- end
8
- end
9
- end
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe DrawioDsl::Schema::{{camel shape.type}} do
4
- include_context :node_dependencies
5
-
6
- subject { instance }
7
-
8
- let(:instance) { described_class.new(diagram, **args) }
9
- let(:args) { { id: 1 } }
10
- let(:default) { KConfig.configuration.drawio.shapes.{{snake shape.type}} }
11
-
12
- it_behaves_like :basic_shape_attributes
13
- end
data/.builders/_.rb DELETED
@@ -1 +0,0 @@
1
- # require_relative './path/here'
@@ -1,173 +0,0 @@
1
- m = KManager.model :shapes, namespace: %i[domain] do
2
- # microapp = import(:handlebars_helpers, :microapp)
3
-
4
- # other settings
5
- # strokeWidth: 1-n
6
- # when there is an arrow at beginning
7
- # startFill=1,0
8
- # when there is an arrow at end
9
- # endFill=1,0
10
-
11
-
12
- table :strokes do
13
- fields [:name, :style]
14
-
15
- row :dashed , 'dashed=1;fixDash=1'
16
- row :dotted , 'dashed=1;fixDash=1;dashPattern=1 4'
17
- row :dashdot , 'dashed=1;fixDash=1;dashPattern=10 5 1 5'
18
- row :dashdotdot , 'dashed=1;fixDash=1;dashPattern=10 5 1 5 1 5'
19
- row :dotdotdot , 'dashed=1;fixDash=1;dashPattern=1 2'
20
- row :longdash , 'dashed=1;fixDash=1;dashPattern=16 6'
21
- row :dashlongdash , 'dashed=1;fixDash=1;dashPattern=10 6 16 6'
22
- row :dashed24 , 'dashed=1;fixDash=1;dashPattern=3 8'
23
- row :dashed32 , 'dashed=1;fixDash=1;dashPattern=6 5'
24
- row :dashed44 , 'dashed=1;fixDash=1;dashPattern=8 8'
25
- end
26
-
27
- table :connector_compass do
28
- fields %i[name x y]
29
-
30
- row :n , x: 0.5 , y: 0 # 'exitX=0.5;exitY=0;exitDx=0;exitDy=0' 'entryX=0.5;entryY=0;entryDx=0;entryDy=0'
31
- row :ne , x: 1 , y: 0 # 'exitX=1;exitY=0;exitDx=0;exitDy=0' 'entryX=1;entryY=0;entryDx=0;entryDy=0'
32
- row :e , x: 1 , y: 0.5 # 'exitX=1;exitY=0.5;exitDx=0;exitDy=0' 'entryX=1;entryY=0.5;entryDx=0;entryDy=0'
33
- row :se , x: 1 , y: 1 # 'exitX=1;exitY=1;exitDx=0;exitDy=0' 'entryX=1;entryY=1;entryDx=0;entryDy=0'
34
- row :s , x: 0.5 , y: 1 # 'exitX=0.5;exitY=1;exitDx=0;exitDy=0' 'entryX=0.5;entryY=1;entryDx=0;entryDy=0'
35
- row :sw , x: 0 , y: 1 # 'exitX=0;exitY=1;exitDx=0;exitDy=0' 'entryX=0;entryY=1;entryDx=0;entryDy=0'
36
- row :w , x: 0 , y: 0.5 # 'exitX=0;exitY=0.5;exitDx=0;exitDy=0' 'entryX=0;entryY=0.5;entryDx=0;entryDy=0'
37
- row :nw , x: 0 , y: 0 # 'exitX=0;exitY=0;exitDx=0;exitDy=0' 'entryX=0;entryY=0;entryDx=0;entryDy=0'
38
- end
39
-
40
- table :connector_design do
41
- fields [:name, :style]
42
-
43
- row :style1, ''
44
- row :style2, 'shape=link'
45
- row :style3, 'shape=flexArrow'
46
- row :style4, 'shape=arrow'
47
- end
48
-
49
- table :connector_arrows do
50
- fields [:name, :style]
51
-
52
- row :simple , 'open'
53
- row :triangle , 'block'
54
- row :diamond , 'diamond'
55
- row :circle , 'oval'
56
- row :cross , 'cross'
57
- row :short , 'classicThin'
58
- row :default , 'classic'
59
- row :none , 'none'
60
- row :plain , 'open'
61
- row :skewed_dash , 'dash'
62
- row :concave , 'openThin'
63
- row :er_many , 'ERmany'
64
- row :er_one , 'ERone'
65
- row :er_one_optional , 'ERzeroToOne'
66
- row :er_one_mandatory , 'ERmandOne'
67
- row :er_many_optional , 'ERzeroToMany'
68
- row :er_many_mandatory , 'ERoneToMany'
69
- end
70
-
71
- table :connector_waypoints do # aka edgeStyle
72
- fields [:name, :style]
73
-
74
- row :straight , 'edgeStyle=none'
75
- row :orthogonal , 'edgeStyle=orthogonalEdgeStyle'
76
- row :elbow , 'edgeStyle=elbowEdgeStyle'
77
- row :elbow_vertical , 'edgeStyle=elbowEdgeStyle;elbow=vertical'
78
- row :isometric , 'edgeStyle=isometricEdgeStyle'
79
- row :isometric_vertical , 'edgeStyle=isometricEdgeStyle;elbow=vertical'
80
- row :orthogonal_curved , 'edgeStyle=orthogonalEdgeStyle;curved=1'
81
- row :entity_relation , 'edgeStyle=entityRelationEdgeStyle'
82
- end
83
-
84
- table :shapes do
85
- fields [:type, :category, :x, :y, :w, :h, :style_modifiers]
86
-
87
- # shape is a custom object
88
- # row :shape , 0, 0, 20, 20, ''
89
-
90
- row :line , :line , 0, 0, 50, 50, 'edgeStyle=none;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0'
91
- # row :line , :line , 0, 0, 50, 50, 'edgeStyle=entityRelationEdgeStyle;strokeWidth=1;elbow=vertical;startArrow=none;startFill=0;endArrow=block;endFill=0;targetPerimeterSpacing=0;shape=flexArrow;endSize=6;fillStyle=zigzag;'
92
- # row :dashed , 'dashed=1;fixDash=1'
93
- # row :dotted , 'dashed=1;fixDash=1;dashPattern=1 4'
94
- # row :dashdot , 'dashed=1;fixDash=1;dashPattern=10 5 1 5'
95
- # row :dashdotdot , 'dashed=1;fixDash=1;dashPattern=10 5 1 5 1 5'
96
- # row :dotdotdot , 'dashed=1;fixDash=1;dashPattern=1 2'
97
- # row :longdash , 'dashed=1;fixDash=1;dashPattern=16 6'
98
- # row :dashlongdash , 'dashed=1;fixDash=1;dashPattern=10 6 16 6'
99
- # row :dashed24 , 'dashed=1;fixDash=1;dashPattern=3 8'
100
- # row :dashed32 , 'dashed=1;fixDash=1;dashPattern=6 5'
101
- # row :dashed44 , 'dashed=1;fixDash=1;dashPattern=8 8'
102
- # edge="1" parent="node_root_2T8" source="b" target="c"
103
-
104
- # configuration for general purpose shapes
105
- row :h1 , :text , 0, 0, 100, 50, 'text;fontSize=89;fontColor=#ffffff;fontStyle=1;fillColor=none'
106
- row :h2 , :text , 0, 0, 100, 50, 'text;fontSize=67;fontColor=#ffffff;fontStyle=1;fillColor=none'
107
- row :h3 , :text , 0, 0, 100, 50, 'text;fontSize=50;fontColor=#ffffff;fontStyle=1;fillColor=none'
108
- row :h4 , :text , 0, 0, 100, 50, 'text;fontSize=37;fontColor=#ffffff;fontStyle=1;fillColor=none'
109
- row :h5 , :text , 0, 0, 100, 50, 'text;fontSize=28;fontColor=#ffffff;fontStyle=1;fillColor=none'
110
- row :h6 , :text , 0, 0, 100, 50, 'text;fontSize=21;fontColor=#ffffff;fontStyle=1;fillColor=none'
111
- row :p , :text , 0, 0, 100, 50, 'text;fontSize=16;fontColor=#ffffff;fontStyle=1;fillColor=none'
112
-
113
- row :actor , :element, 0, 0, 40, 50, 'shape=actor'
114
- row :actor2 , :element, 0, 0, 30, 50, 'shape=umlActor;verticalLabelPosition=bottom;outlineConnect=1'
115
- row :callout , :element, 0, 0, 160, 120, 'shape=callout'
116
- row :callout2 , :element, 0, 0, 160, 160, 'shape=mxgraph.basic.oval_callout'
117
- row :callout3 , :element, 0, 0, 160, 160, 'shape=mxgraph.basic.cloud_callout'
118
- row :callout4 , :element, 0, 0, 160, 120, 'shape=mxgraph.basic.roundRectCallout;dx=30;dy=15;size=5;boundedLbl=1;'
119
- row :circle , :element, 0, 0, 160, 160, 'ellipse'
120
- row :cloud , :element, 0, 0, 160, 160, 'shape=cloud'
121
- row :container , :element, 0, 0, 160, 160, 'swimlane'
122
- row :container2 , :element, 0, 0, 160, 160, 'swimlane;horizontal=0'
123
- row :container3 , :element, 0, 0, 160, 160, 'swimlane;startSize=50'
124
- row :container4 , :element, 0, 0, 160, 160, 'swimlane;resizable=0'
125
- row :cross , :element, 0, 0, 50, 50, 'verticalLabelPosition=bottom;verticalAlign=top;html=1;shape=mxgraph.basic.x'
126
- row :envelop , :element, 0, 0, 160, 100, 'shape=message'
127
- row :database , :element, 0, 0, 160, 80, 'shape=mxgraph.flowchart.database;strokeWidth=1'
128
- row :db_json , :element, 0, 0, 160, 40, 'shape=mxgraph.flowchart.database;strokeWidth=1'
129
- row :diamond , :element, 0, 0, 100, 100, 'rhombus'
130
- row :document , :element, 0, 0, 160, 160, 'shape=mxgraph.basic.document'
131
- row :ellipse , :element, 0, 0, 200, 120, 'ellipse'
132
- row :group , :element, 0, 0, 210, 210, 'fontSize=20;verticalAlign=top'
133
- row :hexagon , :element, 0, 0, 200, 120, 'shape=hexagon'
134
- row :interface , :element, 0, 0, 160, 160, 'align=left;overflow=fill;fontSize=12;fontFamily=Helvetica'
135
- row :klass , :element, 0, 0, 160, 160, 'align=left;overflow=fill;fontSize=12;fontFamily=Helvetica'
136
- row :note , :element, 0, 0, 160, 160, 'shape=note'
137
- row :process , :element, 0, 0, 200, 120, 'shape=process'
138
- row :rectangle , :element, 0, 0, 200, 120, ''
139
- row :rectangle2 , :element, 0, 0, 200, 120, 'shape=mxgraph.basic.cloud_rect'
140
- row :square , :element, 0, 0, 160, 160, ''
141
- row :step , :element, 0, 0, 120, 80, 'shape=step;perimeter=stepPerimeter;fixedSize=1'
142
- row :tick , :element, 0, 0, 50, 50, 'verticalLabelPosition=bottom;verticalAlign=top;shape=mxgraph.basic.tick'
143
- row :todo , :element, 0, 0, 300, 60, ''
144
- row :face , :element, 0, 0, 100, 100, 'verticalLabelPosition=bottom;verticalAlign=top;shape=mxgraph.basic.smiley'
145
- row :triangle , :element, 0, 0, 100, 100, 'triangle'
146
-
147
- # configuration for embedded element shape
148
- # note that the width / height probably should be driven of parent shape
149
- row :embed_row , :element, 0, 0, 200, 40, 'shape=partialRectangle;collapsible=0;dropTarget=0;pointerEvents=0;top=0;left=0;bottom=1;right=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest'
150
- row :embed_col50 , :element, 0, 0, 50, 40, 'shape=partialRectangle;connectable=0;top=0;left=0;bottom=0;right=0;fontStyle=1;overflow=hidden'
151
- row :embed_col200 , :element, 0, 0, 150, 40, 'shape=partialRectangle;connectable=0;top=0;left=0;bottom=0;right=0;align=left;spacingLeft=6;overflow=hidden'
152
- end
153
-
154
- action do
155
- data = self.raw_data
156
- content = {
157
- strokes: data['strokes'],
158
- connector: {
159
- compass: data['connector_compass'],
160
- waypoints: data['connector_waypoints'],
161
- arrows: data['connector_arrows'],
162
- design: data['connector_design']
163
- },
164
- shapes: data['shapes'],
165
- }
166
-
167
- k_builder
168
- .cd(:data)
169
- .add_file('shapes.json', content: JSON.pretty_generate(content), on_exist: :write)
170
- end
171
- end
172
-
173
-