drawio_dsl 0.4.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.builders/.data/shapes.json +242 -0
- data/.builders/.templates/basic/configuration_shapes.rb +27 -0
- data/.builders/.templates/basic/dom_builder_shapes.rb +16 -0
- data/.builders/.templates/basic/drawio_shapes.rb +23 -0
- data/.builders/.templates/basic/schema_require.rb +16 -0
- data/.builders/.templates/basic/schema_shape.rb +9 -0
- data/.builders/.templates/basic/schema_shape_spec.rb +13 -0
- data/.builders/blueprint/shapes.rb +47 -12
- data/.builders/boot.rb +5 -0
- data/.builders/generators/02-generate-app.rb +43 -0
- data/.builders/generators/{10-page-margin.rb → sample_diagrams/10-page-margin.rb} +0 -0
- data/.builders/generators/{15-grid-direction.rb → sample_diagrams/15-grid-direction.rb} +0 -0
- data/.builders/generators/{16-grid-alignment.rb → sample_diagrams/16-grid-alignment.rb} +0 -0
- data/.builders/generators/{20-styles.rb → sample_diagrams/20-styles.rb} +0 -0
- data/.builders/generators/{25-themes.rb → sample_diagrams/25-themes.rb} +2 -2
- data/.builders/generators/sample_diagrams/30-shapes.rb +23 -0
- data/.rubocop.yml +22 -3
- data/CHANGELOG.md +23 -0
- data/README.md +4 -0
- data/lib/drawio_dsl/configuration.rb +5 -101
- data/lib/drawio_dsl/configuration_extension.rb +13 -0
- data/lib/drawio_dsl/configuration_shapes.rb +83 -0
- data/lib/drawio_dsl/configuration_themes.rb +63 -0
- data/lib/drawio_dsl/dom_builder.rb +9 -55
- data/lib/drawio_dsl/dom_builder_shapes.rb +158 -0
- data/lib/drawio_dsl/drawio.rb +1 -91
- data/lib/drawio_dsl/drawio_shapes.rb +193 -0
- data/lib/drawio_dsl/layout_engine.rb +1 -8
- data/lib/drawio_dsl/schema/_.rb +21 -0
- data/lib/drawio_dsl/schema/node_list.rb +37 -0
- data/lib/drawio_dsl/schema/page.rb +5 -5
- data/{.builders/.templates/schema_shape.rb → lib/drawio_dsl/schema/shapes/actor.rb} +2 -2
- data/lib/drawio_dsl/schema/shapes/actor2.rb +9 -0
- data/lib/drawio_dsl/schema/shapes/callout2.rb +9 -0
- data/lib/drawio_dsl/schema/shapes/callout3.rb +9 -0
- data/lib/drawio_dsl/schema/shapes/callout4.rb +9 -0
- data/lib/drawio_dsl/schema/shapes/container.rb +9 -0
- data/lib/drawio_dsl/schema/shapes/container2.rb +9 -0
- data/lib/drawio_dsl/schema/shapes/container3.rb +9 -0
- data/lib/drawio_dsl/schema/shapes/container4.rb +9 -0
- data/lib/drawio_dsl/schema/shapes/cross.rb +9 -0
- data/lib/drawio_dsl/schema/shapes/document.rb +9 -0
- data/lib/drawio_dsl/schema/shapes/embed_col200.rb +9 -0
- data/lib/drawio_dsl/schema/shapes/embed_col50.rb +9 -0
- data/lib/drawio_dsl/schema/shapes/embed_row.rb +9 -0
- data/lib/drawio_dsl/schema/shapes/envelop.rb +9 -0
- data/lib/drawio_dsl/schema/shapes/face.rb +9 -0
- data/lib/drawio_dsl/schema/shapes/rectangle2.rb +9 -0
- data/lib/drawio_dsl/schema/shapes/shape.rb +10 -6
- data/lib/drawio_dsl/schema/shapes/step.rb +9 -0
- data/lib/drawio_dsl/schema/shapes/tick.rb +9 -0
- data/lib/drawio_dsl/schema/shapes/triangle.rb +9 -0
- data/lib/drawio_dsl/version.rb +1 -1
- data/lib/drawio_dsl/xml_builder.rb +2 -12
- data/lib/drawio_dsl.rb +5 -0
- data/package-lock.json +2 -2
- data/package.json +1 -1
- metadata +42 -9
- data/.builders/.templates/command.rb +0 -8
@@ -2,41 +2,17 @@
|
|
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
|
-
ShapeDefaults = Struct.new(:type, :x, :y, :w, :h, :style_modifiers, keyword_init: true)
|
20
|
-
ShapeThemeStyle = Struct.new(:fill_color, :stroke_color, :font_color, :gradient, keyword_init: true)
|
21
|
-
|
22
|
-
Shapes = Struct.new(
|
23
|
-
:shape,
|
24
|
-
:square,
|
25
|
-
:rectangle,
|
26
|
-
:circle,
|
27
|
-
:process,
|
28
|
-
:ellipse,
|
29
|
-
:diamond,
|
30
|
-
:hexagon,
|
31
|
-
:cloud,
|
32
|
-
:note,
|
33
|
-
:callout,
|
34
|
-
keyword_init: true
|
35
|
-
)
|
36
13
|
|
37
14
|
attr_accessor :base_style
|
38
15
|
|
39
|
-
attr_accessor :themes
|
40
16
|
attr_accessor :shapes
|
41
17
|
|
42
18
|
def initialize
|
@@ -47,84 +23,12 @@ module DrawioDsl
|
|
47
23
|
end
|
48
24
|
|
49
25
|
def palette(theme)
|
50
|
-
|
26
|
+
themes[theme]
|
51
27
|
end
|
52
28
|
|
53
29
|
def random_theme
|
54
|
-
|
55
|
-
end
|
56
|
-
|
57
|
-
private
|
58
|
-
|
59
|
-
def add_shapes
|
60
|
-
@shapes = Shapes.new(
|
61
|
-
shape: ShapeDefaults.new(type: :shape , x: 0, y: 0, w: 20, h: 20, style_modifiers: ''),
|
62
|
-
square: ShapeDefaults.new(type: :square , x: 0, y: 0, w: 160, h: 160, style_modifiers: ''),
|
63
|
-
rectangle: ShapeDefaults.new(type: :rectangle , x: 0, y: 0, w: 200, h: 120, style_modifiers: ''),
|
64
|
-
circle: ShapeDefaults.new(type: :circle , x: 0, y: 0, w: 160, h: 160, style_modifiers: 'double=1;ellipse'),
|
65
|
-
process: ShapeDefaults.new(type: :process , x: 0, y: 0, w: 200, h: 120, style_modifiers: 'double=1;shape=process'),
|
66
|
-
ellipse: ShapeDefaults.new(type: :ellipse , x: 0, y: 0, w: 200, h: 120, style_modifiers: 'double=1;ellipse'),
|
67
|
-
diamond: ShapeDefaults.new(type: :diamond , x: 0, y: 0, w: 160, h: 160, style_modifiers: 'double=1;rhombus'),
|
68
|
-
hexagon: ShapeDefaults.new(type: :hexagon , x: 0, y: 0, w: 200, h: 120, style_modifiers: 'double=1;shape=hexagon'),
|
69
|
-
cloud: ShapeDefaults.new(type: :cloud , x: 0, y: 0, w: 160, h: 160, style_modifiers: 'double=1;shape=cloud'),
|
70
|
-
note: ShapeDefaults.new(type: :note , x: 0, y: 0, w: 160, h: 160, style_modifiers: 'double=1;shape=note'),
|
71
|
-
callout: ShapeDefaults.new(type: :callout , x: 0, y: 0, w: 160, h: 160, style_modifiers: 'double=1;shape=callout')
|
72
|
-
)
|
73
|
-
end
|
74
|
-
|
75
|
-
def add_theme(name, **opts)
|
76
|
-
@themes[name] = ShapeThemeStyle.new(**opts)
|
77
|
-
end
|
78
|
-
|
79
|
-
# rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
80
|
-
def add_themes
|
81
|
-
@themes = {}
|
82
|
-
|
83
|
-
add_theme(:style_01 , fill_color: '#f5f5f5', stroke_color: '#666666', font_color: '#333333')
|
84
|
-
add_theme(:style_02 , fill_color: '#dae8fc', stroke_color: '#6c8ebf', font_color: '#333333')
|
85
|
-
add_theme(:style_03 , fill_color: '#d5e8d4', stroke_color: '#82b366', font_color: '#333333')
|
86
|
-
add_theme(:style_04 , fill_color: '#ffe6cc', stroke_color: '#d79b00', font_color: '#333333')
|
87
|
-
add_theme(:style_05 , fill_color: '#fff2cc', stroke_color: '#d6b656', font_color: '#333333')
|
88
|
-
add_theme(:style_06 , fill_color: '#f8cecc', stroke_color: '#b85450', font_color: '#333333')
|
89
|
-
add_theme(:style_07 , fill_color: '#e1d5e7', stroke_color: '#9673a6', font_color: '#333333')
|
90
|
-
add_theme(:style_08 , fill_color: '#60a917', stroke_color: '#2D7600', font_color: '#ffffff')
|
91
|
-
add_theme(:style_09 , fill_color: '#008a00', stroke_color: '#005700', font_color: '#ffffff')
|
92
|
-
add_theme(:style_10 , fill_color: '#1ba1e2', stroke_color: '#006EAF', font_color: '#ffffff')
|
93
|
-
add_theme(:style_11 , fill_color: '#0050ef', stroke_color: '#001DBC', font_color: '#ffffff')
|
94
|
-
add_theme(:style_12 , fill_color: '#6a00ff', stroke_color: '#3700CC', font_color: '#ffffff')
|
95
|
-
add_theme(:style_13 , fill_color: '#aa00ff', stroke_color: '#7700CC', font_color: '#ffffff')
|
96
|
-
add_theme(:style_14 , fill_color: '#d80073', stroke_color: '#A50040', font_color: '#ffffff')
|
97
|
-
add_theme(:style_15 , fill_color: '#a20025', stroke_color: '#6F0000', font_color: '#ffffff')
|
98
|
-
add_theme(:style_16 , fill_color: '#e51400', stroke_color: '#B20000', font_color: '#ffffff')
|
99
|
-
add_theme(:style_17 , fill_color: '#fa6800', stroke_color: '#C73500', font_color: '#000000')
|
100
|
-
add_theme(:style_18 , fill_color: '#f0a30a', stroke_color: '#BD7000', font_color: '#000000')
|
101
|
-
add_theme(:style_19 , fill_color: '#e3c800', stroke_color: '#B09500', font_color: '#000000')
|
102
|
-
add_theme(:style_20 , fill_color: '#6d8764', stroke_color: '#3A5431', font_color: '#ffffff')
|
103
|
-
add_theme(:style_21 , fill_color: '#647687', stroke_color: '#314354', font_color: '#ffffff')
|
104
|
-
add_theme(:style_22 , fill_color: '#76608a', stroke_color: '#432D57', font_color: '#ffffff')
|
105
|
-
add_theme(:style_23 , fill_color: '#a0522d', stroke_color: '#6D1F00', font_color: '#ffffff')
|
106
|
-
add_theme(:style_24 , fill_color: '#fad7ac', stroke_color: '#b46504', font_color: '#333333')
|
107
|
-
add_theme(:style_25 , fill_color: '#fad9d5', stroke_color: '#ae4132', font_color: '#333333')
|
108
|
-
add_theme(:style_26 , fill_color: '#b0e3e6', stroke_color: '#0e8088', font_color: '#000000')
|
109
|
-
add_theme(:style_27 , fill_color: '#b1ddf0', stroke_color: '#10739e', font_color: '#000000')
|
110
|
-
add_theme(:style_28 , fill_color: '#d0cee2', stroke_color: '#56517e', font_color: '#000000')
|
111
|
-
add_theme(:style_29 , fill_color: '#bac8d3', stroke_color: '#23445d', font_color: '#000000')
|
112
|
-
add_theme(:style_30 , fill_color: '#f5f5f5', stroke_color: '#666666', font_color: '#000000', gradient: '#b3b3b3')
|
113
|
-
add_theme(:style_31 , fill_color: '#dae8fc', stroke_color: '#6c8ebf', font_color: '#000000', gradient: '#7ea6e0')
|
114
|
-
add_theme(:style_32 , fill_color: '#d5e8d4', stroke_color: '#82b366', font_color: '#000000', gradient: '#97d077')
|
115
|
-
add_theme(:style_33 , fill_color: '#ffcd28', stroke_color: '#d79b00', font_color: '#000000', gradient: '#ffa500')
|
116
|
-
add_theme(:style_34 , fill_color: '#fff2cc', stroke_color: '#d6b656', font_color: '#000000', gradient: '#ffd966')
|
117
|
-
add_theme(:style_35 , fill_color: '#f8cecc', stroke_color: '#b85450', font_color: '#000000', gradient: '#ea6b66')
|
118
|
-
add_theme(:style_36 , fill_color: '#e6d0de', stroke_color: '#996185', font_color: '#000000', gradient: '#d5739d')
|
119
|
-
add_theme(:style_37 , fill_color: '#eeeeee', stroke_color: '#36393d', font_color: '#000000')
|
120
|
-
add_theme(:style_38 , fill_color: '#f9f7ed', stroke_color: '#36393d', font_color: '#000000')
|
121
|
-
add_theme(:style_39 , fill_color: '#ffcc99', stroke_color: '#36393d', font_color: '#000000')
|
122
|
-
add_theme(:style_40 , fill_color: '#cce5ff', stroke_color: '#36393d', font_color: '#000000')
|
123
|
-
add_theme(:style_41 , fill_color: '#ffff88', stroke_color: '#36393d', font_color: '#000000')
|
124
|
-
add_theme(:style_42 , fill_color: '#cdeb8b', stroke_color: '#36393d', font_color: '#000000')
|
125
|
-
add_theme(:style_43 , fill_color: '#ffcccc', stroke_color: '#36393d', font_color: '#000000')
|
30
|
+
themes.keys.sample
|
126
31
|
end
|
127
|
-
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength
|
128
32
|
end
|
129
33
|
end
|
130
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,83 @@
|
|
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
|
+
:embed_row,
|
39
|
+
:embed_col50,
|
40
|
+
:embed_col200,
|
41
|
+
keyword_init: true
|
42
|
+
)
|
43
|
+
|
44
|
+
def add_shapes
|
45
|
+
@shapes = Shapes.new(
|
46
|
+
shape: ShapeDefaults.new(type: :shape, x: 0, y: 0, w: 20, h: 20, style_modifiers: ''),
|
47
|
+
actor: ShapeDefaults.new(type: :actor, x: 0, y: 0, w: 40, h: 50, style_modifiers: 'shape=actor'),
|
48
|
+
actor2: ShapeDefaults.new(type: :actor2, x: 0, y: 0, w: 30, h: 50, style_modifiers: 'shape=umlActor;verticalLabelPosition=bottom;outlineConnect=1'),
|
49
|
+
callout: ShapeDefaults.new(type: :callout, x: 0, y: 0, w: 160, h: 120, style_modifiers: 'shape=callout'),
|
50
|
+
callout2: ShapeDefaults.new(type: :callout2, x: 0, y: 0, w: 160, h: 160, style_modifiers: 'shape=mxgraph.basic.oval_callout'),
|
51
|
+
callout3: ShapeDefaults.new(type: :callout3, x: 0, y: 0, w: 160, h: 160, style_modifiers: 'shape=mxgraph.basic.cloud_callout'),
|
52
|
+
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;'),
|
53
|
+
circle: ShapeDefaults.new(type: :circle, x: 0, y: 0, w: 160, h: 160, style_modifiers: 'ellipse'),
|
54
|
+
cloud: ShapeDefaults.new(type: :cloud, x: 0, y: 0, w: 160, h: 160, style_modifiers: 'shape=cloud'),
|
55
|
+
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'),
|
56
|
+
envelop: ShapeDefaults.new(type: :envelop, x: 0, y: 0, w: 160, h: 100, style_modifiers: 'shape=message'),
|
57
|
+
diamond: ShapeDefaults.new(type: :diamond, x: 0, y: 0, w: 100, h: 100, style_modifiers: 'rhombus'),
|
58
|
+
document: ShapeDefaults.new(type: :document, x: 0, y: 0, w: 160, h: 160, style_modifiers: 'shape=mxgraph.basic.document'),
|
59
|
+
ellipse: ShapeDefaults.new(type: :ellipse, x: 0, y: 0, w: 200, h: 120, style_modifiers: 'ellipse'),
|
60
|
+
hexagon: ShapeDefaults.new(type: :hexagon, x: 0, y: 0, w: 200, h: 120, style_modifiers: 'shape=hexagon'),
|
61
|
+
container: ShapeDefaults.new(type: :container, x: 0, y: 0, w: 160, h: 160, style_modifiers: 'swimlane'),
|
62
|
+
container2: ShapeDefaults.new(type: :container2, x: 0, y: 0, w: 160, h: 160, style_modifiers: 'swimlane;horizontal=0'),
|
63
|
+
container3: ShapeDefaults.new(type: :container3, x: 0, y: 0, w: 160, h: 160, style_modifiers: 'swimlane;startSize=50'),
|
64
|
+
container4: ShapeDefaults.new(type: :container4, x: 0, y: 0, w: 160, h: 160, style_modifiers: 'swimlane;resizable=0'),
|
65
|
+
note: ShapeDefaults.new(type: :note, x: 0, y: 0, w: 160, h: 160, style_modifiers: 'shape=note'),
|
66
|
+
process: ShapeDefaults.new(type: :process, x: 0, y: 0, w: 200, h: 120, style_modifiers: 'shape=process'),
|
67
|
+
rectangle: ShapeDefaults.new(type: :rectangle, x: 0, y: 0, w: 200, h: 120, style_modifiers: ''),
|
68
|
+
rectangle2: ShapeDefaults.new(type: :rectangle2, x: 0, y: 0, w: 200, h: 120, style_modifiers: 'shape=mxgraph.basic.cloud_rect'),
|
69
|
+
square: ShapeDefaults.new(type: :square, x: 0, y: 0, w: 160, h: 160, style_modifiers: ''),
|
70
|
+
step: ShapeDefaults.new(type: :step, x: 0, y: 0, w: 120, h: 80, style_modifiers: 'shape=step;perimeter=stepPerimeter;fixedSize=1'),
|
71
|
+
tick: ShapeDefaults.new(type: :tick, x: 0, y: 0, w: 50, h: 50, style_modifiers: 'verticalLabelPosition=bottom;verticalAlign=top;shape=mxgraph.basic.tick'),
|
72
|
+
face: ShapeDefaults.new(type: :face, x: 0, y: 0, w: 100, h: 100, style_modifiers: 'verticalLabelPosition=bottom;verticalAlign=top;shape=mxgraph.basic.smiley'),
|
73
|
+
triangle: ShapeDefaults.new(type: :triangle, x: 0, y: 0, w: 100, h: 100, style_modifiers: 'triangle'),
|
74
|
+
embed_row: ShapeDefaults.new(type: :embed_row, x: 0, y: 0, w: 200, h: 40,
|
75
|
+
style_modifiers: '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'),
|
76
|
+
embed_col50: ShapeDefaults.new(type: :embed_col50, x: 0, y: 0, w: 50, h: 40, style_modifiers: 'shape=partialRectangle;connectable=0;top=0;left=0;bottom=0;right=0;fontStyle=1;overflow=hidden'),
|
77
|
+
embed_col200: ShapeDefaults.new(type: :embed_col200, x: 0, y: 0, w: 150, h: 40,
|
78
|
+
style_modifiers: 'shape=partialRectangle;connectable=0;top=0;left=0;bottom=0;right=0;align=left;spacingLeft=6;overflow=hidden')
|
79
|
+
)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
# :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
|
|
@@ -52,20 +54,20 @@ module DrawioDsl
|
|
52
54
|
|
53
55
|
def add_grid_layout(**opts)
|
54
56
|
rule = DrawioDsl::Schema::GridLayout.new(current_page, **opts)
|
55
|
-
|
57
|
+
add_layout(rule)
|
56
58
|
end
|
57
59
|
|
58
60
|
def add_flex_layout(**opts)
|
59
61
|
rule = DrawioDsl::Schema::FlexLayout.new(current_page, **opts)
|
60
|
-
|
62
|
+
add_layout(rule)
|
61
63
|
end
|
62
64
|
|
63
|
-
def
|
65
|
+
def add_layout(rule)
|
64
66
|
@current_layout_rule = rule
|
65
67
|
|
66
68
|
rule.id = "rule-#{current_page.nodes.length + 1}" unless rule.id
|
67
69
|
|
68
|
-
current_page.nodes
|
70
|
+
current_page.nodes.add(rule)
|
69
71
|
|
70
72
|
rule
|
71
73
|
end
|
@@ -79,65 +81,17 @@ module DrawioDsl
|
|
79
81
|
|
80
82
|
shape.id = "#{current_page.id}-#{current_page.nodes.length + 1}" unless shape.id
|
81
83
|
|
82
|
-
current_page.nodes
|
84
|
+
current_page.nodes.add(shape)
|
83
85
|
|
84
86
|
shape
|
85
87
|
end
|
86
88
|
|
87
|
-
|
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
|
-
|
122
|
-
def add_cloud(**opts)
|
123
|
-
cloud = DrawioDsl::Schema::Cloud.new(current_page, **opts)
|
124
|
-
add_shape(cloud)
|
125
|
-
end
|
126
|
-
|
127
|
-
def add_note(**opts)
|
128
|
-
note = DrawioDsl::Schema::Note.new(current_page, **opts)
|
129
|
-
add_shape(note)
|
130
|
-
end
|
131
|
-
|
132
|
-
def add_callout(**opts)
|
133
|
-
callout = DrawioDsl::Schema::Callout.new(current_page, **opts)
|
134
|
-
add_shape(callout)
|
135
|
-
end
|
136
|
-
|
89
|
+
# :nocov:
|
137
90
|
def debug
|
138
91
|
puts JSON.pretty_generate(actions)
|
139
92
|
puts JSON.pretty_generate(diagram.to_h)
|
140
93
|
end
|
94
|
+
# :nocov:
|
141
95
|
|
142
96
|
def dom
|
143
97
|
diagram.to_h
|
@@ -0,0 +1,158 @@
|
|
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
|
+
|
142
|
+
def add_embed_row(**opts)
|
143
|
+
embed_row = DrawioDsl::Schema::EmbedRow.new(current_page, **opts)
|
144
|
+
add_shape(embed_row)
|
145
|
+
end
|
146
|
+
|
147
|
+
def add_embed_col50(**opts)
|
148
|
+
embed_col50 = DrawioDsl::Schema::EmbedCol50.new(current_page, **opts)
|
149
|
+
add_shape(embed_col50)
|
150
|
+
end
|
151
|
+
|
152
|
+
def add_embed_col200(**opts)
|
153
|
+
embed_col200 = DrawioDsl::Schema::EmbedCol200.new(current_page, **opts)
|
154
|
+
add_shape(embed_col200)
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
158
|
+
# :nocov:
|
data/lib/drawio_dsl/drawio.rb
CHANGED
@@ -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
|
-
|
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,78 +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(10)
|
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
|
-
when 7
|
77
|
-
cloud(**opts)
|
78
|
-
when 8
|
79
|
-
note(**opts)
|
80
|
-
when 9
|
81
|
-
callout(**opts)
|
82
|
-
end
|
83
|
-
end
|
84
|
-
# rubocop:enable Metrics/CyclomaticComplexity
|
85
|
-
|
86
|
-
def square(**opts)
|
87
|
-
builder.add_square(**opts)
|
88
|
-
end
|
89
|
-
|
90
|
-
def rectangle(**opts)
|
91
|
-
builder.add_rectangle(**opts)
|
92
|
-
end
|
93
|
-
|
94
|
-
def circle(**opts)
|
95
|
-
builder.add_circle(**opts)
|
96
|
-
end
|
97
|
-
|
98
|
-
def process(**opts)
|
99
|
-
builder.add_process(**opts)
|
100
|
-
end
|
101
|
-
|
102
|
-
def ellipse(**opts)
|
103
|
-
builder.add_ellipse(**opts)
|
104
|
-
end
|
105
|
-
|
106
|
-
def diamond(**opts)
|
107
|
-
builder.add_diamond(**opts)
|
108
|
-
end
|
109
|
-
|
110
|
-
def hexagon(**opts)
|
111
|
-
builder.add_hexagon(**opts)
|
112
|
-
end
|
113
|
-
|
114
|
-
def cloud(**opts)
|
115
|
-
builder.add_cloud(**opts)
|
116
|
-
end
|
117
|
-
|
118
|
-
def note(**opts)
|
119
|
-
builder.add_note(**opts)
|
120
|
-
end
|
121
|
-
|
122
|
-
def callout(**opts)
|
123
|
-
builder.add_callout(**opts)
|
124
|
-
end
|
125
|
-
|
126
|
-
private
|
127
|
-
|
128
|
-
def current_shape
|
129
|
-
builder.current_shape
|
130
|
-
end
|
131
41
|
end
|
132
42
|
end
|