drawio_dsl 0.4.1 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/.builders/.data/shapes.json +144 -8
  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_shape.rb +9 -0
  7. data/.builders/.templates/{schema_shape_spec.rb → basic/schema_shape_spec.rb} +2 -2
  8. data/.builders/blueprint/shapes.rb +31 -12
  9. data/.builders/boot.rb +1 -0
  10. data/.builders/generators/02-generate-app.rb +43 -0
  11. data/.builders/generators/sample_diagrams/25-themes.rb +2 -2
  12. data/.builders/generators/sample_diagrams/30-shapes.rb +23 -0
  13. data/.rubocop.yml +20 -3
  14. data/CHANGELOG.md +7 -0
  15. data/README.md +4 -0
  16. data/lib/drawio_dsl/configuration.rb +5 -101
  17. data/lib/drawio_dsl/configuration_extension.rb +13 -0
  18. data/lib/drawio_dsl/configuration_shapes.rb +75 -0
  19. data/lib/drawio_dsl/configuration_themes.rb +63 -0
  20. data/lib/drawio_dsl/dom_builder.rb +4 -50
  21. data/lib/drawio_dsl/dom_builder_shapes.rb +143 -0
  22. data/lib/drawio_dsl/drawio.rb +1 -91
  23. data/lib/drawio_dsl/drawio_shapes.rb +175 -0
  24. data/lib/drawio_dsl/schema/_.rb +17 -0
  25. data/{.builders/.templates/schema_shape.rb → lib/drawio_dsl/schema/shapes/actor.rb} +2 -2
  26. data/lib/drawio_dsl/schema/shapes/actor2.rb +9 -0
  27. data/lib/drawio_dsl/schema/shapes/callout2.rb +9 -0
  28. data/lib/drawio_dsl/schema/shapes/callout3.rb +9 -0
  29. data/lib/drawio_dsl/schema/shapes/callout4.rb +9 -0
  30. data/lib/drawio_dsl/schema/shapes/container.rb +9 -0
  31. data/lib/drawio_dsl/schema/shapes/container2.rb +9 -0
  32. data/lib/drawio_dsl/schema/shapes/container3.rb +9 -0
  33. data/lib/drawio_dsl/schema/shapes/container4.rb +9 -0
  34. data/lib/drawio_dsl/schema/shapes/cross.rb +9 -0
  35. data/lib/drawio_dsl/schema/shapes/document.rb +9 -0
  36. data/lib/drawio_dsl/schema/shapes/envelop.rb +9 -0
  37. data/lib/drawio_dsl/schema/shapes/face.rb +9 -0
  38. data/lib/drawio_dsl/schema/shapes/rectangle2.rb +9 -0
  39. data/lib/drawio_dsl/schema/shapes/shape.rb +4 -6
  40. data/lib/drawio_dsl/schema/shapes/step.rb +9 -0
  41. data/lib/drawio_dsl/schema/shapes/tick.rb +9 -0
  42. data/lib/drawio_dsl/schema/shapes/triangle.rb +9 -0
  43. data/lib/drawio_dsl/version.rb +1 -1
  44. data/lib/drawio_dsl.rb +5 -0
  45. data/package-lock.json +2 -2
  46. data/package.json +1 -1
  47. metadata +31 -5
  48. data/.builders/generators/90-requires.rb +0 -35
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 43e99df9f899e7c7ebeb6618d9b2018cad1a17abf786cf047d918c1eed513f77
4
- data.tar.gz: 2b251a9fa966d5447cc8130b1a1b9a2ac90e7f229b5b1aa0d182a233179ec88e
3
+ metadata.gz: b4cd7150000e0bd48916f7c5605f1da32d91d5fa20cb221253a9acbaa8538e06
4
+ data.tar.gz: 84355154d1847979120f71315f9cd1b9f79965e652184255bb849e24e6c54832
5
5
  SHA512:
6
- metadata.gz: d0da48b1461fa48072af5674a689dd9beac83fee630cb2cd656c22a3495fdffd062ec3fffa80dfca57478a240557ac70c456c14adc87b31d6dd2d4930d77dc2e
7
- data.tar.gz: 6376e89f6e55ff96b644cbdf23f26000facdad358791f9bfa66eeee4bc7193389cc75c6601c3f5a8cc7a51f24c5717f1985dbcdd86214efbb1cadf5eff991b1e
6
+ metadata.gz: b36ecdb34dcbcd5efc9309671650526590a98c41d7f7fb762349c401cd977284d33346ef8517b3dde60f827013f85b088dd839560e0d03b7c9dda1384e0816fa
7
+ data.tar.gz: 58eacb1d2c4eee64d09380cc9e1c9c7c9c9e6b105377494df083c3a1895d70e78b92a8309caeb7582e706e09c72f51625aa1fec852522c4b48af34d2fef88817
@@ -1,11 +1,51 @@
1
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
+ },
2
18
  {
3
19
  "type": "callout",
4
20
  "x": 0,
5
21
  "y": 0,
6
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,
7
31
  "h": 160,
8
- "style_modifiers": "double=1;shape=callout"
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;"
9
49
  },
10
50
  {
11
51
  "type": "circle",
@@ -13,7 +53,7 @@
13
53
  "y": 0,
14
54
  "w": 160,
15
55
  "h": 160,
16
- "style_modifiers": "double=1;ellipse"
56
+ "style_modifiers": "ellipse"
17
57
  },
18
58
  {
19
59
  "type": "cloud",
@@ -21,15 +61,39 @@
21
61
  "y": 0,
22
62
  "w": 160,
23
63
  "h": 160,
24
- "style_modifiers": "double=1;shape=cloud"
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"
25
81
  },
26
82
  {
27
83
  "type": "diamond",
28
84
  "x": 0,
29
85
  "y": 0,
86
+ "w": 100,
87
+ "h": 100,
88
+ "style_modifiers": "rhombus"
89
+ },
90
+ {
91
+ "type": "document",
92
+ "x": 0,
93
+ "y": 0,
30
94
  "w": 160,
31
95
  "h": 160,
32
- "style_modifiers": "double=1;rhombus"
96
+ "style_modifiers": "shape=mxgraph.basic.document"
33
97
  },
34
98
  {
35
99
  "type": "ellipse",
@@ -37,7 +101,7 @@
37
101
  "y": 0,
38
102
  "w": 200,
39
103
  "h": 120,
40
- "style_modifiers": "double=1;ellipse"
104
+ "style_modifiers": "ellipse"
41
105
  },
42
106
  {
43
107
  "type": "hexagon",
@@ -45,7 +109,39 @@
45
109
  "y": 0,
46
110
  "w": 200,
47
111
  "h": 120,
48
- "style_modifiers": "double=1;shape=hexagon"
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;horizontal=0"
121
+ },
122
+ {
123
+ "type": "container2",
124
+ "x": 0,
125
+ "y": 0,
126
+ "w": 160,
127
+ "h": 160,
128
+ "style_modifiers": "swimlane"
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"
49
145
  },
50
146
  {
51
147
  "type": "note",
@@ -53,7 +149,7 @@
53
149
  "y": 0,
54
150
  "w": 160,
55
151
  "h": 160,
56
- "style_modifiers": "double=1;shape=note"
152
+ "style_modifiers": "shape=note"
57
153
  },
58
154
  {
59
155
  "type": "process",
@@ -61,7 +157,7 @@
61
157
  "y": 0,
62
158
  "w": 200,
63
159
  "h": 120,
64
- "style_modifiers": "double=1;shape=process"
160
+ "style_modifiers": "shape=process"
65
161
  },
66
162
  {
67
163
  "type": "rectangle",
@@ -71,6 +167,14 @@
71
167
  "h": 120,
72
168
  "style_modifiers": ""
73
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
+ },
74
178
  {
75
179
  "type": "square",
76
180
  "x": 0,
@@ -78,5 +182,37 @@
78
182
  "w": 160,
79
183
  "h": 160,
80
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"
81
217
  }
82
218
  ]
@@ -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,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
@@ -1,13 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- RSpec.describe DrawioDsl::Schema::{{camle type}} do
3
+ RSpec.describe DrawioDsl::Schema::{{camel shape.type}} do
4
4
  include_context :node_dependencies
5
5
 
6
6
  subject { instance }
7
7
 
8
8
  let(:instance) { described_class.new(diagram, **args) }
9
9
  let(:args) { { id: 1 } }
10
- let(:default) { KConfig.configuration.drawio.shapes.{{snake type}} }
10
+ let(:default) { KConfig.configuration.drawio.shapes.{{snake shape.type}} }
11
11
 
12
12
  it_behaves_like :basic_shape_attributes
13
13
  end
@@ -4,18 +4,37 @@ KManager.model :shapes, namespace: %i[domain] do
4
4
  table :shapes do
5
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 :callout , x: 0, y: 0, w: 160, h: 160, style_modifiers: 'double=1;shape=callout'
9
- row :circle , x: 0, y: 0, w: 160, h: 160, style_modifiers: 'double=1;ellipse'
10
- row :cloud , x: 0, y: 0, w: 160, h: 160, style_modifiers: 'double=1;shape=cloud'
11
- row :diamond , x: 0, y: 0, w: 160, h: 160, style_modifiers: 'double=1;rhombus'
12
- row :ellipse , x: 0, y: 0, w: 200, h: 120, style_modifiers: 'double=1;ellipse'
13
- row :hexagon , x: 0, y: 0, w: 200, h: 120, style_modifiers: 'double=1;shape=hexagon'
14
- row :note , x: 0, y: 0, w: 160, h: 160, style_modifiers: 'double=1;shape=note'
15
- row :process , x: 0, y: 0, w: 200, h: 120, style_modifiers: 'double=1;shape=process'
16
- row :rectangle , x: 0, y: 0, w: 200, h: 120, style_modifiers: ''
17
- row :square , 0, 0, 160, 160, ''
18
-
7
+ # shape is a custom object
8
+ # row :shape , 0, 0, 20, 20, ''
9
+
10
+ row :actor , 0, 0, 40, 50, 'shape=actor'
11
+ row :actor2 , 0, 0, 30, 50, 'shape=umlActor;verticalLabelPosition=bottom;outlineConnect=1'
12
+ row :callout , 0, 0, 160, 120, 'shape=callout'
13
+ row :callout2 , 0, 0, 160, 160, 'shape=mxgraph.basic.oval_callout'
14
+ row :callout3 , 0, 0, 160, 160, 'shape=mxgraph.basic.cloud_callout'
15
+ row :callout4 , 0, 0, 160, 120, 'shape=mxgraph.basic.roundRectCallout;dx=30;dy=15;size=5;boundedLbl=1;'
16
+ row :circle , 0, 0, 160, 160, 'ellipse'
17
+ row :cloud , 0, 0, 160, 160, 'shape=cloud'
18
+ row :cross , 0, 0, 50, 50, 'verticalLabelPosition=bottom;verticalAlign=top;html=1;shape=mxgraph.basic.x'
19
+ row :envelop , 0, 0, 160, 100, 'shape=message'
20
+ row :diamond , 0, 0, 100, 100, 'rhombus'
21
+ row :document , 0, 0, 160, 160, 'shape=mxgraph.basic.document'
22
+ row :ellipse , 0, 0, 200, 120, 'ellipse'
23
+ row :hexagon , 0, 0, 200, 120, 'shape=hexagon'
24
+ row :container , 0, 0, 160, 160, 'swimlane;horizontal=0'
25
+ row :container2 , 0, 0, 160, 160, 'swimlane'
26
+ row :container3 , 0, 0, 160, 160, 'swimlane;startSize=50'
27
+ row :container4 , 0, 0, 160, 160, 'swimlane;resizable=0'
28
+ row :note , 0, 0, 160, 160, 'shape=note'
29
+ row :process , 0, 0, 200, 120, 'shape=process'
30
+ row :rectangle , 0, 0, 200, 120, ''
31
+ row :rectangle2 , 0, 0, 200, 120, 'shape=mxgraph.basic.cloud_rect'
32
+ row :square , 0, 0, 160, 160, ''
33
+ row :step , 0, 0, 120, 80, 'shape=step;perimeter=stepPerimeter;fixedSize=1'
34
+ row :tick , 0, 0, 50, 50, 'verticalLabelPosition=bottom;verticalAlign=top;shape=mxgraph.basic.tick'
35
+ row :face , 0, 0, 100, 100, 'verticalLabelPosition=bottom;verticalAlign=top;shape=mxgraph.basic.smiley'
36
+ row :triangle , 0, 0, 100, 100, 'triangle'
37
+
19
38
  end
20
39
 
21
40
  action do
data/.builders/boot.rb CHANGED
@@ -52,6 +52,7 @@ KConfig.configure(CONFIG_KEY) do |config|
52
52
  # Target Folders
53
53
  config.target_folders.add(:app , base_folder)
54
54
  config.target_folders.add(:lib , :app, 'lib', 'drawio_dsl')
55
+ config.target_folders.add(:spec , :app, 'spec', 'drawio_dsl')
55
56
  config.target_folders.add(:builder , builder_folder)
56
57
  config.target_folders.add(:data , :builder, '.data')
57
58
  end
@@ -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,9 +36,6 @@ 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
@@ -58,6 +56,25 @@ Metrics/ClassLength:
58
56
  Metrics/ModuleLength:
59
57
  Exclude:
60
58
  - "**/spec/**/*"
59
+ - "lib/drawio_dsl/drawio_shapes.rb"
60
+ - "lib/drawio_dsl/schema/shapes/diagram.rb"
61
+ - "lib/drawio_dsl/dom_builder_shapes.rb"
62
+ Metrics/AbcSize:
63
+ Exclude:
64
+ - "lib/drawio_dsl/drawio_shapes.rb"
65
+ - "lib/drawio_dsl/configuration_shapes.rb"
66
+ - "lib/drawio_dsl/configuration_themes.rb"
67
+ Metrics/CyclomaticComplexity:
68
+ Exclude:
69
+ - "lib/drawio_dsl/drawio_shapes.rb"
70
+ Metrics/MethodLength:
71
+ Max: 25
72
+ Exclude:
73
+ - "lib/drawio_dsl/drawio_shapes.rb"
74
+ - "lib/drawio_dsl/schema/shapes/shape.rb"
75
+ - "lib/drawio_dsl/schema/shapes/page.rb"
76
+ - "lib/drawio_dsl/configuration_shapes.rb"
77
+ - "lib/drawio_dsl/configuration_themes.rb"
61
78
  Naming/MemoizedInstanceVariableName:
62
79
  Enabled: false
63
80
  Naming/AccessorMethodName:
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [0.4.1](https://github.com/klueless-io/drawio_dsl/compare/v0.4.0...v0.4.1) (2022-03-06)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * add support for generated shapes ([b52f278](https://github.com/klueless-io/drawio_dsl/commit/b52f2786281acadc32d546f0ed9c7ac2c8fc1094))
7
+
1
8
  # [0.4.0](https://github.com/klueless-io/drawio_dsl/compare/v0.3.0...v0.4.0) (2022-03-05)
2
9
 
3
10
 
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:
@@ -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
- @themes[theme]
26
+ themes[theme]
51
27
  end
52
28
 
53
29
  def random_theme
54
- @themes.keys.sample
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