drawio_dsl 0.8.1 → 0.8.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,9 +5,10 @@
5
5
  module DrawioDsl
6
6
  # Used to attach configuration to KConfig module
7
7
  module ConfigurationShapes
8
- ShapeDefaults = Struct.new(:type, :text_only, :x, :y, :w, :h, :style_modifiers, keyword_init: true)
8
+ ShapeDefaults = Struct.new(:type, :category, :x, :y, :w, :h, :style_modifiers, keyword_init: true)
9
9
  Shapes = Struct.new(
10
10
  :shape,
11
+ :line,
11
12
  :h1,
12
13
  :h2,
13
14
  :h3,
@@ -29,6 +30,7 @@ module DrawioDsl
29
30
  :container4,
30
31
  :cross,
31
32
  :envelop,
33
+ :database,
32
34
  :diamond,
33
35
  :document,
34
36
  :ellipse,
@@ -53,47 +55,49 @@ module DrawioDsl
53
55
 
54
56
  def add_shapes
55
57
  @shapes = Shapes.new(
56
- shape: ShapeDefaults.new(type: :shape, text_only: false, x: 0, y: 0, w: 20, h: 20, style_modifiers: ''),
57
- h1: ShapeDefaults.new(type: :h1, x: 0, text_only: true, y: 0, w: 100, h: 50, style_modifiers: 'text;fontSize=89;fontColor=#ffffff;fontStyle=1;fillColor=none'),
58
- h2: ShapeDefaults.new(type: :h2, x: 0, text_only: true, y: 0, w: 100, h: 50, style_modifiers: 'text;fontSize=67;fontColor=#ffffff;fontStyle=1;fillColor=none'),
59
- h3: ShapeDefaults.new(type: :h3, x: 0, text_only: true, y: 0, w: 100, h: 50, style_modifiers: 'text;fontSize=50;fontColor=#ffffff;fontStyle=1;fillColor=none'),
60
- h4: ShapeDefaults.new(type: :h4, x: 0, text_only: true, y: 0, w: 100, h: 50, style_modifiers: 'text;fontSize=37;fontColor=#ffffff;fontStyle=1;fillColor=none'),
61
- h5: ShapeDefaults.new(type: :h5, x: 0, text_only: true, y: 0, w: 100, h: 50, style_modifiers: 'text;fontSize=28;fontColor=#ffffff;fontStyle=1;fillColor=none'),
62
- h6: ShapeDefaults.new(type: :h6, x: 0, text_only: true, y: 0, w: 100, h: 50, style_modifiers: 'text;fontSize=21;fontColor=#ffffff;fontStyle=1;fillColor=none'),
63
- p: ShapeDefaults.new(type: :p, x: 0, text_only: true, y: 0, w: 100, h: 50, style_modifiers: 'text;fontSize=16;fontColor=#ffffff;fontStyle=1;fillColor=none'),
64
- actor: ShapeDefaults.new(type: :actor, x: 0, text_only: false, y: 0, w: 40, h: 50, style_modifiers: 'shape=actor'),
65
- actor2: ShapeDefaults.new(type: :actor2, x: 0, text_only: false, y: 0, w: 30, h: 50, style_modifiers: 'shape=umlActor;verticalLabelPosition=bottom;outlineConnect=1'),
66
- callout: ShapeDefaults.new(type: :callout, x: 0, text_only: false, y: 0, w: 160, h: 120, style_modifiers: 'shape=callout'),
67
- callout2: ShapeDefaults.new(type: :callout2, x: 0, text_only: false, y: 0, w: 160, h: 160, style_modifiers: 'shape=mxgraph.basic.oval_callout'),
68
- callout3: ShapeDefaults.new(type: :callout3, x: 0, text_only: false, y: 0, w: 160, h: 160, style_modifiers: 'shape=mxgraph.basic.cloud_callout'),
69
- callout4: ShapeDefaults.new(type: :callout4, x: 0, text_only: false, y: 0, w: 160, h: 120, style_modifiers: 'shape=mxgraph.basic.roundRectCallout;dx=30;dy=15;size=5;boundedLbl=1;'),
70
- circle: ShapeDefaults.new(type: :circle, x: 0, text_only: false, y: 0, w: 160, h: 160, style_modifiers: 'ellipse'),
71
- cloud: ShapeDefaults.new(type: :cloud, x: 0, text_only: false, y: 0, w: 160, h: 160, style_modifiers: 'shape=cloud'),
72
- container: ShapeDefaults.new(type: :container, x: 0, text_only: false, y: 0, w: 160, h: 160, style_modifiers: 'swimlane'),
73
- container2: ShapeDefaults.new(type: :container2, x: 0, text_only: false, y: 0, w: 160, h: 160, style_modifiers: 'swimlane;horizontal=0'),
74
- container3: ShapeDefaults.new(type: :container3, x: 0, text_only: false, y: 0, w: 160, h: 160, style_modifiers: 'swimlane;startSize=50'),
75
- container4: ShapeDefaults.new(type: :container4, x: 0, text_only: false, y: 0, w: 160, h: 160, style_modifiers: 'swimlane;resizable=0'),
76
- cross: ShapeDefaults.new(type: :cross, x: 0, text_only: false, y: 0, w: 50, h: 50, style_modifiers: 'verticalLabelPosition=bottom;verticalAlign=top;html=1;shape=mxgraph.basic.x'),
77
- envelop: ShapeDefaults.new(type: :envelop, x: 0, text_only: false, y: 0, w: 160, h: 100, style_modifiers: 'shape=message'),
78
- diamond: ShapeDefaults.new(type: :diamond, x: 0, text_only: false, y: 0, w: 100, h: 100, style_modifiers: 'rhombus'),
79
- document: ShapeDefaults.new(type: :document, x: 0, text_only: false, y: 0, w: 160, h: 160, style_modifiers: 'shape=mxgraph.basic.document'),
80
- ellipse: ShapeDefaults.new(type: :ellipse, x: 0, text_only: false, y: 0, w: 200, h: 120, style_modifiers: 'ellipse'),
81
- hexagon: ShapeDefaults.new(type: :hexagon, x: 0, text_only: false, y: 0, w: 200, h: 120, style_modifiers: 'shape=hexagon'),
82
- interface: ShapeDefaults.new(type: :interface, x: 0, text_only: false, y: 0, w: 160, h: 160, style_modifiers: 'align=left;overflow=fill;fontSize=12;fontFamily=Helvetica'),
83
- klass: ShapeDefaults.new(type: :klass, x: 0, text_only: false, y: 0, w: 160, h: 160, style_modifiers: 'align=left;overflow=fill;fontSize=12;fontFamily=Helvetica'),
84
- note: ShapeDefaults.new(type: :note, x: 0, text_only: false, y: 0, w: 160, h: 160, style_modifiers: 'shape=note'),
85
- process: ShapeDefaults.new(type: :process, x: 0, text_only: false, y: 0, w: 200, h: 120, style_modifiers: 'shape=process'),
86
- rectangle: ShapeDefaults.new(type: :rectangle, x: 0, text_only: false, y: 0, w: 200, h: 120, style_modifiers: ''),
87
- rectangle2: ShapeDefaults.new(type: :rectangle2, x: 0, text_only: false, y: 0, w: 200, h: 120, style_modifiers: 'shape=mxgraph.basic.cloud_rect'),
88
- square: ShapeDefaults.new(type: :square, x: 0, text_only: false, y: 0, w: 160, h: 160, style_modifiers: ''),
89
- step: ShapeDefaults.new(type: :step, x: 0, text_only: false, y: 0, w: 120, h: 80, style_modifiers: 'shape=step;perimeter=stepPerimeter;fixedSize=1'),
90
- tick: ShapeDefaults.new(type: :tick, x: 0, text_only: false, y: 0, w: 50, h: 50, style_modifiers: 'verticalLabelPosition=bottom;verticalAlign=top;shape=mxgraph.basic.tick'),
91
- todo: ShapeDefaults.new(type: :todo, x: 0, text_only: false, y: 0, w: 300, h: 60, style_modifiers: ''),
92
- face: ShapeDefaults.new(type: :face, x: 0, text_only: false, y: 0, w: 100, h: 100, style_modifiers: 'verticalLabelPosition=bottom;verticalAlign=top;shape=mxgraph.basic.smiley'),
93
- triangle: ShapeDefaults.new(type: :triangle, x: 0, text_only: false, y: 0, w: 100, h: 100, style_modifiers: 'triangle'),
94
- embed_row: ShapeDefaults.new(type: :embed_row, x: 0, text_only: false, y: 0, w: 200, h: 40, 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'),
95
- embed_col50: ShapeDefaults.new(type: :embed_col50, x: 0, text_only: false, y: 0, w: 50, h: 40, style_modifiers: 'shape=partialRectangle;connectable=0;top=0;left=0;bottom=0;right=0;fontStyle=1;overflow=hidden'),
96
- embed_col200: ShapeDefaults.new(type: :embed_col200, x: 0, text_only: false, y: 0, w: 150, h: 40, style_modifiers: 'shape=partialRectangle;connectable=0;top=0;left=0;bottom=0;right=0;align=left;spacingLeft=6;overflow=hidden')
58
+ shape: ShapeDefaults.new(type: :shape, category: :element, x: 0, y: 0, w: 20, h: 20, style_modifiers: ''),
59
+ line: ShapeDefaults.new(type: :line, x: 0, category: :line, y: 0, w: 50, h: 50, style_modifiers: 'edgeStyle=none;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0'),
60
+ h1: ShapeDefaults.new(type: :h1, x: 0, category: :text, y: 0, w: 100, h: 50, style_modifiers: 'text;fontSize=89;fontColor=#ffffff;fontStyle=1;fillColor=none'),
61
+ h2: ShapeDefaults.new(type: :h2, x: 0, category: :text, y: 0, w: 100, h: 50, style_modifiers: 'text;fontSize=67;fontColor=#ffffff;fontStyle=1;fillColor=none'),
62
+ h3: ShapeDefaults.new(type: :h3, x: 0, category: :text, y: 0, w: 100, h: 50, style_modifiers: 'text;fontSize=50;fontColor=#ffffff;fontStyle=1;fillColor=none'),
63
+ h4: ShapeDefaults.new(type: :h4, x: 0, category: :text, y: 0, w: 100, h: 50, style_modifiers: 'text;fontSize=37;fontColor=#ffffff;fontStyle=1;fillColor=none'),
64
+ h5: ShapeDefaults.new(type: :h5, x: 0, category: :text, y: 0, w: 100, h: 50, style_modifiers: 'text;fontSize=28;fontColor=#ffffff;fontStyle=1;fillColor=none'),
65
+ h6: ShapeDefaults.new(type: :h6, x: 0, category: :text, y: 0, w: 100, h: 50, style_modifiers: 'text;fontSize=21;fontColor=#ffffff;fontStyle=1;fillColor=none'),
66
+ p: ShapeDefaults.new(type: :p, x: 0, category: :text, y: 0, w: 100, h: 50, style_modifiers: 'text;fontSize=16;fontColor=#ffffff;fontStyle=1;fillColor=none'),
67
+ actor: ShapeDefaults.new(type: :actor, x: 0, category: :element, y: 0, w: 40, h: 50, style_modifiers: 'shape=actor'),
68
+ actor2: ShapeDefaults.new(type: :actor2, x: 0, category: :element, y: 0, w: 30, h: 50, style_modifiers: 'shape=umlActor;verticalLabelPosition=bottom;outlineConnect=1'),
69
+ callout: ShapeDefaults.new(type: :callout, x: 0, category: :element, y: 0, w: 160, h: 120, style_modifiers: 'shape=callout'),
70
+ callout2: ShapeDefaults.new(type: :callout2, x: 0, category: :element, y: 0, w: 160, h: 160, style_modifiers: 'shape=mxgraph.basic.oval_callout'),
71
+ callout3: ShapeDefaults.new(type: :callout3, x: 0, category: :element, y: 0, w: 160, h: 160, style_modifiers: 'shape=mxgraph.basic.cloud_callout'),
72
+ callout4: ShapeDefaults.new(type: :callout4, x: 0, category: :element, y: 0, w: 160, h: 120, style_modifiers: 'shape=mxgraph.basic.roundRectCallout;dx=30;dy=15;size=5;boundedLbl=1;'),
73
+ circle: ShapeDefaults.new(type: :circle, x: 0, category: :element, y: 0, w: 160, h: 160, style_modifiers: 'ellipse'),
74
+ cloud: ShapeDefaults.new(type: :cloud, x: 0, category: :element, y: 0, w: 160, h: 160, style_modifiers: 'shape=cloud'),
75
+ container: ShapeDefaults.new(type: :container, x: 0, category: :element, y: 0, w: 160, h: 160, style_modifiers: 'swimlane'),
76
+ container2: ShapeDefaults.new(type: :container2, x: 0, category: :element, y: 0, w: 160, h: 160, style_modifiers: 'swimlane;horizontal=0'),
77
+ container3: ShapeDefaults.new(type: :container3, x: 0, category: :element, y: 0, w: 160, h: 160, style_modifiers: 'swimlane;startSize=50'),
78
+ container4: ShapeDefaults.new(type: :container4, x: 0, category: :element, y: 0, w: 160, h: 160, style_modifiers: 'swimlane;resizable=0'),
79
+ cross: ShapeDefaults.new(type: :cross, x: 0, category: :element, y: 0, w: 50, h: 50, style_modifiers: 'verticalLabelPosition=bottom;verticalAlign=top;html=1;shape=mxgraph.basic.x'),
80
+ envelop: ShapeDefaults.new(type: :envelop, x: 0, category: :element, y: 0, w: 160, h: 100, style_modifiers: 'shape=message'),
81
+ database: ShapeDefaults.new(type: :database, x: 0, category: :element, y: 0, w: 160, h: 80, style_modifiers: 'shape=mxgraph.flowchart.database;strokeWidth=1'),
82
+ diamond: ShapeDefaults.new(type: :diamond, x: 0, category: :element, y: 0, w: 100, h: 100, style_modifiers: 'rhombus'),
83
+ document: ShapeDefaults.new(type: :document, x: 0, category: :element, y: 0, w: 160, h: 160, style_modifiers: 'shape=mxgraph.basic.document'),
84
+ ellipse: ShapeDefaults.new(type: :ellipse, x: 0, category: :element, y: 0, w: 200, h: 120, style_modifiers: 'ellipse'),
85
+ hexagon: ShapeDefaults.new(type: :hexagon, x: 0, category: :element, y: 0, w: 200, h: 120, style_modifiers: 'shape=hexagon'),
86
+ interface: ShapeDefaults.new(type: :interface, x: 0, category: :element, y: 0, w: 160, h: 160, style_modifiers: 'align=left;overflow=fill;fontSize=12;fontFamily=Helvetica'),
87
+ klass: ShapeDefaults.new(type: :klass, x: 0, category: :element, y: 0, w: 160, h: 160, style_modifiers: 'align=left;overflow=fill;fontSize=12;fontFamily=Helvetica'),
88
+ note: ShapeDefaults.new(type: :note, x: 0, category: :element, y: 0, w: 160, h: 160, style_modifiers: 'shape=note'),
89
+ process: ShapeDefaults.new(type: :process, x: 0, category: :element, y: 0, w: 200, h: 120, style_modifiers: 'shape=process'),
90
+ rectangle: ShapeDefaults.new(type: :rectangle, x: 0, category: :element, y: 0, w: 200, h: 120, style_modifiers: ''),
91
+ rectangle2: ShapeDefaults.new(type: :rectangle2, x: 0, category: :element, y: 0, w: 200, h: 120, style_modifiers: 'shape=mxgraph.basic.cloud_rect'),
92
+ square: ShapeDefaults.new(type: :square, x: 0, category: :element, y: 0, w: 160, h: 160, style_modifiers: ''),
93
+ step: ShapeDefaults.new(type: :step, x: 0, category: :element, y: 0, w: 120, h: 80, style_modifiers: 'shape=step;perimeter=stepPerimeter;fixedSize=1'),
94
+ tick: ShapeDefaults.new(type: :tick, x: 0, category: :element, y: 0, w: 50, h: 50, style_modifiers: 'verticalLabelPosition=bottom;verticalAlign=top;shape=mxgraph.basic.tick'),
95
+ todo: ShapeDefaults.new(type: :todo, x: 0, category: :element, y: 0, w: 300, h: 60, style_modifiers: ''),
96
+ face: ShapeDefaults.new(type: :face, x: 0, category: :element, y: 0, w: 100, h: 100, style_modifiers: 'verticalLabelPosition=bottom;verticalAlign=top;shape=mxgraph.basic.smiley'),
97
+ triangle: ShapeDefaults.new(type: :triangle, x: 0, category: :element, y: 0, w: 100, h: 100, style_modifiers: 'triangle'),
98
+ embed_row: ShapeDefaults.new(type: :embed_row, x: 0, category: :element, y: 0, w: 200, h: 40, 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'),
99
+ embed_col50: ShapeDefaults.new(type: :embed_col50, x: 0, category: :element, y: 0, w: 50, h: 40, style_modifiers: 'shape=partialRectangle;connectable=0;top=0;left=0;bottom=0;right=0;fontStyle=1;overflow=hidden'),
100
+ embed_col200: ShapeDefaults.new(type: :embed_col200, x: 0, category: :element, y: 0, w: 150, h: 40, style_modifiers: 'shape=partialRectangle;connectable=0;top=0;left=0;bottom=0;right=0;align=left;spacingLeft=6;overflow=hidden')
97
101
  )
98
102
  end
99
103
  end
@@ -4,6 +4,12 @@
4
4
  module DrawioDsl
5
5
  # DrawioDsl is a DSL for draw-io diagrams.
6
6
  module DomBuilderShapes
7
+ def add_line(id = nil, **opts, &block)
8
+ opts = { id: id }.merge(opts) if id
9
+ line = DrawioDsl::Schema::Line.new(current_page, **opts, &block)
10
+ add_shape(line)
11
+ end
12
+
7
13
  def add_h1(id = nil, **opts, &block)
8
14
  opts = { id: id }.merge(opts) if id
9
15
  h1 = DrawioDsl::Schema::H1.new(current_page, **opts, &block)
@@ -130,6 +136,12 @@ module DrawioDsl
130
136
  add_shape(envelop)
131
137
  end
132
138
 
139
+ def add_database(id = nil, **opts, &block)
140
+ opts = { id: id }.merge(opts) if id
141
+ database = DrawioDsl::Schema::Database.new(current_page, **opts, &block)
142
+ add_shape(database)
143
+ end
144
+
133
145
  def add_diamond(id = nil, **opts, &block)
134
146
  opts = { id: id }.merge(opts) if id
135
147
  diamond = DrawioDsl::Schema::Diamond.new(current_page, **opts, &block)
@@ -5,90 +5,98 @@ module DrawioDsl
5
5
  # :nocov:
6
6
  module DrawioShapes
7
7
  def random(**opts)
8
- case rand(40)
8
+ case rand(42)
9
9
  when 0
10
- h1(**opts)
10
+ line(**opts)
11
11
  when 1
12
- h2(**opts)
12
+ h1(**opts)
13
13
  when 2
14
- h3(**opts)
14
+ h2(**opts)
15
15
  when 3
16
- h4(**opts)
16
+ h3(**opts)
17
17
  when 4
18
- h5(**opts)
18
+ h4(**opts)
19
19
  when 5
20
- h6(**opts)
20
+ h5(**opts)
21
21
  when 6
22
- p(**opts)
22
+ h6(**opts)
23
23
  when 7
24
- actor(**opts)
24
+ p(**opts)
25
25
  when 8
26
- actor2(**opts)
26
+ actor(**opts)
27
27
  when 9
28
- callout(**opts)
28
+ actor2(**opts)
29
29
  when 10
30
- callout2(**opts)
30
+ callout(**opts)
31
31
  when 11
32
- callout3(**opts)
32
+ callout2(**opts)
33
33
  when 12
34
- callout4(**opts)
34
+ callout3(**opts)
35
35
  when 13
36
- circle(**opts)
36
+ callout4(**opts)
37
37
  when 14
38
- cloud(**opts)
38
+ circle(**opts)
39
39
  when 15
40
- container(**opts)
40
+ cloud(**opts)
41
41
  when 16
42
- container2(**opts)
42
+ container(**opts)
43
43
  when 17
44
- container3(**opts)
44
+ container2(**opts)
45
45
  when 18
46
- container4(**opts)
46
+ container3(**opts)
47
47
  when 19
48
- cross(**opts)
48
+ container4(**opts)
49
49
  when 20
50
- envelop(**opts)
50
+ cross(**opts)
51
51
  when 21
52
- diamond(**opts)
52
+ envelop(**opts)
53
53
  when 22
54
- document(**opts)
54
+ database(**opts)
55
55
  when 23
56
- ellipse(**opts)
56
+ diamond(**opts)
57
57
  when 24
58
- hexagon(**opts)
58
+ document(**opts)
59
59
  when 25
60
- interface(**opts)
60
+ ellipse(**opts)
61
61
  when 26
62
- klass(**opts)
62
+ hexagon(**opts)
63
63
  when 27
64
- note(**opts)
64
+ interface(**opts)
65
65
  when 28
66
- process(**opts)
66
+ klass(**opts)
67
67
  when 29
68
- rectangle(**opts)
68
+ note(**opts)
69
69
  when 30
70
- rectangle2(**opts)
70
+ process(**opts)
71
71
  when 31
72
- square(**opts)
72
+ rectangle(**opts)
73
73
  when 32
74
- step(**opts)
74
+ rectangle2(**opts)
75
75
  when 33
76
- tick(**opts)
76
+ square(**opts)
77
77
  when 34
78
- todo(**opts)
78
+ step(**opts)
79
79
  when 35
80
- face(**opts)
80
+ tick(**opts)
81
81
  when 36
82
- triangle(**opts)
82
+ todo(**opts)
83
83
  when 37
84
- embed_row(**opts)
84
+ face(**opts)
85
85
  when 38
86
- embed_col50(**opts)
86
+ triangle(**opts)
87
87
  when 39
88
+ embed_row(**opts)
89
+ when 40
90
+ embed_col50(**opts)
91
+ when 41
88
92
  embed_col200(**opts)
89
93
  end
90
94
  end
91
95
 
96
+ def line(id = nil, **opts, &block)
97
+ builder.add_line(id, **opts, &block)
98
+ end
99
+
92
100
  def h1(id = nil, **opts, &block)
93
101
  builder.add_h1(id, **opts, &block)
94
102
  end
@@ -173,6 +181,10 @@ module DrawioDsl
173
181
  builder.add_envelop(id, **opts, &block)
174
182
  end
175
183
 
184
+ def database(id = nil, **opts, &block)
185
+ builder.add_database(id, **opts, &block)
186
+ end
187
+
176
188
  def diamond(id = nil, **opts, &block)
177
189
  builder.add_diamond(id, **opts, &block)
178
190
  end
@@ -12,6 +12,7 @@ require_relative 'layouts/flex_layout'
12
12
  require_relative 'layouts/grid_layout'
13
13
 
14
14
  require_relative 'shapes/shape'
15
+ require_relative 'shapes/line'
15
16
  require_relative 'shapes/h1'
16
17
  require_relative 'shapes/h2'
17
18
  require_relative 'shapes/h3'
@@ -33,6 +34,7 @@ require_relative 'shapes/container3'
33
34
  require_relative 'shapes/container4'
34
35
  require_relative 'shapes/cross'
35
36
  require_relative 'shapes/envelop'
37
+ require_relative 'shapes/database'
36
38
  require_relative 'shapes/diamond'
37
39
  require_relative 'shapes/document'
38
40
  require_relative 'shapes/ellipse'
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DrawioDsl
4
+ module Schema
5
+ class Database < Shape
6
+ configure_shape(:database)
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DrawioDsl
4
+ module Schema
5
+ class Line < Shape
6
+ configure_shape(:line)
7
+ end
8
+ end
9
+ end
@@ -23,6 +23,7 @@ module DrawioDsl
23
23
 
24
24
  configure_shape(:shape)
25
25
 
26
+ attr_accessor :category
26
27
  attr_accessor :theme
27
28
  attr_accessor :title
28
29
  attr_accessor :value
@@ -40,13 +41,15 @@ module DrawioDsl
40
41
  attr_accessor :font_color
41
42
  attr_accessor :gradient
42
43
 
43
- attr_accessor :text_only
44
44
  attr_accessor :x
45
45
  attr_accessor :y
46
46
  attr_accessor :w
47
47
  attr_accessor :h
48
48
  attr_accessor :style_modifiers
49
49
 
50
+ attr_accessor :source
51
+ attr_accessor :target
52
+
50
53
  def initialize(page, **args, &block)
51
54
  args[:classification] = :shape
52
55
  super(page, **args)
@@ -76,16 +79,19 @@ module DrawioDsl
76
79
  @glass = args[:glass] || page.style.glass
77
80
 
78
81
  @type = args[:type] || shape_defaults.type
79
- @text_only = args[:text_only] || shape_defaults.text_only
82
+ @category = args[:category] || shape_defaults.category
80
83
  @x = args[:x] || shape_defaults.x
81
84
  @y = args[:y] || shape_defaults.y
82
85
  @w = args[:w] || shape_defaults.w
83
86
  @h = args[:h] || shape_defaults.h
84
87
  @style_modifiers = args[:style_modifiers] || shape_defaults.style_modifiers
85
88
 
86
- @fill_color = args[:fill_color] || (text_only ? nil : theme_palette.fill_color)
87
- @stroke_color = args[:stroke_color] || (text_only ? nil : theme_palette.stroke_color)
88
- @gradient = args[:gradient] || (text_only ? nil : theme_palette.gradient)
89
+ @source = args[:source]
90
+ @target = args[:target]
91
+
92
+ @fill_color = args[:fill_color] || (category == :text ? nil : theme_palette.fill_color)
93
+ @stroke_color = args[:stroke_color] || (category == :text ? nil : theme_palette.stroke_color)
94
+ @gradient = args[:gradient] || (category == :text ? nil : theme_palette.gradient)
89
95
  @font_color = args[:font_color] || theme_palette.font_color
90
96
  end
91
97
 
@@ -113,11 +119,24 @@ module DrawioDsl
113
119
  # rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
114
120
 
115
121
  def as_xml(xml)
122
+ log.error category
123
+ log.error type
124
+ draw_element(xml) if category == :element
125
+ draw_line(xml) if category == :line
126
+ end
127
+
128
+ def draw_element(xml)
116
129
  xml.mxCell(id: id, value: value, style: style, vertex: 1, parent: parent&.id) do
117
130
  xml.mxGeometry(x: x, y: y, width: w, height: h, as: 'geometry')
118
131
  end
119
132
  end
120
133
 
134
+ def draw_line(xml)
135
+ xml.mxCell(id: id, value: value, style: style, parent: parent&.id, source: source, target: target, edge: 1) do
136
+ xml.mxGeometry(relative: 1, as: 'geometry')
137
+ end
138
+ end
139
+
121
140
  def to_h
122
141
  result = {
123
142
  id: id,
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DrawioDsl
4
- VERSION = '0.8.1'
4
+ VERSION = '0.8.4'
5
5
  end
data/package-lock.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "drawio_dsl",
3
- "version": "0.8.1",
3
+ "version": "0.8.4",
4
4
  "lockfileVersion": 2,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "drawio_dsl",
9
- "version": "0.8.1",
9
+ "version": "0.8.4",
10
10
  "devDependencies": {
11
11
  "@klueless-js/semantic-release-rubygem": "github:klueless-js/semantic-release-rubygem",
12
12
  "@semantic-release/changelog": "^6.0.1",
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "drawio_dsl",
3
- "version": "0.8.1",
3
+ "version": "0.8.4",
4
4
  "description": "DrawIO DSL can build DrawIO diagrams using a Domain Specific Language",
5
5
  "scripts": {
6
6
  "release": "semantic-release"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: drawio_dsl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.8.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Cruwys
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-03-16 00:00:00.000000000 Z
11
+ date: 2022-03-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: k_config
@@ -88,6 +88,8 @@ files:
88
88
  - ".builders/generators/02-generate-app.rb"
89
89
  - ".builders/generators/10-transform-drawio-js.rb"
90
90
  - ".builders/generators/20-drawio-extensions.rb"
91
+ - ".builders/generators/domain_diagram.rb"
92
+ - ".builders/generators/printspeak-architecture-generator.rb"
91
93
  - ".builders/generators/project-plan.rb"
92
94
  - ".builders/generators/sample_diagrams/05-samples.rb"
93
95
  - ".builders/generators/sample_diagrams/10-page-margin.rb"
@@ -111,6 +113,8 @@ files:
111
113
  - Rakefile
112
114
  - bin/console
113
115
  - bin/setup
116
+ - docs/domain.drawio
117
+ - docs/domain_model.svg
114
118
  - docs/extensions.md
115
119
  - docs/extensions/analyti_cs.svg
116
120
  - docs/extensions/android_inputs.svg
@@ -329,6 +333,7 @@ files:
329
333
  - lib/drawio_dsl/schema/shapes/container3.rb
330
334
  - lib/drawio_dsl/schema/shapes/container4.rb
331
335
  - lib/drawio_dsl/schema/shapes/cross.rb
336
+ - lib/drawio_dsl/schema/shapes/database.rb
332
337
  - lib/drawio_dsl/schema/shapes/diamond.rb
333
338
  - lib/drawio_dsl/schema/shapes/document.rb
334
339
  - lib/drawio_dsl/schema/shapes/ellipse.rb
@@ -346,6 +351,7 @@ files:
346
351
  - lib/drawio_dsl/schema/shapes/hexagon.rb
347
352
  - lib/drawio_dsl/schema/shapes/interface.rb
348
353
  - lib/drawio_dsl/schema/shapes/klass.rb
354
+ - lib/drawio_dsl/schema/shapes/line.rb
349
355
  - lib/drawio_dsl/schema/shapes/note.rb
350
356
  - lib/drawio_dsl/schema/shapes/p.rb
351
357
  - lib/drawio_dsl/schema/shapes/process.rb