drawio_dsl 0.5.0 → 0.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/.builders/.data/shapes.json +119 -2
  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 +42 -28
  6. data/.builders/generators/02-generate-app.rb +2 -0
  7. data/.builders/generators/project_plans/drawio_dsl.rb +24 -0
  8. data/.builders/generators/sample_diagrams/50-willoughby-council.rb +52 -0
  9. data/.rubocop.yml +5 -0
  10. data/CHANGELOG.md +23 -0
  11. data/lib/drawio_dsl/configuration_shapes.rb +49 -29
  12. data/lib/drawio_dsl/dom_builder.rb +5 -5
  13. data/lib/drawio_dsl/dom_builder_shapes.rb +50 -0
  14. data/lib/drawio_dsl/drawio_shapes.rb +87 -27
  15. data/lib/drawio_dsl/layout_engine.rb +1 -8
  16. data/lib/drawio_dsl/schema/_.rb +11 -0
  17. data/lib/drawio_dsl/schema/layouts/grid_layout.rb +17 -10
  18. data/lib/drawio_dsl/schema/node.rb +29 -24
  19. data/lib/drawio_dsl/schema/node_list.rb +37 -0
  20. data/lib/drawio_dsl/schema/page.rb +5 -5
  21. data/lib/drawio_dsl/schema/shapes/embed_col200.rb +9 -0
  22. data/lib/drawio_dsl/schema/shapes/embed_col50.rb +9 -0
  23. data/lib/drawio_dsl/schema/shapes/embed_row.rb +9 -0
  24. data/lib/drawio_dsl/schema/shapes/h1.rb +9 -0
  25. data/lib/drawio_dsl/schema/shapes/h2.rb +9 -0
  26. data/lib/drawio_dsl/schema/shapes/h3.rb +9 -0
  27. data/lib/drawio_dsl/schema/shapes/h4.rb +9 -0
  28. data/lib/drawio_dsl/schema/shapes/h5.rb +9 -0
  29. data/lib/drawio_dsl/schema/shapes/h6.rb +9 -0
  30. data/lib/drawio_dsl/schema/shapes/p.rb +9 -0
  31. data/lib/drawio_dsl/schema/shapes/shape.rb +15 -4
  32. data/lib/drawio_dsl/version.rb +1 -1
  33. data/lib/drawio_dsl/xml_builder.rb +2 -12
  34. data/package-lock.json +2 -2
  35. data/package.json +1 -1
  36. metadata +15 -2
@@ -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
@@ -96,6 +101,12 @@ module DrawioDsl
96
101
  end
97
102
  # rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
98
103
 
104
+ def as_xml(xml)
105
+ xml.mxCell(id: id, value: title, style: style, vertex: 1, parent: "#{page.id}-B") do
106
+ xml.mxGeometry(x: x, y: y, width: w, height: h, as: 'geometry')
107
+ end
108
+ end
109
+
99
110
  def to_h
100
111
  {
101
112
  id: id,
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DrawioDsl
4
- VERSION = '0.5.0'
4
+ VERSION = '0.5.3'
5
5
  end
@@ -52,23 +52,13 @@ module DrawioDsl
52
52
  xml.root do
53
53
  xml.mxCell(id: "#{page.id}-A")
54
54
  xml.mxCell(id: "#{page.id}-B", parent: "#{page.id}-A")
55
- page.nodes.each do |node|
56
- build_shape(xml, node) if node.classification == :shape
55
+ page.nodes.all.each do |node|
56
+ node.as_xml(xml) if node.classification == :shape
57
57
  end
58
58
  end
59
59
  end
60
60
  end
61
61
  end
62
62
  # rubocop:enable Metrics/MethodLength, Metrics/AbcSize, Metrics/BlockLength
63
-
64
- def build_shape(xml, shape)
65
- # puts "opts: #{opts}"
66
- # puts shape.x
67
- # puts shape.y
68
-
69
- xml.mxCell(id: shape.id, value: shape.title, style: shape.style, vertex: 1, parent: "#{shape.page.id}-B") do
70
- xml.mxGeometry(x: shape.x, y: shape.y, width: shape.w, height: shape.h, as: 'geometry')
71
- end
72
- end
73
63
  end
74
64
  end
data/package-lock.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "drawio_dsl",
3
- "version": "0.5.0",
3
+ "version": "0.5.3",
4
4
  "lockfileVersion": 2,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "drawio_dsl",
9
- "version": "0.5.0",
9
+ "version": "0.5.3",
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.0",
3
+ "version": "0.5.3",
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.5.0
4
+ version: 0.5.3
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-07 00:00:00.000000000 Z
11
+ date: 2022-03-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: k_config
@@ -85,12 +85,14 @@ files:
85
85
  - ".builders/boot.rb"
86
86
  - ".builders/generators/01-bootstrap.rb"
87
87
  - ".builders/generators/02-generate-app.rb"
88
+ - ".builders/generators/project_plans/drawio_dsl.rb"
88
89
  - ".builders/generators/sample_diagrams/10-page-margin.rb"
89
90
  - ".builders/generators/sample_diagrams/15-grid-direction.rb"
90
91
  - ".builders/generators/sample_diagrams/16-grid-alignment.rb"
91
92
  - ".builders/generators/sample_diagrams/20-styles.rb"
92
93
  - ".builders/generators/sample_diagrams/25-themes.rb"
93
94
  - ".builders/generators/sample_diagrams/30-shapes.rb"
95
+ - ".builders/generators/sample_diagrams/50-willoughby-council.rb"
94
96
  - ".releaserc.json"
95
97
  - ".rspec"
96
98
  - ".rubocop.yml"
@@ -122,6 +124,7 @@ files:
122
124
  - lib/drawio_dsl/schema/layouts/grid_layout.rb
123
125
  - lib/drawio_dsl/schema/layouts/layout.rb
124
126
  - lib/drawio_dsl/schema/node.rb
127
+ - lib/drawio_dsl/schema/node_list.rb
125
128
  - lib/drawio_dsl/schema/page.rb
126
129
  - lib/drawio_dsl/schema/shapes/actor.rb
127
130
  - lib/drawio_dsl/schema/shapes/actor2.rb
@@ -139,10 +142,20 @@ files:
139
142
  - lib/drawio_dsl/schema/shapes/diamond.rb
140
143
  - lib/drawio_dsl/schema/shapes/document.rb
141
144
  - lib/drawio_dsl/schema/shapes/ellipse.rb
145
+ - lib/drawio_dsl/schema/shapes/embed_col200.rb
146
+ - lib/drawio_dsl/schema/shapes/embed_col50.rb
147
+ - lib/drawio_dsl/schema/shapes/embed_row.rb
142
148
  - lib/drawio_dsl/schema/shapes/envelop.rb
143
149
  - lib/drawio_dsl/schema/shapes/face.rb
150
+ - lib/drawio_dsl/schema/shapes/h1.rb
151
+ - lib/drawio_dsl/schema/shapes/h2.rb
152
+ - lib/drawio_dsl/schema/shapes/h3.rb
153
+ - lib/drawio_dsl/schema/shapes/h4.rb
154
+ - lib/drawio_dsl/schema/shapes/h5.rb
155
+ - lib/drawio_dsl/schema/shapes/h6.rb
144
156
  - lib/drawio_dsl/schema/shapes/hexagon.rb
145
157
  - lib/drawio_dsl/schema/shapes/note.rb
158
+ - lib/drawio_dsl/schema/shapes/p.rb
146
159
  - lib/drawio_dsl/schema/shapes/process.rb
147
160
  - lib/drawio_dsl/schema/shapes/rectangle.rb
148
161
  - lib/drawio_dsl/schema/shapes/rectangle2.rb