drawio_dsl 0.11.0 → 0.11.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +21 -0
  3. data/config/configuration.json +564 -370
  4. data/docs/domain_model.drawio +89 -89
  5. data/docs/domain_model.json +267 -267
  6. data/docs/printspeak-architecture-controllers-custom.drawio +9 -9
  7. data/docs/printspeak-architecture-controllers.drawio +47 -47
  8. data/docs/printspeak-architecture-generator-custom.drawio +16 -10
  9. data/docs/printspeak-architecture-generator.drawio +268 -0
  10. data/docs/project-plan/project.drawio +89 -89
  11. data/docs/project-plan/project_done.svg +1 -1
  12. data/docs/project-plan/project_in_progress.svg +1 -1
  13. data/docs/project-plan/project_todo.svg +1 -1
  14. data/docs/samples/styles-glass.svg +1 -1
  15. data/docs/samples/styles-plain.svg +1 -1
  16. data/docs/samples/styles-rounded.svg +1 -1
  17. data/docs/samples/styles-shadow.svg +1 -1
  18. data/docs/samples/styles-sketch.svg +1 -1
  19. data/docs/samples/themes-random.svg +1 -1
  20. data/docs/tailwind_domain_model-custom.drawio +104 -0
  21. data/docs/tailwind_domain_model.json +288 -0
  22. data/docs/tailwind_domain_model.svg +3 -0
  23. data/lib/drawio_dsl/configuration.rb +96 -84
  24. data/lib/drawio_dsl/dom_builder.rb +2 -2
  25. data/lib/drawio_dsl/dom_builder_shapes.rb +60 -0
  26. data/lib/drawio_dsl/drawio_shapes.rb +103 -43
  27. data/lib/drawio_dsl/schema/_.rb +10 -0
  28. data/lib/drawio_dsl/schema/diagram.rb +1 -1
  29. data/lib/drawio_dsl/schema/element.rb +4 -0
  30. data/lib/drawio_dsl/schema/layouts/flex_layout.rb +1 -1
  31. data/lib/drawio_dsl/schema/layouts/grid_layout.rb +1 -1
  32. data/lib/drawio_dsl/schema/line.rb +24 -3
  33. data/lib/drawio_dsl/schema/lines/dash_dot.rb +9 -0
  34. data/lib/drawio_dsl/schema/lines/dash_dot_dot.rb +9 -0
  35. data/lib/drawio_dsl/schema/lines/dash_long_dash.rb +9 -0
  36. data/lib/drawio_dsl/schema/lines/dashed.rb +9 -0
  37. data/lib/drawio_dsl/schema/lines/dashed24.rb +9 -0
  38. data/lib/drawio_dsl/schema/lines/dashed32.rb +9 -0
  39. data/lib/drawio_dsl/schema/lines/dashed44.rb +9 -0
  40. data/lib/drawio_dsl/schema/lines/dot_dot_dot.rb +9 -0
  41. data/lib/drawio_dsl/schema/lines/dotted.rb +9 -0
  42. data/lib/drawio_dsl/schema/lines/long_dash.rb +9 -0
  43. data/lib/drawio_dsl/schema/node.rb +5 -5
  44. data/lib/drawio_dsl/schema/shape.rb +14 -9
  45. data/lib/drawio_dsl/schema/text.rb +4 -0
  46. data/lib/drawio_dsl/version.rb +1 -1
  47. data/package-lock.json +2 -2
  48. data/package.json +1 -1
  49. metadata +16 -2
@@ -15,7 +15,7 @@ module DrawioDsl
15
15
  @gap = args[:gap] || 20
16
16
  @perpendicular_max = 0
17
17
 
18
- super(page, **args.merge(type: :flex_layout))
18
+ super(page, **args.merge(key: :flex_layout))
19
19
  end
20
20
 
21
21
  def position_shape(shape)
@@ -24,7 +24,7 @@ module DrawioDsl
24
24
  @v_align = args[:v_align] || :center
25
25
  @cell_no = 1
26
26
 
27
- super(page, **args.merge(type: :grid_layout))
27
+ super(page, **args.merge(key: :grid_layout))
28
28
  end
29
29
  # rubocop:enable Metrics/CyclomaticComplexity
30
30
 
@@ -5,19 +5,40 @@ module DrawioDsl
5
5
  # Text represents lines, usually used for drawing a connection between two elements.
6
6
  class Line < Shape
7
7
  class << self
8
- def configure_as(key)
8
+ attr_reader :default_stroke
9
+
10
+ def configure_as(key, stroke: nil)
9
11
  configure_shape(key, :line)
12
+ @default_stroke = stroke
10
13
  end
11
14
  end
12
15
 
13
16
  attr_accessor :source
14
17
  attr_accessor :target
18
+ attr_accessor :c1 # compass_point1 = :n, :ne, :e, :se, :s, :sw, :w, :nw
19
+ attr_accessor :c2 # compass_point2 = :n, :ne, :e, :se, :s, :sw, :w, :nw
20
+ attr_accessor :stroke
15
21
 
16
22
  def apply_defaults(args)
17
23
  super(args)
18
24
 
19
- @source = args[:source]
20
- @target = args[:target]
25
+ @source = args[:source]
26
+ @target = args[:target]
27
+ @c1 = args[:c1] || :nw
28
+ @c2 = args[:c2] || :ne
29
+ @stroke = args[:stroke] || self.class.default_stroke
30
+ @fill_color = args[:fill_color] || theme_palette.fill_color
31
+ @stroke_color = args[:stroke_color] || theme_palette.stroke_color
32
+ end
33
+
34
+ def default_configuration
35
+ KConfig.configuration.drawio.shape.default_line
36
+ end
37
+
38
+ def base_modifiers
39
+ return @base_modifiers if defined? @base_modifiers
40
+
41
+ @base_modifiers = KConfig.configuration.drawio.stroke(stroke)
21
42
  end
22
43
  end
23
44
  end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DrawioDsl
4
+ module Schema
5
+ class DashDot < Line
6
+ configure_as(:dash_dot, stroke: :dash_dot)
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DrawioDsl
4
+ module Schema
5
+ class DashDotDot < Line
6
+ configure_as(:dash_dot_dot, stroke: :dash_dot_dot)
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DrawioDsl
4
+ module Schema
5
+ class DashLongDash < Line
6
+ configure_as(:dash_long_dash, stroke: :dash_long_dash)
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DrawioDsl
4
+ module Schema
5
+ class Dashed < Line
6
+ configure_as(:dashed, stroke: :dashed)
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DrawioDsl
4
+ module Schema
5
+ class Dashed24 < Line
6
+ configure_as(:dashed24, stroke: :dashed24)
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DrawioDsl
4
+ module Schema
5
+ class Dashed32 < Line
6
+ configure_as(:dashed32, stroke: :dashed32)
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DrawioDsl
4
+ module Schema
5
+ class Dashed44 < Line
6
+ configure_as(:dashed44, stroke: :dashed44)
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DrawioDsl
4
+ module Schema
5
+ class DotDotDot < Line
6
+ configure_as(:dot_dot_dot, stroke: :dot_dot_dot)
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DrawioDsl
4
+ module Schema
5
+ class Dotted < Line
6
+ configure_as(:dotted, stroke: :dotted)
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DrawioDsl
4
+ module Schema
5
+ class LongDash < Line
6
+ configure_as(:long_dash, stroke: :long_dash)
7
+ end
8
+ end
9
+ end
@@ -9,7 +9,7 @@ module DrawioDsl
9
9
  attr_accessor :page
10
10
  attr_accessor :parent
11
11
  attr_accessor :classification
12
- attr_accessor :type
12
+ attr_accessor :key
13
13
  attr_accessor :nodes
14
14
 
15
15
  def initialize(page, **args)
@@ -17,7 +17,7 @@ module DrawioDsl
17
17
  @id = args[:id]
18
18
  @parent = args[:parent]
19
19
  @classification = args[:classification] || :unknown
20
- @type = args[:type] || :unknown
20
+ @key = args[:key] || :unknown
21
21
  @nodes = NodeList.new
22
22
  end
23
23
 
@@ -26,7 +26,7 @@ module DrawioDsl
26
26
  id: id,
27
27
  parent_id: parent&.id,
28
28
  classification: classification,
29
- type: type
29
+ key: key
30
30
  }
31
31
  result[:nodes] = nodes.to_h if nodes.any?
32
32
  result
@@ -58,11 +58,11 @@ module DrawioDsl
58
58
  end
59
59
 
60
60
  # rubocop:disable Metrics/ParameterLists
61
- def debug_row(classification, id, type = nil, x = nil, y = nil, width = nil, height = nil)
61
+ def debug_row(classification, id, key = nil, x = nil, y = nil, width = nil, height = nil)
62
62
  row = []
63
63
  row << classification.to_s.ljust(11)
64
64
  row << id.to_s.ljust(6)
65
- row << (type.nil? ? '' : type).to_s.ljust(15)
65
+ row << (key.nil? ? '' : key).to_s.ljust(15)
66
66
  row << (x.nil? ? '' : x).to_s.rjust(5)
67
67
  row << (y.nil? ? '' : y).to_s.rjust(5)
68
68
  row << (width.nil? ? '' : width).to_s.rjust(5)
@@ -60,7 +60,7 @@ module DrawioDsl
60
60
  end
61
61
 
62
62
  def shape_defaults
63
- @shape_defaults ||= self.class.shape_defaults.clone
63
+ @shape_defaults ||= self.class.shape_defaults || default_configuration
64
64
  end
65
65
 
66
66
  # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
@@ -75,7 +75,7 @@ module DrawioDsl
75
75
  @sketch = args[:sketch] || page.style.sketch
76
76
  @glass = args[:glass] || page.style.glass
77
77
 
78
- @type = args[:type] || shape_defaults.type
78
+ @key = args[:key] || shape_defaults.key
79
79
  @x = args[:x] || shape_defaults.x
80
80
  @y = args[:y] || shape_defaults.y
81
81
  @w = args[:w] || shape_defaults.w
@@ -83,9 +83,9 @@ module DrawioDsl
83
83
  @style_modifiers = args[:style_modifiers] || shape_defaults.style_modifiers
84
84
  end
85
85
 
86
- def format(type = nil)
87
- type ||= self.class.shape_key
88
- format_instance(type)
86
+ def format(key = nil)
87
+ key ||= self.class.shape_key
88
+ format_instance(key)
89
89
  end
90
90
 
91
91
  def style
@@ -100,6 +100,7 @@ module DrawioDsl
100
100
  key_values << "strokeColor=#{stroke_color}" if stroke_color
101
101
  key_values << "fontColor=#{font_color}" if font_color
102
102
  key_values << "gradient=#{gradient}" if gradient
103
+ key_values << base_modifiers unless base_modifiers.empty?
103
104
  key_values << style_modifiers unless style_modifiers.empty?
104
105
 
105
106
  key_values.join(';')
@@ -108,7 +109,7 @@ module DrawioDsl
108
109
 
109
110
  def as_xml(xml)
110
111
  # log.error category
111
- # log.error type
112
+ # log.error key
112
113
  draw_element(xml) if is_a?(Element) || is_a?(Text)
113
114
  draw_line(xml) if is_a?(Line)
114
115
  end
@@ -130,7 +131,7 @@ module DrawioDsl
130
131
  id: id,
131
132
  parent_id: parent&.id,
132
133
  classification: classification,
133
- type: type,
134
+ key: key,
134
135
  x: x,
135
136
  y: y,
136
137
  w: w,
@@ -141,6 +142,10 @@ module DrawioDsl
141
142
  result
142
143
  end
143
144
 
145
+ def base_modifiers
146
+ @base_modifiers ||= ''
147
+ end
148
+
144
149
  def theme_palette
145
150
  @theme_palette ||= KConfig.configuration.drawio.theme.element(theme)
146
151
  end
@@ -153,9 +158,9 @@ module DrawioDsl
153
158
  # :nocov:
154
159
  def debug(format: :detail)
155
160
  if format == :detail
156
- debug_detail({ id: id, classification: classification, type: type })
161
+ debug_detail({ id: id, classification: classification, key: key })
157
162
  else
158
- debug_row(classification, id, type, x, y, w, h)
163
+ debug_row(classification, id, key, x, y, w, h)
159
164
  end
160
165
  end
161
166
  # :nocov:
@@ -18,6 +18,10 @@ module DrawioDsl
18
18
  @gradient = args[:gradient]
19
19
  @font_color = args[:font_color] || page.bg_theme_palette.font_color
20
20
  end
21
+
22
+ def default_configuration
23
+ KConfig.configuration.drawio.shape.default_text
24
+ end
21
25
  end
22
26
  end
23
27
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DrawioDsl
4
- VERSION = '0.11.0'
4
+ VERSION = '0.11.3'
5
5
  end
data/package-lock.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "drawio_dsl",
3
- "version": "0.11.0",
3
+ "version": "0.11.3",
4
4
  "lockfileVersion": 2,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "drawio_dsl",
9
- "version": "0.11.0",
9
+ "version": "0.11.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.11.0",
3
+ "version": "0.11.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.11.0
4
+ version: 0.11.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-25 00:00:00.000000000 Z
11
+ date: 2022-03-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: k_config
@@ -257,6 +257,7 @@ files:
257
257
  - docs/printspeak-architecture-controllers.drawio
258
258
  - docs/printspeak-architecture-generator-custom.drawio
259
259
  - docs/printspeak-architecture-generator-custom.png
260
+ - docs/printspeak-architecture-generator.drawio
260
261
  - docs/printspeak-architecture-generator.svg
261
262
  - docs/project-plan.md
262
263
  - docs/project-plan/project.drawio
@@ -279,6 +280,9 @@ files:
279
280
  - docs/samples/themes-random.svg
280
281
  - docs/samples/themes-square.svg
281
282
  - docs/samples/willoughby-council.svg
283
+ - docs/tailwind_domain_model-custom.drawio
284
+ - docs/tailwind_domain_model.json
285
+ - docs/tailwind_domain_model.svg
282
286
  - lib/drawio_dsl.rb
283
287
  - lib/drawio_dsl/configuration.rb
284
288
  - lib/drawio_dsl/configuration_extension.rb
@@ -343,6 +347,16 @@ files:
343
347
  - lib/drawio_dsl/schema/layouts/grid_layout.rb
344
348
  - lib/drawio_dsl/schema/layouts/layout.rb
345
349
  - lib/drawio_dsl/schema/line.rb
350
+ - lib/drawio_dsl/schema/lines/dash_dot.rb
351
+ - lib/drawio_dsl/schema/lines/dash_dot_dot.rb
352
+ - lib/drawio_dsl/schema/lines/dash_long_dash.rb
353
+ - lib/drawio_dsl/schema/lines/dashed.rb
354
+ - lib/drawio_dsl/schema/lines/dashed24.rb
355
+ - lib/drawio_dsl/schema/lines/dashed32.rb
356
+ - lib/drawio_dsl/schema/lines/dashed44.rb
357
+ - lib/drawio_dsl/schema/lines/dot_dot_dot.rb
358
+ - lib/drawio_dsl/schema/lines/dotted.rb
359
+ - lib/drawio_dsl/schema/lines/long_dash.rb
346
360
  - lib/drawio_dsl/schema/lines/solid.rb
347
361
  - lib/drawio_dsl/schema/node.rb
348
362
  - lib/drawio_dsl/schema/node_list.rb