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.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/.builders/.data/shapes.json +242 -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 +47 -12
  10. data/.builders/boot.rb +5 -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} +2 -2
  17. data/.builders/generators/sample_diagrams/30-shapes.rb +23 -0
  18. data/.rubocop.yml +22 -3
  19. data/CHANGELOG.md +23 -0
  20. data/README.md +4 -0
  21. data/lib/drawio_dsl/configuration.rb +5 -101
  22. data/lib/drawio_dsl/configuration_extension.rb +13 -0
  23. data/lib/drawio_dsl/configuration_shapes.rb +83 -0
  24. data/lib/drawio_dsl/configuration_themes.rb +63 -0
  25. data/lib/drawio_dsl/dom_builder.rb +9 -55
  26. data/lib/drawio_dsl/dom_builder_shapes.rb +158 -0
  27. data/lib/drawio_dsl/drawio.rb +1 -91
  28. data/lib/drawio_dsl/drawio_shapes.rb +193 -0
  29. data/lib/drawio_dsl/layout_engine.rb +1 -8
  30. data/lib/drawio_dsl/schema/_.rb +21 -0
  31. data/lib/drawio_dsl/schema/node_list.rb +37 -0
  32. data/lib/drawio_dsl/schema/page.rb +5 -5
  33. data/{.builders/.templates/schema_shape.rb → lib/drawio_dsl/schema/shapes/actor.rb} +2 -2
  34. data/lib/drawio_dsl/schema/shapes/actor2.rb +9 -0
  35. data/lib/drawio_dsl/schema/shapes/callout2.rb +9 -0
  36. data/lib/drawio_dsl/schema/shapes/callout3.rb +9 -0
  37. data/lib/drawio_dsl/schema/shapes/callout4.rb +9 -0
  38. data/lib/drawio_dsl/schema/shapes/container.rb +9 -0
  39. data/lib/drawio_dsl/schema/shapes/container2.rb +9 -0
  40. data/lib/drawio_dsl/schema/shapes/container3.rb +9 -0
  41. data/lib/drawio_dsl/schema/shapes/container4.rb +9 -0
  42. data/lib/drawio_dsl/schema/shapes/cross.rb +9 -0
  43. data/lib/drawio_dsl/schema/shapes/document.rb +9 -0
  44. data/lib/drawio_dsl/schema/shapes/embed_col200.rb +9 -0
  45. data/lib/drawio_dsl/schema/shapes/embed_col50.rb +9 -0
  46. data/lib/drawio_dsl/schema/shapes/embed_row.rb +9 -0
  47. data/lib/drawio_dsl/schema/shapes/envelop.rb +9 -0
  48. data/lib/drawio_dsl/schema/shapes/face.rb +9 -0
  49. data/lib/drawio_dsl/schema/shapes/rectangle2.rb +9 -0
  50. data/lib/drawio_dsl/schema/shapes/shape.rb +10 -6
  51. data/lib/drawio_dsl/schema/shapes/step.rb +9 -0
  52. data/lib/drawio_dsl/schema/shapes/tick.rb +9 -0
  53. data/lib/drawio_dsl/schema/shapes/triangle.rb +9 -0
  54. data/lib/drawio_dsl/version.rb +1 -1
  55. data/lib/drawio_dsl/xml_builder.rb +2 -12
  56. data/lib/drawio_dsl.rb +5 -0
  57. data/package-lock.json +2 -2
  58. data/package.json +1 -1
  59. metadata +42 -9
  60. data/.builders/.templates/command.rb +0 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 56780c6c8fa8c1ea29a29e07bf389cf257fd7a33faf52e955b3fe56133367063
4
- data.tar.gz: f583d40a64cea1177d7d52ab627dcbfa954cb3091dada0903947f69f5792d3b5
3
+ metadata.gz: e5d0f74df30a578aa511a4d9a7ba497839667f25c33d30cb70ec97c42254ec57
4
+ data.tar.gz: bab21fd8a4c2e2db844e3bf1cba63b6e224778fbe94a029ddaba9fd6fad71539
5
5
  SHA512:
6
- metadata.gz: 92b5c4e8e2a8210c3e2213df96f1d35034689a3d2ff9132e17fc1fa30f68b89551cb395f725e0b1b5da3b506e62471e2e64def33683f8959f53a41a43e4f5805
7
- data.tar.gz: 112eb4f963aa4c295559f8d1e8ed0eaf0121bb768282924ca54059c3de4924d16a33b5a3d33dd9044378315840aafda7db34d228aa2064606eccf5d29776da52
6
+ metadata.gz: c1b8da217e0876c4720cf087080ed0d66a332eaecb469ab51548b52f95f923943ea57c1fb2405499456be030ce8144d74667f8ff120a7df7d674b4f138c11945
7
+ data.tar.gz: 1bf29a42082f521cf04f51cd882bb0f664589f076add43d956ccf636f1c24f57c260bf46721bb4f18b8bf87acb9ed487b0ac77d5fd35d482b9dbd71853f875af
@@ -0,0 +1,242 @@
1
+ [
2
+ {
3
+ "type": "actor",
4
+ "x": 0,
5
+ "y": 0,
6
+ "w": 40,
7
+ "h": 50,
8
+ "style_modifiers": "shape=actor"
9
+ },
10
+ {
11
+ "type": "actor2",
12
+ "x": 0,
13
+ "y": 0,
14
+ "w": 30,
15
+ "h": 50,
16
+ "style_modifiers": "shape=umlActor;verticalLabelPosition=bottom;outlineConnect=1"
17
+ },
18
+ {
19
+ "type": "callout",
20
+ "x": 0,
21
+ "y": 0,
22
+ "w": 160,
23
+ "h": 120,
24
+ "style_modifiers": "shape=callout"
25
+ },
26
+ {
27
+ "type": "callout2",
28
+ "x": 0,
29
+ "y": 0,
30
+ "w": 160,
31
+ "h": 160,
32
+ "style_modifiers": "shape=mxgraph.basic.oval_callout"
33
+ },
34
+ {
35
+ "type": "callout3",
36
+ "x": 0,
37
+ "y": 0,
38
+ "w": 160,
39
+ "h": 160,
40
+ "style_modifiers": "shape=mxgraph.basic.cloud_callout"
41
+ },
42
+ {
43
+ "type": "callout4",
44
+ "x": 0,
45
+ "y": 0,
46
+ "w": 160,
47
+ "h": 120,
48
+ "style_modifiers": "shape=mxgraph.basic.roundRectCallout;dx=30;dy=15;size=5;boundedLbl=1;"
49
+ },
50
+ {
51
+ "type": "circle",
52
+ "x": 0,
53
+ "y": 0,
54
+ "w": 160,
55
+ "h": 160,
56
+ "style_modifiers": "ellipse"
57
+ },
58
+ {
59
+ "type": "cloud",
60
+ "x": 0,
61
+ "y": 0,
62
+ "w": 160,
63
+ "h": 160,
64
+ "style_modifiers": "shape=cloud"
65
+ },
66
+ {
67
+ "type": "cross",
68
+ "x": 0,
69
+ "y": 0,
70
+ "w": 50,
71
+ "h": 50,
72
+ "style_modifiers": "verticalLabelPosition=bottom;verticalAlign=top;html=1;shape=mxgraph.basic.x"
73
+ },
74
+ {
75
+ "type": "envelop",
76
+ "x": 0,
77
+ "y": 0,
78
+ "w": 160,
79
+ "h": 100,
80
+ "style_modifiers": "shape=message"
81
+ },
82
+ {
83
+ "type": "diamond",
84
+ "x": 0,
85
+ "y": 0,
86
+ "w": 100,
87
+ "h": 100,
88
+ "style_modifiers": "rhombus"
89
+ },
90
+ {
91
+ "type": "document",
92
+ "x": 0,
93
+ "y": 0,
94
+ "w": 160,
95
+ "h": 160,
96
+ "style_modifiers": "shape=mxgraph.basic.document"
97
+ },
98
+ {
99
+ "type": "ellipse",
100
+ "x": 0,
101
+ "y": 0,
102
+ "w": 200,
103
+ "h": 120,
104
+ "style_modifiers": "ellipse"
105
+ },
106
+ {
107
+ "type": "hexagon",
108
+ "x": 0,
109
+ "y": 0,
110
+ "w": 200,
111
+ "h": 120,
112
+ "style_modifiers": "shape=hexagon"
113
+ },
114
+ {
115
+ "type": "container",
116
+ "x": 0,
117
+ "y": 0,
118
+ "w": 160,
119
+ "h": 160,
120
+ "style_modifiers": "swimlane"
121
+ },
122
+ {
123
+ "type": "container2",
124
+ "x": 0,
125
+ "y": 0,
126
+ "w": 160,
127
+ "h": 160,
128
+ "style_modifiers": "swimlane;horizontal=0"
129
+ },
130
+ {
131
+ "type": "container3",
132
+ "x": 0,
133
+ "y": 0,
134
+ "w": 160,
135
+ "h": 160,
136
+ "style_modifiers": "swimlane;startSize=50"
137
+ },
138
+ {
139
+ "type": "container4",
140
+ "x": 0,
141
+ "y": 0,
142
+ "w": 160,
143
+ "h": 160,
144
+ "style_modifiers": "swimlane;resizable=0"
145
+ },
146
+ {
147
+ "type": "note",
148
+ "x": 0,
149
+ "y": 0,
150
+ "w": 160,
151
+ "h": 160,
152
+ "style_modifiers": "shape=note"
153
+ },
154
+ {
155
+ "type": "process",
156
+ "x": 0,
157
+ "y": 0,
158
+ "w": 200,
159
+ "h": 120,
160
+ "style_modifiers": "shape=process"
161
+ },
162
+ {
163
+ "type": "rectangle",
164
+ "x": 0,
165
+ "y": 0,
166
+ "w": 200,
167
+ "h": 120,
168
+ "style_modifiers": ""
169
+ },
170
+ {
171
+ "type": "rectangle2",
172
+ "x": 0,
173
+ "y": 0,
174
+ "w": 200,
175
+ "h": 120,
176
+ "style_modifiers": "shape=mxgraph.basic.cloud_rect"
177
+ },
178
+ {
179
+ "type": "square",
180
+ "x": 0,
181
+ "y": 0,
182
+ "w": 160,
183
+ "h": 160,
184
+ "style_modifiers": ""
185
+ },
186
+ {
187
+ "type": "step",
188
+ "x": 0,
189
+ "y": 0,
190
+ "w": 120,
191
+ "h": 80,
192
+ "style_modifiers": "shape=step;perimeter=stepPerimeter;fixedSize=1"
193
+ },
194
+ {
195
+ "type": "tick",
196
+ "x": 0,
197
+ "y": 0,
198
+ "w": 50,
199
+ "h": 50,
200
+ "style_modifiers": "verticalLabelPosition=bottom;verticalAlign=top;shape=mxgraph.basic.tick"
201
+ },
202
+ {
203
+ "type": "face",
204
+ "x": 0,
205
+ "y": 0,
206
+ "w": 100,
207
+ "h": 100,
208
+ "style_modifiers": "verticalLabelPosition=bottom;verticalAlign=top;shape=mxgraph.basic.smiley"
209
+ },
210
+ {
211
+ "type": "triangle",
212
+ "x": 0,
213
+ "y": 0,
214
+ "w": 100,
215
+ "h": 100,
216
+ "style_modifiers": "triangle"
217
+ },
218
+ {
219
+ "type": "embed_row",
220
+ "x": 0,
221
+ "y": 0,
222
+ "w": 200,
223
+ "h": 40,
224
+ "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"
225
+ },
226
+ {
227
+ "type": "embed_col50",
228
+ "x": 0,
229
+ "y": 0,
230
+ "w": 50,
231
+ "h": 40,
232
+ "style_modifiers": "shape=partialRectangle;connectable=0;top=0;left=0;bottom=0;right=0;fontStyle=1;overflow=hidden"
233
+ },
234
+ {
235
+ "type": "embed_col200",
236
+ "x": 0,
237
+ "y": 0,
238
+ "w": 150,
239
+ "h": 40,
240
+ "style_modifiers": "shape=partialRectangle;connectable=0;top=0;left=0;bottom=0;right=0;align=left;spacingLeft=6;overflow=hidden"
241
+ }
242
+ ]
@@ -0,0 +1,27 @@
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
+ {{#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, x: 0, y: 0, w: 20, h: 20, style_modifiers: ''),
20
+ {{#each shapes}}
21
+ {{snake ./type}}: ShapeDefaults.new(type: :{{snake ./type}}, x: {{./x}}, y: {{./y}}, w: {{./w}}, h: {{./h}}, style_modifiers: '{{{./style_modifiers}}}'){{#if @last}}{{^}},{{/if}}
22
+ {{/each}}
23
+ )
24
+ end
25
+ end
26
+ end
27
+ # :nocov:
@@ -0,0 +1,16 @@
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}}(**opts)
10
+ {{snake ./type}} = DrawioDsl::Schema::{{camel ./type}}.new(current_page, **opts)
11
+ add_shape({{snake ./type}})
12
+ end
13
+ {{/each}}
14
+ end
15
+ end
16
+ # :nocov:
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DrawioDsl
4
+ # DrawioDsl::Shapes is a list of DSL methods (one per 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}}(**opts)
18
+ builder.add_{{snake ./type}}(**opts)
19
+ end
20
+ {{/each}}
21
+ end
22
+ # :nocov:
23
+ end
@@ -0,0 +1,16 @@
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 'page'
8
+
9
+ require_relative 'layouts/layout'
10
+ require_relative 'layouts/flex_layout'
11
+ require_relative 'layouts/grid_layout'
12
+
13
+ require_relative 'shapes/shape'
14
+ {{#each shapes}}
15
+ require_relative 'shapes/{{snake ./type}}'
16
+ {{/each}}
@@ -0,0 +1,9 @@
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
@@ -0,0 +1,13 @@
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
@@ -2,18 +2,53 @@ KManager.model :shapes, namespace: %i[domain] do
2
2
  # microapp = import(:handlebars_helpers, :microapp)
3
3
 
4
4
  table :shapes do
5
- fields :type, :x, :y, :w, :h, :style_modifiers
5
+ fields [:type, :x, :y, :w, :h, :style_modifiers]
6
6
 
7
- # row :shape , x: 0, y: 0, w: 20, h: 20, style_modifiers: ''
8
- row :square , x: 0, y: 0, w: 160, h: 160, style_modifiers: ''
9
- row :rectangle , x: 0, y: 0, w: 200, h: 120, style_modifiers: ''
10
- row :circle , x: 0, y: 0, w: 160, h: 160, style_modifiers: 'double=1;ellipse'
11
- row :process , x: 0, y: 0, w: 200, h: 120, style_modifiers: 'double=1;shape=process'
12
- row :ellipse , x: 0, y: 0, w: 200, h: 120, style_modifiers: 'double=1;ellipse'
13
- row :diamond , x: 0, y: 0, w: 160, h: 160, style_modifiers: 'double=1;rhombus'
14
- row :hexagon , x: 0, y: 0, w: 200, h: 120, style_modifiers: 'double=1;shape=hexagon'
15
- row :cloud , x: 0, y: 0, w: 160, h: 160, style_modifiers: 'double=1;shape=cloud'
16
- row :note , x: 0, y: 0, w: 160, h: 160, style_modifiers: 'double=1;shape=note'
17
- row :callout , x: 0, y: 0, w: 160, h: 160, style_modifiers: 'double=1;shape=callout'
7
+ # shape is a custom object
8
+ # row :shape , 0, 0, 20, 20, ''
9
+
10
+ # configuration for general purpose shapes
11
+ row :actor , 0, 0, 40, 50, 'shape=actor'
12
+ row :actor2 , 0, 0, 30, 50, 'shape=umlActor;verticalLabelPosition=bottom;outlineConnect=1'
13
+ row :callout , 0, 0, 160, 120, 'shape=callout'
14
+ row :callout2 , 0, 0, 160, 160, 'shape=mxgraph.basic.oval_callout'
15
+ row :callout3 , 0, 0, 160, 160, 'shape=mxgraph.basic.cloud_callout'
16
+ row :callout4 , 0, 0, 160, 120, 'shape=mxgraph.basic.roundRectCallout;dx=30;dy=15;size=5;boundedLbl=1;'
17
+ row :circle , 0, 0, 160, 160, 'ellipse'
18
+ row :cloud , 0, 0, 160, 160, 'shape=cloud'
19
+ row :cross , 0, 0, 50, 50, 'verticalLabelPosition=bottom;verticalAlign=top;html=1;shape=mxgraph.basic.x'
20
+ row :envelop , 0, 0, 160, 100, 'shape=message'
21
+ row :diamond , 0, 0, 100, 100, 'rhombus'
22
+ row :document , 0, 0, 160, 160, 'shape=mxgraph.basic.document'
23
+ row :ellipse , 0, 0, 200, 120, 'ellipse'
24
+ row :hexagon , 0, 0, 200, 120, 'shape=hexagon'
25
+ row :container , 0, 0, 160, 160, 'swimlane'
26
+ row :container2 , 0, 0, 160, 160, 'swimlane;horizontal=0'
27
+ row :container3 , 0, 0, 160, 160, 'swimlane;startSize=50'
28
+ row :container4 , 0, 0, 160, 160, 'swimlane;resizable=0'
29
+ row :note , 0, 0, 160, 160, 'shape=note'
30
+ row :process , 0, 0, 200, 120, 'shape=process'
31
+ row :rectangle , 0, 0, 200, 120, ''
32
+ row :rectangle2 , 0, 0, 200, 120, 'shape=mxgraph.basic.cloud_rect'
33
+ row :square , 0, 0, 160, 160, ''
34
+ row :step , 0, 0, 120, 80, 'shape=step;perimeter=stepPerimeter;fixedSize=1'
35
+ row :tick , 0, 0, 50, 50, 'verticalLabelPosition=bottom;verticalAlign=top;shape=mxgraph.basic.tick'
36
+ row :face , 0, 0, 100, 100, 'verticalLabelPosition=bottom;verticalAlign=top;shape=mxgraph.basic.smiley'
37
+ row :triangle , 0, 0, 100, 100, 'triangle'
38
+
39
+ # configuration for embedded element shape
40
+ # note that the width / height probably should be driven of parent shape
41
+ row :embed_row , 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'
42
+ row :embed_col50 , 0, 0, 50, 40, 'shape=partialRectangle;connectable=0;top=0;left=0;bottom=0;right=0;fontStyle=1;overflow=hidden'
43
+ row :embed_col200 , 0, 0, 150, 40, 'shape=partialRectangle;connectable=0;top=0;left=0;bottom=0;right=0;align=left;spacingLeft=6;overflow=hidden'
44
+ end
45
+
46
+ action do
47
+ data = self.raw_data
48
+ shapes = JSON.pretty_generate(data['shapes'])
49
+
50
+ k_builder
51
+ .cd(:data)
52
+ .add_file('shapes.json', content: shapes, on_exist: :write)
18
53
  end
19
54
  end
data/.builders/boot.rb CHANGED
@@ -45,11 +45,16 @@ KConfig.configure(CONFIG_KEY) do |config|
45
45
  base_folder = File.expand_path('../', builder_folder)
46
46
  global_template = File.expand_path('~/dev/kgems/k_templates/templates')
47
47
 
48
+ # Templates
48
49
  config.template_folders.add(:global_template , global_template)
49
50
  config.template_folders.add(:template , File.expand_path('.templates', Dir.pwd))
50
51
 
52
+ # Target Folders
51
53
  config.target_folders.add(:app , base_folder)
54
+ config.target_folders.add(:lib , :app, 'lib', 'drawio_dsl')
55
+ config.target_folders.add(:spec , :app, 'spec', 'drawio_dsl')
52
56
  config.target_folders.add(:builder , builder_folder)
57
+ config.target_folders.add(:data , :builder, '.data')
53
58
  end
54
59
 
55
60
  KConfig.configuration(CONFIG_KEY).debug
@@ -0,0 +1,43 @@
1
+ KManager.action :requires do
2
+
3
+ action do
4
+ shapes_file = k_builder.target_folders.get_filename(:data, 'shapes.json')
5
+ shapes = JSON.parse(File.read(shapes_file))
6
+
7
+ KDirector::Dsls::BasicDsl
8
+ .init(k_builder,
9
+ on_exist: :write, # %i[skip write compare]
10
+ on_action: :execute # %i[queue execute]
11
+ )
12
+ .blueprint(
13
+ active: true,
14
+ on_exist: :write) do
15
+
16
+ cd(:lib)
17
+
18
+ add('schema/_.rb', template_file: 'schema_require.rb', shapes: shapes)
19
+
20
+ shapes.each do |shape|
21
+ add("schema/shapes/#{shape['type']}.rb",
22
+ template_file: 'schema_shape.rb',
23
+ shape: shape)
24
+ end
25
+
26
+ add("drawio_shapes.rb" , template_file: 'drawio_shapes.rb' , shapes: shapes, shape_length: shapes.length)
27
+ add("dom_builder_shapes.rb" , template_file: 'dom_builder_shapes.rb' , shapes: shapes)
28
+ add("configuration_shapes.rb" , template_file: 'configuration_shapes.rb', shapes: shapes)
29
+
30
+ cd(:spec)
31
+
32
+ shapes.each do |shape|
33
+ add("schema/shapes/#{shape['type']}_spec.rb",
34
+ template_file: 'schema_shape_spec.rb',
35
+ shape: shape)
36
+ end
37
+
38
+ cd(:app)
39
+ run_command('rubocop -a')
40
+
41
+ end
42
+ end
43
+ end
@@ -5,8 +5,8 @@ KManager.action :bootstrap do
5
5
  director = DrawioDsl::Drawio
6
6
  .init(k_builder)
7
7
  .diagram(theme: :style_06)
8
- .page('Style-Plain', margin_left: 0, margin_top: 0) do
9
- grid_layout(wrap_at: 5)
8
+ .page('Style-Plain', margin_left: 0, margin_top: 0, rounded: 1, background: '#FFEADB') do
9
+ grid_layout(wrap_at: 8)
10
10
 
11
11
  square(title: 'The quick brown fox jumps over the lazy dog')
12
12
  circle(title: 'Mary had a little lamb')
@@ -0,0 +1,23 @@
1
+ KManager.action :bootstrap do
2
+ action do
3
+
4
+ # :rounded, :shadow, :sketch, :glass
5
+ director = DrawioDsl::Drawio
6
+ .init(k_builder)
7
+ .diagram(theme: :style_06)
8
+ .page('Shapes', margin_left: 0, margin_top: 0) do
9
+ grid_layout(wrap_at: 5)
10
+
11
+ KConfig.configuration.drawio.shapes.members.each do |shape|
12
+ next if shape == :shape
13
+
14
+ send(shape, title: shape.to_s, shape: shape)
15
+ end
16
+ end
17
+
18
+ diagram = DrawioDsl::XmlBuilder.new(director.builder.diagram)
19
+
20
+ File.write('../spec/.samples/drawio/30-shapes.xml', diagram.build)
21
+ File.write('../spec/.samples/drawio/30-shapes.drawio', diagram.build)
22
+ end
23
+ end
data/.rubocop.yml CHANGED
@@ -11,6 +11,7 @@ AllCops:
11
11
  - ".builders/**/*"
12
12
  - "spec/samples/**/*"
13
13
 
14
+
14
15
  Metrics/BlockLength:
15
16
  Exclude:
16
17
  - "**/spec/**/*"
@@ -35,14 +36,13 @@ Metrics/BlockLength:
35
36
  - shared_examples_for
36
37
  - transaction
37
38
 
38
- Metrics/MethodLength:
39
- Max: 25
40
-
41
39
  Layout/LineLength:
42
40
  Max: 200
43
41
  # Ignores annotate output
44
42
  IgnoredPatterns: ['\A# \*\*']
45
43
  IgnoreCopDirectives: true
44
+ Exclude:
45
+ - "lib/drawio_dsl/configuration_shapes.rb"
46
46
 
47
47
  Lint/UnusedMethodArgument:
48
48
  AllowUnusedKeywordArguments: true
@@ -58,6 +58,25 @@ Metrics/ClassLength:
58
58
  Metrics/ModuleLength:
59
59
  Exclude:
60
60
  - "**/spec/**/*"
61
+ - "lib/drawio_dsl/drawio_shapes.rb"
62
+ - "lib/drawio_dsl/schema/shapes/diagram.rb"
63
+ - "lib/drawio_dsl/dom_builder_shapes.rb"
64
+ Metrics/AbcSize:
65
+ Exclude:
66
+ - "lib/drawio_dsl/drawio_shapes.rb"
67
+ - "lib/drawio_dsl/configuration_shapes.rb"
68
+ - "lib/drawio_dsl/configuration_themes.rb"
69
+ Metrics/CyclomaticComplexity:
70
+ Exclude:
71
+ - "lib/drawio_dsl/drawio_shapes.rb"
72
+ Metrics/MethodLength:
73
+ Max: 25
74
+ Exclude:
75
+ - "lib/drawio_dsl/drawio_shapes.rb"
76
+ - "lib/drawio_dsl/schema/shapes/shape.rb"
77
+ - "lib/drawio_dsl/schema/shapes/page.rb"
78
+ - "lib/drawio_dsl/configuration_shapes.rb"
79
+ - "lib/drawio_dsl/configuration_themes.rb"
61
80
  Naming/MemoizedInstanceVariableName:
62
81
  Enabled: false
63
82
  Naming/AccessorMethodName:
data/CHANGELOG.md CHANGED
@@ -1,3 +1,26 @@
1
+ # [0.5.0](https://github.com/klueless-io/drawio_dsl/compare/v0.4.1...v0.5.0) (2022-03-07)
2
+
3
+
4
+ ### Features
5
+
6
+ * add new and update older shapes ([64a0d83](https://github.com/klueless-io/drawio_dsl/commit/64a0d83dda6181183c0980914b7b2ee1520b84e6))
7
+ * final code generation in place for shapes ([ac4ed3c](https://github.com/klueless-io/drawio_dsl/commit/ac4ed3cace4e1794d38306e14d3cee60529add4b))
8
+ * final code generation in place for shapes ([4c2a6fb](https://github.com/klueless-io/drawio_dsl/commit/4c2a6fb376fe61cfd44a699677f7781c9e2b215c))
9
+
10
+ ## [0.4.1](https://github.com/klueless-io/drawio_dsl/compare/v0.4.0...v0.4.1) (2022-03-06)
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * add support for generated shapes ([b52f278](https://github.com/klueless-io/drawio_dsl/commit/b52f2786281acadc32d546f0ed9c7ac2c8fc1094))
16
+
17
+ # [0.4.0](https://github.com/klueless-io/drawio_dsl/compare/v0.3.0...v0.4.0) (2022-03-05)
18
+
19
+
20
+ ### Features
21
+
22
+ * big refactor, plus 98% test coverage ([0d1075c](https://github.com/klueless-io/drawio_dsl/commit/0d1075c177ff1441246950aaa7306ef774ba6df4))
23
+
1
24
  # [0.3.0](https://github.com/klueless-io/drawio_dsl/compare/v0.2.0...v0.3.0) (2022-03-04)
2
25
 
3
26
 
data/README.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  > DrawIO DSL can build DrawIO diagrams using a Domain Specific Language
4
4
 
5
+ ## ToDo
6
+
7
+ - Diagram needs to support background color and it needs to trickle down to pages
8
+
5
9
  ## Installation
6
10
 
7
11
  Add this line to your application's Gemfile: