drawio_dsl 0.3.0 → 0.5.0

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 (72) hide show
  1. checksums.yaml +4 -4
  2. data/.builders/.data/shapes.json +218 -0
  3. data/.builders/.templates/basic/configuration_shapes.rb +27 -0
  4. data/.builders/.templates/basic/dom_builder_shapes.rb +16 -0
  5. data/.builders/.templates/basic/drawio_shapes.rb +23 -0
  6. data/.builders/.templates/basic/schema_require.rb +16 -0
  7. data/.builders/.templates/basic/schema_shape.rb +9 -0
  8. data/.builders/.templates/basic/schema_shape_spec.rb +13 -0
  9. data/.builders/blueprint/shapes.rb +48 -0
  10. data/.builders/boot.rb +6 -0
  11. data/.builders/generators/02-generate-app.rb +43 -0
  12. data/.builders/generators/{10-page-margin.rb → sample_diagrams/10-page-margin.rb} +0 -0
  13. data/.builders/generators/{15-grid-direction.rb → sample_diagrams/15-grid-direction.rb} +0 -0
  14. data/.builders/generators/{16-grid-alignment.rb → sample_diagrams/16-grid-alignment.rb} +0 -0
  15. data/.builders/generators/{20-styles.rb → sample_diagrams/20-styles.rb} +0 -0
  16. data/.builders/generators/{25-themes.rb → sample_diagrams/25-themes.rb} +5 -2
  17. data/.builders/generators/sample_diagrams/30-shapes.rb +23 -0
  18. data/.rubocop.yml +20 -3
  19. data/CHANGELOG.md +21 -0
  20. data/README.md +4 -0
  21. data/lib/drawio_dsl/configuration.rb +7 -94
  22. data/lib/drawio_dsl/configuration_extension.rb +13 -0
  23. data/lib/drawio_dsl/configuration_shapes.rb +75 -0
  24. data/lib/drawio_dsl/configuration_themes.rb +63 -0
  25. data/lib/drawio_dsl/dom_builder.rb +4 -35
  26. data/lib/drawio_dsl/dom_builder_shapes.rb +143 -0
  27. data/lib/drawio_dsl/drawio.rb +1 -73
  28. data/lib/drawio_dsl/drawio_shapes.rb +175 -0
  29. data/lib/drawio_dsl/layout_engine.rb +1 -1
  30. data/lib/drawio_dsl/schema/_.rb +40 -0
  31. data/lib/drawio_dsl/schema/common_style.rb +42 -0
  32. data/lib/drawio_dsl/schema/default_palette.rb +31 -0
  33. data/lib/drawio_dsl/schema/diagram.rb +57 -0
  34. data/lib/drawio_dsl/schema/layouts/flex_layout.rb +87 -0
  35. data/lib/drawio_dsl/schema/layouts/grid_layout.rb +102 -0
  36. data/lib/drawio_dsl/schema/layouts/layout.rb +41 -0
  37. data/lib/drawio_dsl/schema/node.rb +53 -0
  38. data/lib/drawio_dsl/schema/page.rb +135 -0
  39. data/lib/drawio_dsl/schema/shapes/actor.rb +9 -0
  40. data/lib/drawio_dsl/schema/shapes/actor2.rb +9 -0
  41. data/lib/drawio_dsl/schema/shapes/callout.rb +9 -0
  42. data/lib/drawio_dsl/schema/shapes/callout2.rb +9 -0
  43. data/lib/drawio_dsl/schema/shapes/callout3.rb +9 -0
  44. data/lib/drawio_dsl/schema/shapes/callout4.rb +9 -0
  45. data/lib/drawio_dsl/schema/shapes/circle.rb +9 -0
  46. data/lib/drawio_dsl/schema/shapes/cloud.rb +9 -0
  47. data/lib/drawio_dsl/schema/shapes/container.rb +9 -0
  48. data/lib/drawio_dsl/schema/shapes/container2.rb +9 -0
  49. data/lib/drawio_dsl/schema/shapes/container3.rb +9 -0
  50. data/lib/drawio_dsl/schema/shapes/container4.rb +9 -0
  51. data/lib/drawio_dsl/schema/shapes/cross.rb +9 -0
  52. data/lib/drawio_dsl/schema/shapes/diamond.rb +9 -0
  53. data/lib/drawio_dsl/schema/shapes/document.rb +9 -0
  54. data/lib/drawio_dsl/schema/shapes/ellipse.rb +9 -0
  55. data/lib/drawio_dsl/schema/shapes/envelop.rb +9 -0
  56. data/lib/drawio_dsl/schema/shapes/face.rb +9 -0
  57. data/lib/drawio_dsl/schema/shapes/hexagon.rb +9 -0
  58. data/lib/drawio_dsl/schema/shapes/note.rb +9 -0
  59. data/lib/drawio_dsl/schema/shapes/process.rb +9 -0
  60. data/lib/drawio_dsl/schema/shapes/rectangle.rb +9 -0
  61. data/lib/drawio_dsl/schema/shapes/rectangle2.rb +9 -0
  62. data/lib/drawio_dsl/schema/shapes/shape.rb +123 -0
  63. data/lib/drawio_dsl/schema/shapes/square.rb +9 -0
  64. data/lib/drawio_dsl/schema/shapes/step.rb +9 -0
  65. data/lib/drawio_dsl/schema/shapes/tick.rb +9 -0
  66. data/lib/drawio_dsl/schema/shapes/triangle.rb +9 -0
  67. data/lib/drawio_dsl/version.rb +1 -1
  68. data/lib/drawio_dsl.rb +6 -1
  69. data/package-lock.json +2 -2
  70. data/package.json +1 -1
  71. metadata +59 -8
  72. data/lib/drawio_dsl/schema.rb +0 -617
@@ -2,120 +2,33 @@
2
2
 
3
3
  # Attach configuration to the DrawIO DSL module
4
4
  module DrawioDsl
5
- # Used to attach configuration to KConfig module
6
- module ConfigurationExtension
7
- def drawio
8
- return @drawio if defined? @drawio
9
-
10
- @drawio = DrawioDsl::Configuration.new
11
- end
12
- end
13
-
14
5
  # Configuration container for the DrawIO DSL
15
6
  class Configuration
7
+ include DrawioDsl::ConfigurationShapes
8
+ include DrawioDsl::ConfigurationThemes
9
+
16
10
  include KLog::Logging
17
11
 
18
12
  BaseStyle = Struct.new(:white_space, :html, :rounded, :shadow, :sketch, :glass, keyword_init: true)
19
13
 
20
- ShapeDefaults = Struct.new(:type, :x, :y, :w, :h, :style_modifiers)
21
- ShapeThemeStyle = Struct.new(:fill_color, :stroke_color, :font_color, :gradient, keyword_init: true)
22
-
23
14
  attr_accessor :base_style
24
15
 
25
- # Theme colors
26
- attr_accessor :themes
27
-
28
- # Shape shapes
29
- attr_accessor :shape
30
- attr_accessor :square
31
- attr_accessor :rectangle
32
- attr_accessor :circle
33
- attr_accessor :process
34
- attr_accessor :ellipse
35
- attr_accessor :diamond
36
- attr_accessor :hexagon
37
-
38
- # <mxCell id="6" value="" style="rhombus;whiteSpace=wrap;html=1;" vertex="1" parent="TqO-B">
39
- # <mxGeometry x="-496" y="115" width="80" height="80" as="geometry"/>
40
- # </mxCell>
16
+ attr_accessor :shapes
41
17
 
42
18
  def initialize
43
19
  @base_style = BaseStyle.new(white_space: :wrap, html: 1, rounded: nil, shadow: nil, sketch: nil, glass: nil)
44
20
 
45
- @shape = ShapeDefaults.new(:shape , 0, 0, 20, 20, '')
46
- @square = ShapeDefaults.new(:square , 0, 0, 160, 160, '')
47
- @rectangle = ShapeDefaults.new(:rectangle , 0, 0, 200, 120, '')
48
- @circle = ShapeDefaults.new(:circle , 0, 0, 160, 160, 'ellipse')
49
- @process = ShapeDefaults.new(:process , 0, 0, 200, 120, 'shape=process')
50
- @ellipse = ShapeDefaults.new(:ellipse , 0, 0, 200, 120, 'ellipse')
51
- @diamond = ShapeDefaults.new(:diamond , 0, 0, 160, 160, 'rhombus')
52
- @hexagon = ShapeDefaults.new(:hexagon , 0, 0, 200, 120, 'shape=hexagon')
53
-
54
- @themes = {}
21
+ add_shapes
55
22
  add_themes
56
23
  end
57
24
 
58
25
  def palette(theme)
59
- @themes[theme]
26
+ themes[theme]
60
27
  end
61
28
 
62
29
  def random_theme
63
- @themes.keys.sample
64
- end
65
-
66
- private
67
-
68
- def add_theme(name, **opts)
69
- @themes[name] = ShapeThemeStyle.new(**opts)
70
- end
71
-
72
- # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
73
- def add_themes
74
- add_theme(:style_01 , fill_color: '#f5f5f5', stroke_color: '#666666', font_color: '#333333')
75
- add_theme(:style_02 , fill_color: '#dae8fc', stroke_color: '#6c8ebf', font_color: '#333333')
76
- add_theme(:style_03 , fill_color: '#d5e8d4', stroke_color: '#82b366', font_color: '#333333')
77
- add_theme(:style_04 , fill_color: '#ffe6cc', stroke_color: '#d79b00', font_color: '#333333')
78
- add_theme(:style_05 , fill_color: '#fff2cc', stroke_color: '#d6b656', font_color: '#333333')
79
- add_theme(:style_06 , fill_color: '#f8cecc', stroke_color: '#b85450', font_color: '#333333')
80
- add_theme(:style_07 , fill_color: '#e1d5e7', stroke_color: '#9673a6', font_color: '#333333')
81
- add_theme(:style_08 , fill_color: '#60a917', stroke_color: '#2D7600', font_color: '#ffffff')
82
- add_theme(:style_09 , fill_color: '#008a00', stroke_color: '#005700', font_color: '#ffffff')
83
- add_theme(:style_10 , fill_color: '#1ba1e2', stroke_color: '#006EAF', font_color: '#ffffff')
84
- add_theme(:style_11 , fill_color: '#0050ef', stroke_color: '#001DBC', font_color: '#ffffff')
85
- add_theme(:style_12 , fill_color: '#6a00ff', stroke_color: '#3700CC', font_color: '#ffffff')
86
- add_theme(:style_13 , fill_color: '#aa00ff', stroke_color: '#7700CC', font_color: '#ffffff')
87
- add_theme(:style_14 , fill_color: '#d80073', stroke_color: '#A50040', font_color: '#ffffff')
88
- add_theme(:style_15 , fill_color: '#a20025', stroke_color: '#6F0000', font_color: '#ffffff')
89
- add_theme(:style_16 , fill_color: '#e51400', stroke_color: '#B20000', font_color: '#ffffff')
90
- add_theme(:style_17 , fill_color: '#fa6800', stroke_color: '#C73500', font_color: '#000000')
91
- add_theme(:style_18 , fill_color: '#f0a30a', stroke_color: '#BD7000', font_color: '#000000')
92
- add_theme(:style_19 , fill_color: '#e3c800', stroke_color: '#B09500', font_color: '#000000')
93
- add_theme(:style_20 , fill_color: '#6d8764', stroke_color: '#3A5431', font_color: '#ffffff')
94
- add_theme(:style_21 , fill_color: '#647687', stroke_color: '#314354', font_color: '#ffffff')
95
- add_theme(:style_22 , fill_color: '#76608a', stroke_color: '#432D57', font_color: '#ffffff')
96
- add_theme(:style_23 , fill_color: '#a0522d', stroke_color: '#6D1F00', font_color: '#ffffff')
97
- add_theme(:style_24 , fill_color: '#fad7ac', stroke_color: '#b46504', font_color: '#333333')
98
- add_theme(:style_25 , fill_color: '#fad9d5', stroke_color: '#ae4132', font_color: '#333333')
99
- add_theme(:style_26 , fill_color: '#b0e3e6', stroke_color: '#0e8088', font_color: '#000000')
100
- add_theme(:style_27 , fill_color: '#b1ddf0', stroke_color: '#10739e', font_color: '#000000')
101
- add_theme(:style_28 , fill_color: '#d0cee2', stroke_color: '#56517e', font_color: '#000000')
102
- add_theme(:style_29 , fill_color: '#bac8d3', stroke_color: '#23445d', font_color: '#000000')
103
- add_theme(:style_30 , fill_color: '#f5f5f5', stroke_color: '#666666', font_color: '#000000', gradient: '#b3b3b3')
104
- add_theme(:style_31 , fill_color: '#dae8fc', stroke_color: '#6c8ebf', font_color: '#000000', gradient: '#7ea6e0')
105
- add_theme(:style_32 , fill_color: '#d5e8d4', stroke_color: '#82b366', font_color: '#000000', gradient: '#97d077')
106
- add_theme(:style_33 , fill_color: '#ffcd28', stroke_color: '#d79b00', font_color: '#000000', gradient: '#ffa500')
107
- add_theme(:style_34 , fill_color: '#fff2cc', stroke_color: '#d6b656', font_color: '#000000', gradient: '#ffd966')
108
- add_theme(:style_35 , fill_color: '#f8cecc', stroke_color: '#b85450', font_color: '#000000', gradient: '#ea6b66')
109
- add_theme(:style_36 , fill_color: '#e6d0de', stroke_color: '#996185', font_color: '#000000', gradient: '#d5739d')
110
- add_theme(:style_37 , fill_color: '#eeeeee', stroke_color: '#36393d', font_color: '#000000')
111
- add_theme(:style_38 , fill_color: '#f9f7ed', stroke_color: '#36393d', font_color: '#000000')
112
- add_theme(:style_39 , fill_color: '#ffcc99', stroke_color: '#36393d', font_color: '#000000')
113
- add_theme(:style_40 , fill_color: '#cce5ff', stroke_color: '#36393d', font_color: '#000000')
114
- add_theme(:style_41 , fill_color: '#ffff88', stroke_color: '#36393d', font_color: '#000000')
115
- add_theme(:style_42 , fill_color: '#cdeb8b', stroke_color: '#36393d', font_color: '#000000')
116
- add_theme(:style_43 , fill_color: '#ffcccc', stroke_color: '#36393d', font_color: '#000000')
30
+ themes.keys.sample
117
31
  end
118
- # rubocop:enable Metrics/AbcSize, Metrics/MethodLength
119
32
  end
120
33
  end
121
34
 
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Attach configuration to the DrawIO DSL module
4
+ module DrawioDsl
5
+ # Used to attach configuration to KConfig module
6
+ module ConfigurationExtension
7
+ def drawio
8
+ return @drawio if defined? @drawio
9
+
10
+ @drawio = DrawioDsl::Configuration.new
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,75 @@
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, :x, :y, :w, :h, :style_modifiers, keyword_init: true)
9
+ Shapes = Struct.new(
10
+ :shape,
11
+ :actor,
12
+ :actor2,
13
+ :callout,
14
+ :callout2,
15
+ :callout3,
16
+ :callout4,
17
+ :circle,
18
+ :cloud,
19
+ :cross,
20
+ :envelop,
21
+ :diamond,
22
+ :document,
23
+ :ellipse,
24
+ :hexagon,
25
+ :container,
26
+ :container2,
27
+ :container3,
28
+ :container4,
29
+ :note,
30
+ :process,
31
+ :rectangle,
32
+ :rectangle2,
33
+ :square,
34
+ :step,
35
+ :tick,
36
+ :face,
37
+ :triangle,
38
+ keyword_init: true
39
+ )
40
+
41
+ def add_shapes
42
+ @shapes = Shapes.new(
43
+ shape: ShapeDefaults.new(type: :shape, x: 0, y: 0, w: 20, h: 20, style_modifiers: ''),
44
+ actor: ShapeDefaults.new(type: :actor, x: 0, y: 0, w: 40, h: 50, style_modifiers: 'shape=actor'),
45
+ actor2: ShapeDefaults.new(type: :actor2, x: 0, y: 0, w: 30, h: 50, style_modifiers: 'shape=umlActor;verticalLabelPosition=bottom;outlineConnect=1'),
46
+ callout: ShapeDefaults.new(type: :callout, x: 0, y: 0, w: 160, h: 120, style_modifiers: 'shape=callout'),
47
+ callout2: ShapeDefaults.new(type: :callout2, x: 0, y: 0, w: 160, h: 160, style_modifiers: 'shape=mxgraph.basic.oval_callout'),
48
+ callout3: ShapeDefaults.new(type: :callout3, x: 0, y: 0, w: 160, h: 160, style_modifiers: 'shape=mxgraph.basic.cloud_callout'),
49
+ callout4: ShapeDefaults.new(type: :callout4, x: 0, y: 0, w: 160, h: 120, style_modifiers: 'shape=mxgraph.basic.roundRectCallout;dx=30;dy=15;size=5;boundedLbl=1;'),
50
+ circle: ShapeDefaults.new(type: :circle, x: 0, y: 0, w: 160, h: 160, style_modifiers: 'ellipse'),
51
+ cloud: ShapeDefaults.new(type: :cloud, x: 0, y: 0, w: 160, h: 160, style_modifiers: 'shape=cloud'),
52
+ cross: ShapeDefaults.new(type: :cross, x: 0, y: 0, w: 50, h: 50, style_modifiers: 'verticalLabelPosition=bottom;verticalAlign=top;html=1;shape=mxgraph.basic.x'),
53
+ envelop: ShapeDefaults.new(type: :envelop, x: 0, y: 0, w: 160, h: 100, style_modifiers: 'shape=message'),
54
+ diamond: ShapeDefaults.new(type: :diamond, x: 0, y: 0, w: 100, h: 100, style_modifiers: 'rhombus'),
55
+ document: ShapeDefaults.new(type: :document, x: 0, y: 0, w: 160, h: 160, style_modifiers: 'shape=mxgraph.basic.document'),
56
+ ellipse: ShapeDefaults.new(type: :ellipse, x: 0, y: 0, w: 200, h: 120, style_modifiers: 'ellipse'),
57
+ hexagon: ShapeDefaults.new(type: :hexagon, x: 0, y: 0, w: 200, h: 120, style_modifiers: 'shape=hexagon'),
58
+ container: ShapeDefaults.new(type: :container, x: 0, y: 0, w: 160, h: 160, style_modifiers: 'swimlane;horizontal=0'),
59
+ container2: ShapeDefaults.new(type: :container2, x: 0, y: 0, w: 160, h: 160, style_modifiers: 'swimlane'),
60
+ container3: ShapeDefaults.new(type: :container3, x: 0, y: 0, w: 160, h: 160, style_modifiers: 'swimlane;startSize=50'),
61
+ container4: ShapeDefaults.new(type: :container4, x: 0, y: 0, w: 160, h: 160, style_modifiers: 'swimlane;resizable=0'),
62
+ note: ShapeDefaults.new(type: :note, x: 0, y: 0, w: 160, h: 160, style_modifiers: 'shape=note'),
63
+ process: ShapeDefaults.new(type: :process, x: 0, y: 0, w: 200, h: 120, style_modifiers: 'shape=process'),
64
+ rectangle: ShapeDefaults.new(type: :rectangle, x: 0, y: 0, w: 200, h: 120, style_modifiers: ''),
65
+ rectangle2: ShapeDefaults.new(type: :rectangle2, x: 0, y: 0, w: 200, h: 120, style_modifiers: 'shape=mxgraph.basic.cloud_rect'),
66
+ square: ShapeDefaults.new(type: :square, x: 0, y: 0, w: 160, h: 160, style_modifiers: ''),
67
+ step: ShapeDefaults.new(type: :step, x: 0, y: 0, w: 120, h: 80, style_modifiers: 'shape=step;perimeter=stepPerimeter;fixedSize=1'),
68
+ tick: ShapeDefaults.new(type: :tick, x: 0, y: 0, w: 50, h: 50, style_modifiers: 'verticalLabelPosition=bottom;verticalAlign=top;shape=mxgraph.basic.tick'),
69
+ face: ShapeDefaults.new(type: :face, x: 0, y: 0, w: 100, h: 100, style_modifiers: 'verticalLabelPosition=bottom;verticalAlign=top;shape=mxgraph.basic.smiley'),
70
+ triangle: ShapeDefaults.new(type: :triangle, x: 0, y: 0, w: 100, h: 100, style_modifiers: 'triangle')
71
+ )
72
+ end
73
+ end
74
+ end
75
+ # :nocov:
@@ -0,0 +1,63 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Attach configuration to the DrawIO DSL module
4
+ module DrawioDsl
5
+ # Configuration for each theme
6
+ module ConfigurationThemes
7
+ ShapeThemeStyle = Struct.new(:fill_color, :stroke_color, :font_color, :gradient, keyword_init: true)
8
+
9
+ attr_accessor :themes
10
+
11
+ def add_theme(name, **opts)
12
+ @themes[name] = ShapeThemeStyle.new(**opts)
13
+ end
14
+
15
+ def add_themes
16
+ @themes = {}
17
+
18
+ add_theme(:style_01 , fill_color: '#f5f5f5', stroke_color: '#666666', font_color: '#333333')
19
+ add_theme(:style_02 , fill_color: '#dae8fc', stroke_color: '#6c8ebf', font_color: '#333333')
20
+ add_theme(:style_03 , fill_color: '#d5e8d4', stroke_color: '#82b366', font_color: '#333333')
21
+ add_theme(:style_04 , fill_color: '#ffe6cc', stroke_color: '#d79b00', font_color: '#333333')
22
+ add_theme(:style_05 , fill_color: '#fff2cc', stroke_color: '#d6b656', font_color: '#333333')
23
+ add_theme(:style_06 , fill_color: '#f8cecc', stroke_color: '#b85450', font_color: '#333333')
24
+ add_theme(:style_07 , fill_color: '#e1d5e7', stroke_color: '#9673a6', font_color: '#333333')
25
+ add_theme(:style_08 , fill_color: '#60a917', stroke_color: '#2D7600', font_color: '#ffffff')
26
+ add_theme(:style_09 , fill_color: '#008a00', stroke_color: '#005700', font_color: '#ffffff')
27
+ add_theme(:style_10 , fill_color: '#1ba1e2', stroke_color: '#006EAF', font_color: '#ffffff')
28
+ add_theme(:style_11 , fill_color: '#0050ef', stroke_color: '#001DBC', font_color: '#ffffff')
29
+ add_theme(:style_12 , fill_color: '#6a00ff', stroke_color: '#3700CC', font_color: '#ffffff')
30
+ add_theme(:style_13 , fill_color: '#aa00ff', stroke_color: '#7700CC', font_color: '#ffffff')
31
+ add_theme(:style_14 , fill_color: '#d80073', stroke_color: '#A50040', font_color: '#ffffff')
32
+ add_theme(:style_15 , fill_color: '#a20025', stroke_color: '#6F0000', font_color: '#ffffff')
33
+ add_theme(:style_16 , fill_color: '#e51400', stroke_color: '#B20000', font_color: '#ffffff')
34
+ add_theme(:style_17 , fill_color: '#fa6800', stroke_color: '#C73500', font_color: '#000000')
35
+ add_theme(:style_18 , fill_color: '#f0a30a', stroke_color: '#BD7000', font_color: '#000000')
36
+ add_theme(:style_19 , fill_color: '#e3c800', stroke_color: '#B09500', font_color: '#000000')
37
+ add_theme(:style_20 , fill_color: '#6d8764', stroke_color: '#3A5431', font_color: '#ffffff')
38
+ add_theme(:style_21 , fill_color: '#647687', stroke_color: '#314354', font_color: '#ffffff')
39
+ add_theme(:style_22 , fill_color: '#76608a', stroke_color: '#432D57', font_color: '#ffffff')
40
+ add_theme(:style_23 , fill_color: '#a0522d', stroke_color: '#6D1F00', font_color: '#ffffff')
41
+ add_theme(:style_24 , fill_color: '#fad7ac', stroke_color: '#b46504', font_color: '#333333')
42
+ add_theme(:style_25 , fill_color: '#fad9d5', stroke_color: '#ae4132', font_color: '#333333')
43
+ add_theme(:style_26 , fill_color: '#b0e3e6', stroke_color: '#0e8088', font_color: '#000000')
44
+ add_theme(:style_27 , fill_color: '#b1ddf0', stroke_color: '#10739e', font_color: '#000000')
45
+ add_theme(:style_28 , fill_color: '#d0cee2', stroke_color: '#56517e', font_color: '#000000')
46
+ add_theme(:style_29 , fill_color: '#bac8d3', stroke_color: '#23445d', font_color: '#000000')
47
+ add_theme(:style_30 , fill_color: '#f5f5f5', stroke_color: '#666666', font_color: '#000000', gradient: '#b3b3b3')
48
+ add_theme(:style_31 , fill_color: '#dae8fc', stroke_color: '#6c8ebf', font_color: '#000000', gradient: '#7ea6e0')
49
+ add_theme(:style_32 , fill_color: '#d5e8d4', stroke_color: '#82b366', font_color: '#000000', gradient: '#97d077')
50
+ add_theme(:style_33 , fill_color: '#ffcd28', stroke_color: '#d79b00', font_color: '#000000', gradient: '#ffa500')
51
+ add_theme(:style_34 , fill_color: '#fff2cc', stroke_color: '#d6b656', font_color: '#000000', gradient: '#ffd966')
52
+ add_theme(:style_35 , fill_color: '#f8cecc', stroke_color: '#b85450', font_color: '#000000', gradient: '#ea6b66')
53
+ add_theme(:style_36 , fill_color: '#e6d0de', stroke_color: '#996185', font_color: '#000000', gradient: '#d5739d')
54
+ add_theme(:style_37 , fill_color: '#eeeeee', stroke_color: '#36393d', font_color: '#000000')
55
+ add_theme(:style_38 , fill_color: '#f9f7ed', stroke_color: '#36393d', font_color: '#000000')
56
+ add_theme(:style_39 , fill_color: '#ffcc99', stroke_color: '#36393d', font_color: '#000000')
57
+ add_theme(:style_40 , fill_color: '#cce5ff', stroke_color: '#36393d', font_color: '#000000')
58
+ add_theme(:style_41 , fill_color: '#ffff88', stroke_color: '#36393d', font_color: '#000000')
59
+ add_theme(:style_42 , fill_color: '#cdeb8b', stroke_color: '#36393d', font_color: '#000000')
60
+ add_theme(:style_43 , fill_color: '#ffcccc', stroke_color: '#36393d', font_color: '#000000')
61
+ end
62
+ end
63
+ end
@@ -3,6 +3,8 @@
3
3
  module DrawioDsl
4
4
  # DrawioDsl is a DSL for draw-io diagrams.
5
5
  class DomBuilder
6
+ include DomBuilderShapes
7
+
6
8
  attr_reader :actions
7
9
  attr_reader :last_action
8
10
 
@@ -84,45 +86,12 @@ module DrawioDsl
84
86
  shape
85
87
  end
86
88
 
87
- def add_square(**opts)
88
- square = DrawioDsl::Schema::Square.new(current_page, **opts)
89
- add_shape(square)
90
- end
91
-
92
- def add_rectangle(**opts)
93
- rectangle = DrawioDsl::Schema::Rectangle.new(current_page, **opts)
94
- add_shape(rectangle)
95
- end
96
-
97
- def add_circle(**opts)
98
- circle = DrawioDsl::Schema::Circle.new(current_page, **opts)
99
- add_shape(circle)
100
- end
101
-
102
- def add_process(**opts)
103
- process = DrawioDsl::Schema::Process.new(current_page, **opts)
104
- add_shape(process)
105
- end
106
-
107
- def add_ellipse(**opts)
108
- ellipse = DrawioDsl::Schema::Ellipse.new(current_page, **opts)
109
- add_shape(ellipse)
110
- end
111
-
112
- def add_diamond(**opts)
113
- diamond = DrawioDsl::Schema::Diamond.new(current_page, **opts)
114
- add_shape(diamond)
115
- end
116
-
117
- def add_hexagon(**opts)
118
- add_hexagon = DrawioDsl::Schema::Hexagon.new(current_page, **opts)
119
- add_shape(add_hexagon)
120
- end
121
-
89
+ # :nocov:
122
90
  def debug
123
91
  puts JSON.pretty_generate(actions)
124
92
  puts JSON.pretty_generate(diagram.to_h)
125
93
  end
94
+ # :nocov:
126
95
 
127
96
  def dom
128
97
  diagram.to_h
@@ -0,0 +1,143 @@
1
+ # frozen_string_literal: true
2
+
3
+ # :nocov:
4
+ module DrawioDsl
5
+ # DrawioDsl is a DSL for draw-io diagrams.
6
+ module DomBuilderShapes
7
+ def add_actor(**opts)
8
+ actor = DrawioDsl::Schema::Actor.new(current_page, **opts)
9
+ add_shape(actor)
10
+ end
11
+
12
+ def add_actor2(**opts)
13
+ actor2 = DrawioDsl::Schema::Actor2.new(current_page, **opts)
14
+ add_shape(actor2)
15
+ end
16
+
17
+ def add_callout(**opts)
18
+ callout = DrawioDsl::Schema::Callout.new(current_page, **opts)
19
+ add_shape(callout)
20
+ end
21
+
22
+ def add_callout2(**opts)
23
+ callout2 = DrawioDsl::Schema::Callout2.new(current_page, **opts)
24
+ add_shape(callout2)
25
+ end
26
+
27
+ def add_callout3(**opts)
28
+ callout3 = DrawioDsl::Schema::Callout3.new(current_page, **opts)
29
+ add_shape(callout3)
30
+ end
31
+
32
+ def add_callout4(**opts)
33
+ callout4 = DrawioDsl::Schema::Callout4.new(current_page, **opts)
34
+ add_shape(callout4)
35
+ end
36
+
37
+ def add_circle(**opts)
38
+ circle = DrawioDsl::Schema::Circle.new(current_page, **opts)
39
+ add_shape(circle)
40
+ end
41
+
42
+ def add_cloud(**opts)
43
+ cloud = DrawioDsl::Schema::Cloud.new(current_page, **opts)
44
+ add_shape(cloud)
45
+ end
46
+
47
+ def add_cross(**opts)
48
+ cross = DrawioDsl::Schema::Cross.new(current_page, **opts)
49
+ add_shape(cross)
50
+ end
51
+
52
+ def add_envelop(**opts)
53
+ envelop = DrawioDsl::Schema::Envelop.new(current_page, **opts)
54
+ add_shape(envelop)
55
+ end
56
+
57
+ def add_diamond(**opts)
58
+ diamond = DrawioDsl::Schema::Diamond.new(current_page, **opts)
59
+ add_shape(diamond)
60
+ end
61
+
62
+ def add_document(**opts)
63
+ document = DrawioDsl::Schema::Document.new(current_page, **opts)
64
+ add_shape(document)
65
+ end
66
+
67
+ def add_ellipse(**opts)
68
+ ellipse = DrawioDsl::Schema::Ellipse.new(current_page, **opts)
69
+ add_shape(ellipse)
70
+ end
71
+
72
+ def add_hexagon(**opts)
73
+ hexagon = DrawioDsl::Schema::Hexagon.new(current_page, **opts)
74
+ add_shape(hexagon)
75
+ end
76
+
77
+ def add_container(**opts)
78
+ container = DrawioDsl::Schema::Container.new(current_page, **opts)
79
+ add_shape(container)
80
+ end
81
+
82
+ def add_container2(**opts)
83
+ container2 = DrawioDsl::Schema::Container2.new(current_page, **opts)
84
+ add_shape(container2)
85
+ end
86
+
87
+ def add_container3(**opts)
88
+ container3 = DrawioDsl::Schema::Container3.new(current_page, **opts)
89
+ add_shape(container3)
90
+ end
91
+
92
+ def add_container4(**opts)
93
+ container4 = DrawioDsl::Schema::Container4.new(current_page, **opts)
94
+ add_shape(container4)
95
+ end
96
+
97
+ def add_note(**opts)
98
+ note = DrawioDsl::Schema::Note.new(current_page, **opts)
99
+ add_shape(note)
100
+ end
101
+
102
+ def add_process(**opts)
103
+ process = DrawioDsl::Schema::Process.new(current_page, **opts)
104
+ add_shape(process)
105
+ end
106
+
107
+ def add_rectangle(**opts)
108
+ rectangle = DrawioDsl::Schema::Rectangle.new(current_page, **opts)
109
+ add_shape(rectangle)
110
+ end
111
+
112
+ def add_rectangle2(**opts)
113
+ rectangle2 = DrawioDsl::Schema::Rectangle2.new(current_page, **opts)
114
+ add_shape(rectangle2)
115
+ end
116
+
117
+ def add_square(**opts)
118
+ square = DrawioDsl::Schema::Square.new(current_page, **opts)
119
+ add_shape(square)
120
+ end
121
+
122
+ def add_step(**opts)
123
+ step = DrawioDsl::Schema::Step.new(current_page, **opts)
124
+ add_shape(step)
125
+ end
126
+
127
+ def add_tick(**opts)
128
+ tick = DrawioDsl::Schema::Tick.new(current_page, **opts)
129
+ add_shape(tick)
130
+ end
131
+
132
+ def add_face(**opts)
133
+ face = DrawioDsl::Schema::Face.new(current_page, **opts)
134
+ add_shape(face)
135
+ end
136
+
137
+ def add_triangle(**opts)
138
+ triangle = DrawioDsl::Schema::Triangle.new(current_page, **opts)
139
+ add_shape(triangle)
140
+ end
141
+ end
142
+ end
143
+ # :nocov:
@@ -19,35 +19,18 @@ module DrawioDsl
19
19
  layout.call
20
20
  self
21
21
  end
22
-
23
- def apply_layout
24
- engine = DrawioDsl::LayoutEngine.new(builder.diagram)
25
- engine.call
26
-
27
- self
28
- end
29
22
  end
30
23
 
31
24
  # DrawioDsl::DrawioPage is created when you call .page on the draw-io DSL.
32
25
  class DrawioPage < KDirector::Directors::ChildDirector
33
- attr_reader :auto_layout
34
- attr_reader :current_x
35
- attr_reader :current_y
26
+ include DrawioDsl::DrawioShapes
36
27
 
37
28
  def initialize(parent, **opts)
38
29
  super(parent, **opts)
39
30
 
40
- @auto_layout = true
41
- @current_x = 20
42
- @current_y = 20
43
-
44
31
  builder.add_page(**opts)
45
32
  end
46
33
 
47
- def layout_rule(**opts)
48
- builder.add_layout_rule(**opts)
49
- end
50
-
51
34
  def grid_layout(**opts)
52
35
  builder.add_grid_layout(**opts)
53
36
  end
@@ -55,60 +38,5 @@ module DrawioDsl
55
38
  def flex_layout(**opts)
56
39
  builder.add_flex_layout(**opts)
57
40
  end
58
-
59
- # rubocop:disable Metrics/CyclomaticComplexity
60
- def random(**opts)
61
- case rand(7)
62
- when 0
63
- square(**opts)
64
- when 1
65
- rectangle(**opts)
66
- when 2
67
- circle(**opts)
68
- when 3
69
- process(**opts)
70
- when 4
71
- ellipse(**opts)
72
- when 5
73
- diamond(**opts)
74
- when 6
75
- hexagon(**opts)
76
- end
77
- end
78
- # rubocop:enable Metrics/CyclomaticComplexity
79
-
80
- def square(**opts)
81
- builder.add_square(**opts)
82
- end
83
-
84
- def rectangle(**opts)
85
- builder.add_rectangle(**opts)
86
- end
87
-
88
- def circle(**opts)
89
- builder.add_circle(**opts)
90
- end
91
-
92
- def process(**opts)
93
- builder.add_process(**opts)
94
- end
95
-
96
- def ellipse(**opts)
97
- builder.add_ellipse(**opts)
98
- end
99
-
100
- def diamond(**opts)
101
- builder.add_diamond(**opts)
102
- end
103
-
104
- def hexagon(**opts)
105
- builder.add_hexagon(**opts)
106
- end
107
-
108
- private
109
-
110
- def current_shape
111
- builder.current_shape
112
- end
113
41
  end
114
42
  end