drawio_dsl 0.5.2 → 0.5.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/.builders/.data/shapes.json +93 -0
  3. data/.builders/.templates/basic/configuration_shapes.rb +3 -3
  4. data/.builders/.templates/basic/schema_require.rb +1 -0
  5. data/.builders/blueprint/shapes.rb +39 -31
  6. data/.builders/boot.rb +1 -0
  7. data/.builders/generators/02-generate-app.rb +2 -0
  8. data/.builders/generators/project_plans/drawio_dsl.rb +57 -0
  9. data/.builders/generators/sample_diagrams/10-page-margin.rb +4 -8
  10. data/.builders/generators/sample_diagrams/15-grid-direction.rb +9 -7
  11. data/.builders/generators/sample_diagrams/16-grid-alignment.rb +6 -9
  12. data/.builders/generators/sample_diagrams/20-styles.rb +43 -45
  13. data/.builders/generators/sample_diagrams/25-themes.rb +21 -8
  14. data/.builders/generators/sample_diagrams/50-willoughby-council.rb +40 -27
  15. data/.rubocop.yml +3 -0
  16. data/CHANGELOG.md +22 -0
  17. data/README.md +4 -3
  18. data/docs/project-plan.md +24 -0
  19. data/docs/project_done.svg +3 -0
  20. data/docs/project_in_progress.svg +3 -0
  21. data/docs/project_todo.svg +3 -0
  22. data/docs/samples/grid-alignment-center.svg +3 -0
  23. data/docs/samples/grid-alignment.svg +3 -0
  24. data/docs/samples/grid-direction-horizontal.svg +3 -0
  25. data/docs/samples/grid-direction-vertical.svg +3 -0
  26. data/docs/samples/samples.md +48 -0
  27. data/docs/samples/styles-glass.svg +3 -0
  28. data/docs/samples/styles-plain.svg +3 -0
  29. data/docs/samples/styles-rounded.svg +3 -0
  30. data/docs/samples/styles-shadow.svg +3 -0
  31. data/docs/samples/styles-sketch.svg +3 -0
  32. data/docs/samples/themes-circle.svg +3 -0
  33. data/docs/samples/themes-random.svg +3 -0
  34. data/docs/samples/themes-square.svg +3 -0
  35. data/docs/samples/willoughby-council.svg +3 -0
  36. data/lib/drawio_dsl/configuration_shapes.rb +46 -34
  37. data/lib/drawio_dsl/dom_builder_shapes.rb +35 -0
  38. data/lib/drawio_dsl/drawio.rb +47 -0
  39. data/lib/drawio_dsl/drawio_shapes.rb +72 -30
  40. data/lib/drawio_dsl/schema/_.rb +7 -0
  41. data/lib/drawio_dsl/schema/layouts/grid_layout.rb +2 -2
  42. data/lib/drawio_dsl/schema/node.rb +29 -24
  43. data/lib/drawio_dsl/schema/shapes/h1.rb +9 -0
  44. data/lib/drawio_dsl/schema/shapes/h2.rb +9 -0
  45. data/lib/drawio_dsl/schema/shapes/h3.rb +9 -0
  46. data/lib/drawio_dsl/schema/shapes/h4.rb +9 -0
  47. data/lib/drawio_dsl/schema/shapes/h5.rb +9 -0
  48. data/lib/drawio_dsl/schema/shapes/h6.rb +9 -0
  49. data/lib/drawio_dsl/schema/shapes/p.rb +9 -0
  50. data/lib/drawio_dsl/schema/shapes/shape.rb +9 -4
  51. data/lib/drawio_dsl/version.rb +1 -1
  52. data/package-lock.json +2 -2
  53. data/package.json +1 -1
  54. metadata +28 -3
  55. data/.builders/generators/sample_diagrams/30-shapes.rb +0 -23
@@ -5,9 +5,16 @@
5
5
  module DrawioDsl
6
6
  # Used to attach configuration to KConfig module
7
7
  module ConfigurationShapes
8
- ShapeDefaults = Struct.new(:type, :x, :y, :w, :h, :style_modifiers, keyword_init: true)
8
+ ShapeDefaults = Struct.new(:type, :text_only, :x, :y, :w, :h, :style_modifiers, keyword_init: true)
9
9
  Shapes = Struct.new(
10
10
  :shape,
11
+ :h1,
12
+ :h2,
13
+ :h3,
14
+ :h4,
15
+ :h5,
16
+ :h6,
17
+ :p,
11
18
  :actor,
12
19
  :actor2,
13
20
  :callout,
@@ -43,39 +50,44 @@ module DrawioDsl
43
50
 
44
51
  def add_shapes
45
52
  @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')
53
+ shape: ShapeDefaults.new(type: :shape, text_only: false, x: 0, y: 0, w: 20, h: 20, style_modifiers: ''),
54
+ 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'),
55
+ 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'),
56
+ 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'),
57
+ 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'),
58
+ 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'),
59
+ 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'),
60
+ 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'),
61
+ actor: ShapeDefaults.new(type: :actor, x: 0, text_only: false, y: 0, w: 40, h: 50, style_modifiers: 'shape=actor'),
62
+ actor2: ShapeDefaults.new(type: :actor2, x: 0, text_only: false, y: 0, w: 30, h: 50, style_modifiers: 'shape=umlActor;verticalLabelPosition=bottom;outlineConnect=1'),
63
+ callout: ShapeDefaults.new(type: :callout, x: 0, text_only: false, y: 0, w: 160, h: 120, style_modifiers: 'shape=callout'),
64
+ callout2: ShapeDefaults.new(type: :callout2, x: 0, text_only: false, y: 0, w: 160, h: 160, style_modifiers: 'shape=mxgraph.basic.oval_callout'),
65
+ callout3: ShapeDefaults.new(type: :callout3, x: 0, text_only: false, y: 0, w: 160, h: 160, style_modifiers: 'shape=mxgraph.basic.cloud_callout'),
66
+ 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;'),
67
+ circle: ShapeDefaults.new(type: :circle, x: 0, text_only: false, y: 0, w: 160, h: 160, style_modifiers: 'ellipse'),
68
+ cloud: ShapeDefaults.new(type: :cloud, x: 0, text_only: false, y: 0, w: 160, h: 160, style_modifiers: 'shape=cloud'),
69
+ 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'),
70
+ envelop: ShapeDefaults.new(type: :envelop, x: 0, text_only: false, y: 0, w: 160, h: 100, style_modifiers: 'shape=message'),
71
+ diamond: ShapeDefaults.new(type: :diamond, x: 0, text_only: false, y: 0, w: 100, h: 100, style_modifiers: 'rhombus'),
72
+ document: ShapeDefaults.new(type: :document, x: 0, text_only: false, y: 0, w: 160, h: 160, style_modifiers: 'shape=mxgraph.basic.document'),
73
+ ellipse: ShapeDefaults.new(type: :ellipse, x: 0, text_only: false, y: 0, w: 200, h: 120, style_modifiers: 'ellipse'),
74
+ hexagon: ShapeDefaults.new(type: :hexagon, x: 0, text_only: false, y: 0, w: 200, h: 120, style_modifiers: 'shape=hexagon'),
75
+ container: ShapeDefaults.new(type: :container, x: 0, text_only: false, y: 0, w: 160, h: 160, style_modifiers: 'swimlane'),
76
+ container2: ShapeDefaults.new(type: :container2, x: 0, text_only: false, y: 0, w: 160, h: 160, style_modifiers: 'swimlane;horizontal=0'),
77
+ container3: ShapeDefaults.new(type: :container3, x: 0, text_only: false, y: 0, w: 160, h: 160, style_modifiers: 'swimlane;startSize=50'),
78
+ container4: ShapeDefaults.new(type: :container4, x: 0, text_only: false, y: 0, w: 160, h: 160, style_modifiers: 'swimlane;resizable=0'),
79
+ note: ShapeDefaults.new(type: :note, x: 0, text_only: false, y: 0, w: 160, h: 160, style_modifiers: 'shape=note'),
80
+ process: ShapeDefaults.new(type: :process, x: 0, text_only: false, y: 0, w: 200, h: 120, style_modifiers: 'shape=process'),
81
+ rectangle: ShapeDefaults.new(type: :rectangle, x: 0, text_only: false, y: 0, w: 200, h: 120, style_modifiers: ''),
82
+ rectangle2: ShapeDefaults.new(type: :rectangle2, x: 0, text_only: false, y: 0, w: 200, h: 120, style_modifiers: 'shape=mxgraph.basic.cloud_rect'),
83
+ square: ShapeDefaults.new(type: :square, x: 0, text_only: false, y: 0, w: 160, h: 160, style_modifiers: ''),
84
+ step: ShapeDefaults.new(type: :step, x: 0, text_only: false, y: 0, w: 120, h: 80, style_modifiers: 'shape=step;perimeter=stepPerimeter;fixedSize=1'),
85
+ 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'),
86
+ 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'),
87
+ triangle: ShapeDefaults.new(type: :triangle, x: 0, text_only: false, y: 0, w: 100, h: 100, style_modifiers: 'triangle'),
88
+ 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'),
89
+ 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'),
90
+ 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')
79
91
  )
80
92
  end
81
93
  end
@@ -4,6 +4,41 @@
4
4
  module DrawioDsl
5
5
  # DrawioDsl is a DSL for draw-io diagrams.
6
6
  module DomBuilderShapes
7
+ def add_h1(**opts)
8
+ h1 = DrawioDsl::Schema::H1.new(current_page, **opts)
9
+ add_shape(h1)
10
+ end
11
+
12
+ def add_h2(**opts)
13
+ h2 = DrawioDsl::Schema::H2.new(current_page, **opts)
14
+ add_shape(h2)
15
+ end
16
+
17
+ def add_h3(**opts)
18
+ h3 = DrawioDsl::Schema::H3.new(current_page, **opts)
19
+ add_shape(h3)
20
+ end
21
+
22
+ def add_h4(**opts)
23
+ h4 = DrawioDsl::Schema::H4.new(current_page, **opts)
24
+ add_shape(h4)
25
+ end
26
+
27
+ def add_h5(**opts)
28
+ h5 = DrawioDsl::Schema::H5.new(current_page, **opts)
29
+ add_shape(h5)
30
+ end
31
+
32
+ def add_h6(**opts)
33
+ h6 = DrawioDsl::Schema::H6.new(current_page, **opts)
34
+ add_shape(h6)
35
+ end
36
+
37
+ def add_p(**opts)
38
+ p = DrawioDsl::Schema::P.new(current_page, **opts)
39
+ add_shape(p)
40
+ end
41
+
7
42
  def add_actor(**opts)
8
43
  actor = DrawioDsl::Schema::Actor.new(current_page, **opts)
9
44
  add_shape(actor)
@@ -5,6 +5,8 @@ module DrawioDsl
5
5
  class Drawio < KDirector::Directors::BaseDirector
6
6
  default_builder_type(DrawioDsl::DomBuilder)
7
7
 
8
+ attr_reader :last_save_file_name
9
+
8
10
  def diagram(**opts)
9
11
  builder.set_diagram(**opts)
10
12
 
@@ -19,6 +21,51 @@ module DrawioDsl
19
21
  layout.call
20
22
  self
21
23
  end
24
+
25
+ def save(file_name, **opts)
26
+ diagram = DrawioDsl::XmlBuilder.new(builder.diagram)
27
+
28
+ add(file_name, content: diagram.build, **opts)
29
+
30
+ # if last_save_file_name is nil then you are not in execute mode
31
+ @last_save_file_name = k_builder.last_output_file
32
+
33
+ self
34
+ end
35
+
36
+ def osave(file_name, **opts)
37
+ save(file_name, **{ open: :write }.merge(opts))
38
+ end
39
+
40
+ def export_svg(output_file_name, page: 1)
41
+ return unless last_save_file_name
42
+ return unless File.exist?(last_save_file_name)
43
+
44
+ page -= 1 # use zero based index
45
+
46
+ output_file_name = "#{output_file_name}.svg" unless output_file_name.end_with?('.svg')
47
+
48
+ command = "/Applications/draw.io.app/Contents/MacOS/draw.io '#{last_save_file_name}' -p #{page} -x -o #{output_file_name}"
49
+
50
+ run_command(command)
51
+
52
+ self
53
+ end
54
+
55
+ def export_png(output_file_name, page: 1)
56
+ return unless last_save_file_name
57
+ return unless File.exist?(last_save_file_name)
58
+
59
+ page -= 1 # use zero based index
60
+
61
+ output_file_name = "#{output_file_name}.png" unless output_file_name.end_with?('.png')
62
+
63
+ command = "/Applications/draw.io.app/Contents/MacOS/draw.io '#{last_save_file_name}' -p #{page} -x -o #{output_file_name}"
64
+
65
+ run_command(command)
66
+
67
+ self
68
+ end
22
69
  end
23
70
 
24
71
  # DrawioDsl::DrawioPage is created when you call .page on the draw-io DSL.
@@ -5,70 +5,112 @@ module DrawioDsl
5
5
  # :nocov:
6
6
  module DrawioShapes
7
7
  def random(**opts)
8
- case rand(30)
8
+ case rand(37)
9
9
  when 0
10
- actor(**opts)
10
+ h1(**opts)
11
11
  when 1
12
- actor2(**opts)
12
+ h2(**opts)
13
13
  when 2
14
- callout(**opts)
14
+ h3(**opts)
15
15
  when 3
16
- callout2(**opts)
16
+ h4(**opts)
17
17
  when 4
18
- callout3(**opts)
18
+ h5(**opts)
19
19
  when 5
20
- callout4(**opts)
20
+ h6(**opts)
21
21
  when 6
22
- circle(**opts)
22
+ p(**opts)
23
23
  when 7
24
- cloud(**opts)
24
+ actor(**opts)
25
25
  when 8
26
- cross(**opts)
26
+ actor2(**opts)
27
27
  when 9
28
- envelop(**opts)
28
+ callout(**opts)
29
29
  when 10
30
- diamond(**opts)
30
+ callout2(**opts)
31
31
  when 11
32
- document(**opts)
32
+ callout3(**opts)
33
33
  when 12
34
- ellipse(**opts)
34
+ callout4(**opts)
35
35
  when 13
36
- hexagon(**opts)
36
+ circle(**opts)
37
37
  when 14
38
- container(**opts)
38
+ cloud(**opts)
39
39
  when 15
40
- container2(**opts)
40
+ cross(**opts)
41
41
  when 16
42
- container3(**opts)
42
+ envelop(**opts)
43
43
  when 17
44
- container4(**opts)
44
+ diamond(**opts)
45
45
  when 18
46
- note(**opts)
46
+ document(**opts)
47
47
  when 19
48
- process(**opts)
48
+ ellipse(**opts)
49
49
  when 20
50
- rectangle(**opts)
50
+ hexagon(**opts)
51
51
  when 21
52
- rectangle2(**opts)
52
+ container(**opts)
53
53
  when 22
54
- square(**opts)
54
+ container2(**opts)
55
55
  when 23
56
- step(**opts)
56
+ container3(**opts)
57
57
  when 24
58
- tick(**opts)
58
+ container4(**opts)
59
59
  when 25
60
- face(**opts)
60
+ note(**opts)
61
61
  when 26
62
- triangle(**opts)
62
+ process(**opts)
63
63
  when 27
64
- embed_row(**opts)
64
+ rectangle(**opts)
65
65
  when 28
66
- embed_col50(**opts)
66
+ rectangle2(**opts)
67
67
  when 29
68
+ square(**opts)
69
+ when 30
70
+ step(**opts)
71
+ when 31
72
+ tick(**opts)
73
+ when 32
74
+ face(**opts)
75
+ when 33
76
+ triangle(**opts)
77
+ when 34
78
+ embed_row(**opts)
79
+ when 35
80
+ embed_col50(**opts)
81
+ when 36
68
82
  embed_col200(**opts)
69
83
  end
70
84
  end
71
85
 
86
+ def h1(**opts)
87
+ builder.add_h1(**opts)
88
+ end
89
+
90
+ def h2(**opts)
91
+ builder.add_h2(**opts)
92
+ end
93
+
94
+ def h3(**opts)
95
+ builder.add_h3(**opts)
96
+ end
97
+
98
+ def h4(**opts)
99
+ builder.add_h4(**opts)
100
+ end
101
+
102
+ def h5(**opts)
103
+ builder.add_h5(**opts)
104
+ end
105
+
106
+ def h6(**opts)
107
+ builder.add_h6(**opts)
108
+ end
109
+
110
+ def p(**opts)
111
+ builder.add_p(**opts)
112
+ end
113
+
72
114
  def actor(**opts)
73
115
  builder.add_actor(**opts)
74
116
  end
@@ -12,6 +12,13 @@ require_relative 'layouts/flex_layout'
12
12
  require_relative 'layouts/grid_layout'
13
13
 
14
14
  require_relative 'shapes/shape'
15
+ require_relative 'shapes/h1'
16
+ require_relative 'shapes/h2'
17
+ require_relative 'shapes/h3'
18
+ require_relative 'shapes/h4'
19
+ require_relative 'shapes/h5'
20
+ require_relative 'shapes/h6'
21
+ require_relative 'shapes/p'
15
22
  require_relative 'shapes/actor'
16
23
  require_relative 'shapes/actor2'
17
24
  require_relative 'shapes/callout'
@@ -88,7 +88,7 @@ module DrawioDsl
88
88
 
89
89
  # Flow down to the next row
90
90
  page.position_x = anchor_x
91
- page.position_y += grid_w
91
+ page.position_y += grid_h
92
92
  @cell_no = 1
93
93
  end
94
94
 
@@ -101,7 +101,7 @@ module DrawioDsl
101
101
 
102
102
  # Flow right to the next column
103
103
  page.position_y = anchor_y
104
- page.position_x += grid_h
104
+ page.position_x += grid_w
105
105
  @cell_no = 1
106
106
  end
107
107
  end
@@ -22,32 +22,37 @@ module DrawioDsl
22
22
  }
23
23
  end
24
24
 
25
- # def debug(format: :detail)
26
- # if format == :detail
27
- # debug_detail(to_h)
28
- # else
29
- # debug_row(classification, id)
30
- # end
31
- # end
25
+ # :nocov:
26
+ # rubocop:disable Metrics/AbcSize
27
+ def debug(format: :detail)
28
+ if format == :detail
29
+ debug_detail(to_h)
30
+ else
31
+ debug_row(classification, id)
32
+ end
33
+ end
32
34
 
33
- # def debug_detail(**key_values)
34
- # key_values.each do |key, value|
35
- # puts "#{key.to_s.ljust(15)}: #{value}"
36
- # end
37
- # end
35
+ def debug_detail(**key_values)
36
+ key_values.each do |key, value|
37
+ puts "#{key.to_s.ljust(15)}: #{value}"
38
+ end
39
+ end
38
40
 
39
- #
40
- # def debug_row(classification, id, type = nil, x = nil, y = nil, width = nil, height = nil)
41
- # row = []
42
- # row << classification.to_s.ljust(11)
43
- # row << id.to_s.ljust(6)
44
- # row << (type.nil? ? '' : type).to_s.ljust(15)
45
- # row << (x.nil? ? '' : x).to_s.rjust(5)
46
- # row << (y.nil? ? '' : y).to_s.rjust(5)
47
- # row << (width.nil? ? '' : width).to_s.rjust(5)
48
- # row << (height.nil? ? '' : height).to_s.rjust(5)
49
- # puts row.join(' | ')
50
- # end
41
+ # rubocop:disable Metrics/ParameterLists
42
+ def debug_row(classification, id, type = nil, x = nil, y = nil, width = nil, height = nil)
43
+ row = []
44
+ row << classification.to_s.ljust(11)
45
+ row << id.to_s.ljust(6)
46
+ row << (type.nil? ? '' : type).to_s.ljust(15)
47
+ row << (x.nil? ? '' : x).to_s.rjust(5)
48
+ row << (y.nil? ? '' : y).to_s.rjust(5)
49
+ row << (width.nil? ? '' : width).to_s.rjust(5)
50
+ row << (height.nil? ? '' : height).to_s.rjust(5)
51
+ puts row.join(' | ')
52
+ end
53
+ # rubocop:enable Metrics/ParameterLists
54
+ # :nocov:
51
55
  end
56
+ # rubocop:enable Metrics/AbcSize
52
57
  end
53
58
  end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DrawioDsl
4
+ module Schema
5
+ class H1 < Shape
6
+ configure_shape(:h1)
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DrawioDsl
4
+ module Schema
5
+ class H2 < Shape
6
+ configure_shape(:h2)
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DrawioDsl
4
+ module Schema
5
+ class H3 < Shape
6
+ configure_shape(:h3)
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DrawioDsl
4
+ module Schema
5
+ class H4 < Shape
6
+ configure_shape(:h4)
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DrawioDsl
4
+ module Schema
5
+ class H5 < Shape
6
+ configure_shape(:h5)
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DrawioDsl
4
+ module Schema
5
+ class H6 < Shape
6
+ configure_shape(:h6)
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DrawioDsl
4
+ module Schema
5
+ class P < Shape
6
+ configure_shape(:p)
7
+ end
8
+ end
9
+ end
@@ -8,7 +8,10 @@ module DrawioDsl
8
8
  attr_reader :shape_defaults
9
9
 
10
10
  def configure_shape(name)
11
- raise "Shape #{name} not found in configuration" unless KConfig.configuration.drawio.shapes.members.include?(name)
11
+ unless KConfig.configuration.drawio.shapes.members.include?(name)
12
+ puts "Shape #{name} not found in configuration"
13
+ return
14
+ end
12
15
 
13
16
  config = KConfig.configuration.drawio.shapes[name]
14
17
 
@@ -35,6 +38,7 @@ module DrawioDsl
35
38
  attr_accessor :gradient
36
39
 
37
40
  attr_accessor :type
41
+ attr_accessor :text_only
38
42
  attr_accessor :x
39
43
  attr_accessor :y
40
44
  attr_accessor :w
@@ -66,16 +70,17 @@ module DrawioDsl
66
70
  @glass = args[:glass] || page.style.glass
67
71
 
68
72
  @type = args[:type] || shape_defaults.type
73
+ @text_only = args[:text_only] || shape_defaults.text_only
69
74
  @x = args[:x] || shape_defaults.x
70
75
  @y = args[:y] || shape_defaults.y
71
76
  @w = args[:w] || shape_defaults.w
72
77
  @h = args[:h] || shape_defaults.h
73
78
  @style_modifiers = args[:style_modifiers] || shape_defaults.style_modifiers
74
79
 
75
- @fill_color = args[:fill_color] || theme_palette.fill_color
76
- @stroke_color = args[:stroke_color] || theme_palette.stroke_color
80
+ @fill_color = args[:fill_color] || (text_only ? nil : theme_palette.fill_color)
81
+ @stroke_color = args[:stroke_color] || (text_only ? nil : theme_palette.stroke_color)
82
+ @gradient = args[:gradient] || (text_only ? nil : theme_palette.gradient)
77
83
  @font_color = args[:font_color] || theme_palette.font_color
78
- @gradient = args[:gradient] || theme_palette.gradient
79
84
  end
80
85
 
81
86
  def style
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DrawioDsl
4
- VERSION = '0.5.2'
4
+ VERSION = '0.5.5'
5
5
  end
data/package-lock.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "drawio_dsl",
3
- "version": "0.5.2",
3
+ "version": "0.5.5",
4
4
  "lockfileVersion": 2,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "drawio_dsl",
9
- "version": "0.5.2",
9
+ "version": "0.5.5",
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.5.2",
3
+ "version": "0.5.5",
4
4
  "description": "DrawIO DSL can build DrawIO diagrams using a Domain Specific Language",
5
5
  "scripts": {
6
6
  "release": "semantic-release"