drawio_dsl 0.2.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.builders/.data/shapes.json +82 -0
- data/.builders/.templates/basic/schema_require.rb +16 -0
- data/.builders/.templates/schema_shape.rb +9 -0
- data/.builders/.templates/schema_shape_spec.rb +13 -0
- data/.builders/blueprint/shapes.rb +29 -0
- data/.builders/boot.rb +5 -0
- data/.builders/generators/90-requires.rb +35 -0
- data/.builders/generators/sample_diagrams/10-page-margin.rb +46 -0
- data/.builders/generators/sample_diagrams/15-grid-direction.rb +40 -0
- data/.builders/generators/sample_diagrams/16-grid-alignment.rb +73 -0
- data/.builders/generators/sample_diagrams/20-styles.rb +64 -0
- data/.builders/generators/sample_diagrams/25-themes.rb +24 -0
- data/.rubocop.yml +2 -1
- data/CHANGELOG.md +21 -0
- data/lib/drawio_dsl/configuration.rb +56 -43
- data/lib/drawio_dsl/dom_builder.rb +25 -0
- data/lib/drawio_dsl/drawio.rb +49 -0
- data/lib/drawio_dsl/layout_engine.rb +12 -28
- data/lib/drawio_dsl/schema/_.rb +23 -0
- data/lib/drawio_dsl/schema/common_style.rb +42 -0
- data/lib/drawio_dsl/schema/default_palette.rb +31 -0
- data/lib/drawio_dsl/schema/diagram.rb +57 -0
- data/lib/drawio_dsl/schema/layouts/flex_layout.rb +87 -0
- data/lib/drawio_dsl/schema/layouts/grid_layout.rb +102 -0
- data/lib/drawio_dsl/schema/layouts/layout.rb +41 -0
- data/lib/drawio_dsl/schema/node.rb +53 -0
- data/lib/drawio_dsl/schema/page.rb +135 -0
- data/lib/drawio_dsl/schema/shapes/callout.rb +9 -0
- data/lib/drawio_dsl/schema/shapes/circle.rb +9 -0
- data/lib/drawio_dsl/schema/shapes/cloud.rb +9 -0
- data/lib/drawio_dsl/schema/shapes/diamond.rb +9 -0
- data/lib/drawio_dsl/schema/shapes/ellipse.rb +9 -0
- data/lib/drawio_dsl/schema/shapes/hexagon.rb +9 -0
- data/lib/drawio_dsl/schema/shapes/note.rb +9 -0
- data/lib/drawio_dsl/schema/shapes/process.rb +9 -0
- data/lib/drawio_dsl/schema/shapes/rectangle.rb +9 -0
- data/lib/drawio_dsl/schema/shapes/shape.rb +125 -0
- data/lib/drawio_dsl/schema/shapes/square.rb +9 -0
- data/lib/drawio_dsl/version.rb +1 -1
- data/lib/drawio_dsl.rb +1 -1
- data/package-lock.json +2 -2
- data/package.json +1 -1
- metadata +33 -5
- data/.builders/generators/10-layout.rb +0 -34
- data/lib/drawio_dsl/drawio_dsl-OLD.x +0 -335
- data/lib/drawio_dsl/schema.rb +0 -604
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 43e99df9f899e7c7ebeb6618d9b2018cad1a17abf786cf047d918c1eed513f77
|
4
|
+
data.tar.gz: 2b251a9fa966d5447cc8130b1a1b9a2ac90e7f229b5b1aa0d182a233179ec88e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d0da48b1461fa48072af5674a689dd9beac83fee630cb2cd656c22a3495fdffd062ec3fffa80dfca57478a240557ac70c456c14adc87b31d6dd2d4930d77dc2e
|
7
|
+
data.tar.gz: 6376e89f6e55ff96b644cbdf23f26000facdad358791f9bfa66eeee4bc7193389cc75c6601c3f5a8cc7a51f24c5717f1985dbcdd86214efbb1cadf5eff991b1e
|
@@ -0,0 +1,82 @@
|
|
1
|
+
[
|
2
|
+
{
|
3
|
+
"type": "callout",
|
4
|
+
"x": 0,
|
5
|
+
"y": 0,
|
6
|
+
"w": 160,
|
7
|
+
"h": 160,
|
8
|
+
"style_modifiers": "double=1;shape=callout"
|
9
|
+
},
|
10
|
+
{
|
11
|
+
"type": "circle",
|
12
|
+
"x": 0,
|
13
|
+
"y": 0,
|
14
|
+
"w": 160,
|
15
|
+
"h": 160,
|
16
|
+
"style_modifiers": "double=1;ellipse"
|
17
|
+
},
|
18
|
+
{
|
19
|
+
"type": "cloud",
|
20
|
+
"x": 0,
|
21
|
+
"y": 0,
|
22
|
+
"w": 160,
|
23
|
+
"h": 160,
|
24
|
+
"style_modifiers": "double=1;shape=cloud"
|
25
|
+
},
|
26
|
+
{
|
27
|
+
"type": "diamond",
|
28
|
+
"x": 0,
|
29
|
+
"y": 0,
|
30
|
+
"w": 160,
|
31
|
+
"h": 160,
|
32
|
+
"style_modifiers": "double=1;rhombus"
|
33
|
+
},
|
34
|
+
{
|
35
|
+
"type": "ellipse",
|
36
|
+
"x": 0,
|
37
|
+
"y": 0,
|
38
|
+
"w": 200,
|
39
|
+
"h": 120,
|
40
|
+
"style_modifiers": "double=1;ellipse"
|
41
|
+
},
|
42
|
+
{
|
43
|
+
"type": "hexagon",
|
44
|
+
"x": 0,
|
45
|
+
"y": 0,
|
46
|
+
"w": 200,
|
47
|
+
"h": 120,
|
48
|
+
"style_modifiers": "double=1;shape=hexagon"
|
49
|
+
},
|
50
|
+
{
|
51
|
+
"type": "note",
|
52
|
+
"x": 0,
|
53
|
+
"y": 0,
|
54
|
+
"w": 160,
|
55
|
+
"h": 160,
|
56
|
+
"style_modifiers": "double=1;shape=note"
|
57
|
+
},
|
58
|
+
{
|
59
|
+
"type": "process",
|
60
|
+
"x": 0,
|
61
|
+
"y": 0,
|
62
|
+
"w": 200,
|
63
|
+
"h": 120,
|
64
|
+
"style_modifiers": "double=1;shape=process"
|
65
|
+
},
|
66
|
+
{
|
67
|
+
"type": "rectangle",
|
68
|
+
"x": 0,
|
69
|
+
"y": 0,
|
70
|
+
"w": 200,
|
71
|
+
"h": 120,
|
72
|
+
"style_modifiers": ""
|
73
|
+
},
|
74
|
+
{
|
75
|
+
"type": "square",
|
76
|
+
"x": 0,
|
77
|
+
"y": 0,
|
78
|
+
"w": 160,
|
79
|
+
"h": 160,
|
80
|
+
"style_modifiers": ""
|
81
|
+
}
|
82
|
+
]
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'common_style'
|
4
|
+
require_relative 'default_palette'
|
5
|
+
require_relative 'diagram'
|
6
|
+
require_relative 'node'
|
7
|
+
require_relative 'page'
|
8
|
+
|
9
|
+
require_relative 'layouts/layout'
|
10
|
+
require_relative 'layouts/flex_layout'
|
11
|
+
require_relative 'layouts/grid_layout'
|
12
|
+
|
13
|
+
require_relative 'shapes/shape'
|
14
|
+
{{#each shapes}}
|
15
|
+
require_relative 'shapes/{{snake ./type}}'
|
16
|
+
{{/each}}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
RSpec.describe DrawioDsl::Schema::{{camle type}} do
|
4
|
+
include_context :node_dependencies
|
5
|
+
|
6
|
+
subject { instance }
|
7
|
+
|
8
|
+
let(:instance) { described_class.new(diagram, **args) }
|
9
|
+
let(:args) { { id: 1 } }
|
10
|
+
let(:default) { KConfig.configuration.drawio.shapes.{{snake type}} }
|
11
|
+
|
12
|
+
it_behaves_like :basic_shape_attributes
|
13
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
KManager.model :shapes, namespace: %i[domain] do
|
2
|
+
# microapp = import(:handlebars_helpers, :microapp)
|
3
|
+
|
4
|
+
table :shapes do
|
5
|
+
fields [:type, :x, :y, :w, :h, :style_modifiers]
|
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
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
action do
|
22
|
+
data = self.raw_data
|
23
|
+
shapes = JSON.pretty_generate(data['shapes'])
|
24
|
+
|
25
|
+
k_builder
|
26
|
+
.cd(:data)
|
27
|
+
.add_file('shapes.json', content: shapes, on_exist: :write)
|
28
|
+
end
|
29
|
+
end
|
data/.builders/boot.rb
CHANGED
@@ -45,11 +45,15 @@ KConfig.configure(CONFIG_KEY) do |config|
|
|
45
45
|
base_folder = File.expand_path('../', builder_folder)
|
46
46
|
global_template = File.expand_path('~/dev/kgems/k_templates/templates')
|
47
47
|
|
48
|
+
# Templates
|
48
49
|
config.template_folders.add(:global_template , global_template)
|
49
50
|
config.template_folders.add(:template , File.expand_path('.templates', Dir.pwd))
|
50
51
|
|
52
|
+
# Target Folders
|
51
53
|
config.target_folders.add(:app , base_folder)
|
54
|
+
config.target_folders.add(:lib , :app, 'lib', 'drawio_dsl')
|
52
55
|
config.target_folders.add(:builder , builder_folder)
|
56
|
+
config.target_folders.add(:data , :builder, '.data')
|
53
57
|
end
|
54
58
|
|
55
59
|
KConfig.configuration(CONFIG_KEY).debug
|
@@ -60,6 +64,7 @@ resource_manager
|
|
60
64
|
.fileset
|
61
65
|
.glob('*.rb', exclude: ['boot.rb'])
|
62
66
|
.glob('generators/**/*.rb')
|
67
|
+
.glob('blueprint/**/*.rb')
|
63
68
|
resource_manager.add_resources
|
64
69
|
|
65
70
|
KManager.boot
|
@@ -0,0 +1,35 @@
|
|
1
|
+
KManager.action :requires do
|
2
|
+
# NOT yet working on file change
|
3
|
+
# depend_on(:domain_shapes_kdoc)
|
4
|
+
|
5
|
+
# init do
|
6
|
+
# # context.shapes = import_data(:domain_shapes_kdoc, as: :ostruct)
|
7
|
+
# end
|
8
|
+
|
9
|
+
action do
|
10
|
+
shapes_file = k_builder.target_folders.get_filename(:data, 'shapes.json')
|
11
|
+
shapes = JSON.parse(File.read(shapes_file))
|
12
|
+
puts 'david'
|
13
|
+
KDirector::Dsls::BasicDsl
|
14
|
+
.init(k_builder,
|
15
|
+
on_exist: :write, # %i[skip write compare]
|
16
|
+
on_action: :execute # %i[queue execute]
|
17
|
+
)
|
18
|
+
.blueprint(
|
19
|
+
active: true,
|
20
|
+
name: :bin_hook,
|
21
|
+
description: 'initialize repository',
|
22
|
+
on_exist: :write) do
|
23
|
+
|
24
|
+
cd(:lib)
|
25
|
+
|
26
|
+
add('schema/_.rb.txt', template_file: 'schema_require.rb', shapes: shapes)
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
# # director.play_actions
|
31
|
+
# director.builder.debug
|
32
|
+
# director.debug
|
33
|
+
# director.k_builder.debug
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
KManager.action :bootstrap do
|
2
|
+
action do
|
3
|
+
director = DrawioDsl::Drawio
|
4
|
+
.init(k_builder)
|
5
|
+
.diagram(theme: :style_01)
|
6
|
+
.page('PgMargin-default') do
|
7
|
+
grid_layout(wrap_at: 4)
|
8
|
+
square(title: 'Page Margin 50, 50 (Default)')
|
9
|
+
circle
|
10
|
+
square
|
11
|
+
circle
|
12
|
+
square
|
13
|
+
circle
|
14
|
+
square
|
15
|
+
circle
|
16
|
+
end
|
17
|
+
.page('PgMargin-0-0', margin_left: 0, margin_top: 0) do
|
18
|
+
grid_layout(wrap_at: 4)
|
19
|
+
square(title: 'Page Margin 0, 0')
|
20
|
+
circle
|
21
|
+
square
|
22
|
+
circle
|
23
|
+
square
|
24
|
+
circle
|
25
|
+
square
|
26
|
+
circle
|
27
|
+
end
|
28
|
+
.page('PgMargin-90-70', margin_left: 90, margin_top: 70) do
|
29
|
+
grid_layout(wrap_at: 4)
|
30
|
+
square(title: 'Page Margin 90, 70')
|
31
|
+
circle
|
32
|
+
square
|
33
|
+
circle
|
34
|
+
square
|
35
|
+
circle
|
36
|
+
square
|
37
|
+
circle
|
38
|
+
end
|
39
|
+
|
40
|
+
diagram = DrawioDsl::XmlBuilder.new(director.builder.diagram)
|
41
|
+
|
42
|
+
|
43
|
+
File.write('../spec/.samples/drawio/10-page-margin.xml', diagram.build)
|
44
|
+
File.write('../spec/.samples/drawio/10-page-margin.drawio', diagram.build)
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
KManager.action :bootstrap do
|
2
|
+
action do
|
3
|
+
|
4
|
+
# KConfig.configuration.drawio.square.w = KConfig.configuration.drawio.square.w / 4
|
5
|
+
# KConfig.configuration.drawio.square.h = KConfig.configuration.drawio.square.h / 4
|
6
|
+
# KConfig.configuration.drawio.circle.w = KConfig.configuration.drawio.circle.w / 4
|
7
|
+
# KConfig.configuration.drawio.circle.h = KConfig.configuration.drawio.circle.h / 4
|
8
|
+
# KConfig.configuration.drawio.rectangle.w = KConfig.configuration.drawio.rectangle.w / 4
|
9
|
+
# KConfig.configuration.drawio.rectangle.h = KConfig.configuration.drawio.rectangle.h / 4
|
10
|
+
|
11
|
+
director = DrawioDsl::Drawio
|
12
|
+
.init(k_builder)
|
13
|
+
.diagram(theme: :style_01)
|
14
|
+
.page('Horizontal', margin_left: 0, margin_top: 0) do
|
15
|
+
grid_layout(wrap_at: 3, direction: :horizontal)
|
16
|
+
circle(title: '01')
|
17
|
+
square(title: '02')
|
18
|
+
circle(title: '03')
|
19
|
+
square(title: '04')
|
20
|
+
circle(title: '05')
|
21
|
+
square(title: '06')
|
22
|
+
circle(title: '07')
|
23
|
+
end
|
24
|
+
.page('Vertical', margin_left: 0, margin_top: 0) do
|
25
|
+
grid_layout(wrap_at: 3, direction: :vertical)
|
26
|
+
circle(title: '01')
|
27
|
+
square(title: '02')
|
28
|
+
circle(title: '03')
|
29
|
+
square(title: '04')
|
30
|
+
circle(title: '05')
|
31
|
+
square(title: '06')
|
32
|
+
circle(title: '07')
|
33
|
+
end
|
34
|
+
|
35
|
+
diagram = DrawioDsl::XmlBuilder.new(director.builder.diagram)
|
36
|
+
|
37
|
+
File.write('../spec/.samples/drawio/15-grid-direction.xml', diagram.build)
|
38
|
+
File.write('../spec/.samples/drawio/15-grid-direction.drawio', diagram.build)
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
KManager.action :bootstrap do
|
2
|
+
action do
|
3
|
+
|
4
|
+
# KConfig.configuration.drawio.square.w = KConfig.configuration.drawio.square.w / 4
|
5
|
+
# KConfig.configuration.drawio.square.h = KConfig.configuration.drawio.square.h / 4
|
6
|
+
# KConfig.configuration.drawio.circle.w = KConfig.configuration.drawio.circle.w / 4
|
7
|
+
# KConfig.configuration.drawio.circle.h = KConfig.configuration.drawio.circle.h / 4
|
8
|
+
# KConfig.configuration.drawio.rectangle.w = KConfig.configuration.drawio.rectangle.w / 4
|
9
|
+
# KConfig.configuration.drawio.rectangle.h = KConfig.configuration.drawio.rectangle.h / 4
|
10
|
+
|
11
|
+
director = DrawioDsl::Drawio
|
12
|
+
.init(k_builder,
|
13
|
+
on_exist: :skip, # %i[skip write compare]
|
14
|
+
on_action: :queue # %i[queue execute]
|
15
|
+
)
|
16
|
+
.diagram(theme: :style_01)
|
17
|
+
.page('Grid-Center', margin_left: 0, margin_top: 0) do
|
18
|
+
grid_layout(wrap_at: 3)
|
19
|
+
circle
|
20
|
+
square
|
21
|
+
circle
|
22
|
+
square
|
23
|
+
circle
|
24
|
+
square
|
25
|
+
circle
|
26
|
+
end
|
27
|
+
.page('Grid-Top', margin_left: 0, margin_top: 0) do
|
28
|
+
grid_layout(wrap_at: 3, v_align: :top, h_align: :center)
|
29
|
+
circle
|
30
|
+
square
|
31
|
+
circle
|
32
|
+
square
|
33
|
+
circle
|
34
|
+
square
|
35
|
+
circle
|
36
|
+
end
|
37
|
+
.page('Grid-Bottom', margin_left: 0, margin_top: 0) do
|
38
|
+
grid_layout(wrap_at: 3, v_align: :bottom, h_align: :center)
|
39
|
+
circle
|
40
|
+
square
|
41
|
+
circle
|
42
|
+
square
|
43
|
+
circle
|
44
|
+
square
|
45
|
+
circle
|
46
|
+
end
|
47
|
+
.page('Grid-Left', margin_left: 0, margin_top: 0) do
|
48
|
+
grid_layout(wrap_at: 3, v_align: :center, h_align: :left)
|
49
|
+
circle
|
50
|
+
square
|
51
|
+
circle
|
52
|
+
square
|
53
|
+
circle
|
54
|
+
square
|
55
|
+
circle
|
56
|
+
end
|
57
|
+
.page('Grid-Right', margin_left: 0, margin_top: 0) do
|
58
|
+
grid_layout(wrap_at: 3, v_align: :center, h_align: :right)
|
59
|
+
circle
|
60
|
+
square
|
61
|
+
circle
|
62
|
+
square
|
63
|
+
circle
|
64
|
+
square
|
65
|
+
circle
|
66
|
+
end
|
67
|
+
|
68
|
+
diagram = DrawioDsl::XmlBuilder.new(director.builder.diagram)
|
69
|
+
|
70
|
+
File.write('../spec/.samples/drawio/16-grid-alignment.xml', diagram.build)
|
71
|
+
File.write('../spec/.samples/drawio/16-grid-alignment.drawio', diagram.build)
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,64 @@
|
|
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('Style-Plain', margin_left: 0, margin_top: 0) do
|
9
|
+
grid_layout(wrap_at: 4)
|
10
|
+
circle
|
11
|
+
square
|
12
|
+
circle
|
13
|
+
square
|
14
|
+
circle
|
15
|
+
square
|
16
|
+
circle
|
17
|
+
end
|
18
|
+
.page('Style-Shadow', shadow: 1, margin_left: 0, margin_top: 0) do
|
19
|
+
grid_layout(wrap_at: 4)
|
20
|
+
circle
|
21
|
+
square
|
22
|
+
circle
|
23
|
+
square
|
24
|
+
circle
|
25
|
+
square
|
26
|
+
circle
|
27
|
+
end
|
28
|
+
.page('Style-Rounded', rounded: 1, margin_left: 0, margin_top: 0) do
|
29
|
+
grid_layout(wrap_at: 4)
|
30
|
+
circle
|
31
|
+
square
|
32
|
+
circle
|
33
|
+
square
|
34
|
+
circle
|
35
|
+
square
|
36
|
+
circle
|
37
|
+
end
|
38
|
+
.page('Style-Glass', glass: 1, margin_left: 0, margin_top: 0) do
|
39
|
+
grid_layout(wrap_at: 4)
|
40
|
+
circle
|
41
|
+
square
|
42
|
+
circle
|
43
|
+
square
|
44
|
+
circle
|
45
|
+
square
|
46
|
+
circle
|
47
|
+
end
|
48
|
+
.page('Style-Sketch', sketch: 1, margin_left: 0, margin_top: 0) do
|
49
|
+
grid_layout(wrap_at: 4)
|
50
|
+
circle
|
51
|
+
square
|
52
|
+
circle
|
53
|
+
square
|
54
|
+
circle
|
55
|
+
square
|
56
|
+
circle
|
57
|
+
end
|
58
|
+
|
59
|
+
diagram = DrawioDsl::XmlBuilder.new(director.builder.diagram)
|
60
|
+
|
61
|
+
File.write('../spec/.samples/drawio/20-styles.xml', diagram.build)
|
62
|
+
File.write('../spec/.samples/drawio/20-styles.drawio', diagram.build)
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,24 @@
|
|
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('Style-Plain', margin_left: 0, margin_top: 0) do
|
9
|
+
grid_layout(wrap_at: 5)
|
10
|
+
|
11
|
+
square(title: 'The quick brown fox jumps over the lazy dog')
|
12
|
+
circle(title: 'Mary had a little lamb')
|
13
|
+
|
14
|
+
KConfig.configuration.drawio.themes.keys.each do |theme|
|
15
|
+
random(title: theme.to_s, theme: theme)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
diagram = DrawioDsl::XmlBuilder.new(director.builder.diagram)
|
20
|
+
|
21
|
+
File.write('../spec/.samples/drawio/25-themes.xml', diagram.build)
|
22
|
+
File.write('../spec/.samples/drawio/25-themes.drawio', diagram.build)
|
23
|
+
end
|
24
|
+
end
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,24 @@
|
|
1
|
+
# [0.4.0](https://github.com/klueless-io/drawio_dsl/compare/v0.3.0...v0.4.0) (2022-03-05)
|
2
|
+
|
3
|
+
|
4
|
+
### Features
|
5
|
+
|
6
|
+
* big refactor, plus 98% test coverage ([0d1075c](https://github.com/klueless-io/drawio_dsl/commit/0d1075c177ff1441246950aaa7306ef774ba6df4))
|
7
|
+
|
8
|
+
# [0.3.0](https://github.com/klueless-io/drawio_dsl/compare/v0.2.0...v0.3.0) (2022-03-04)
|
9
|
+
|
10
|
+
|
11
|
+
### Features
|
12
|
+
|
13
|
+
* add samples for direction, alignment, themes, styles and page margin ([2e9f735](https://github.com/klueless-io/drawio_dsl/commit/2e9f735ba50c9391d7dea64c565ca9c0fb61978a))
|
14
|
+
|
15
|
+
# [0.2.0](https://github.com/klueless-io/drawio_dsl/compare/v0.1.0...v0.2.0) (2022-03-04)
|
16
|
+
|
17
|
+
|
18
|
+
### Features
|
19
|
+
|
20
|
+
* update drawio with grid layout engine ([cc5dc51](https://github.com/klueless-io/drawio_dsl/commit/cc5dc51debfd902a815df704fa2dd77f39f498c7))
|
21
|
+
|
1
22
|
# [0.1.0](https://github.com/klueless-io/drawio_dsl/compare/v0.0.1...v0.1.0) (2022-03-02)
|
2
23
|
|
3
24
|
|
@@ -16,38 +16,33 @@ module DrawioDsl
|
|
16
16
|
include KLog::Logging
|
17
17
|
|
18
18
|
BaseStyle = Struct.new(:white_space, :html, :rounded, :shadow, :sketch, :glass, keyword_init: true)
|
19
|
-
|
20
|
-
ShapeDefaults = Struct.new(:type, :x, :y, :w, :h, :style_modifiers)
|
19
|
+
ShapeDefaults = Struct.new(:type, :x, :y, :w, :h, :style_modifiers, keyword_init: true)
|
21
20
|
ShapeThemeStyle = Struct.new(:fill_color, :stroke_color, :font_color, :gradient, keyword_init: true)
|
22
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
|
+
|
23
37
|
attr_accessor :base_style
|
24
38
|
|
25
|
-
# Theme colors
|
26
39
|
attr_accessor :themes
|
27
|
-
|
28
|
-
# Shape shapes
|
29
|
-
attr_accessor :shape
|
30
|
-
attr_accessor :square
|
31
|
-
attr_accessor :rectangle
|
32
|
-
attr_accessor :circle
|
33
|
-
attr_accessor :process
|
34
|
-
attr_accessor :ellipse
|
35
|
-
attr_accessor :triangle
|
36
|
-
attr_accessor :parallelogram
|
37
|
-
attr_accessor :hexagon
|
40
|
+
attr_accessor :shapes
|
38
41
|
|
39
42
|
def initialize
|
40
43
|
@base_style = BaseStyle.new(white_space: :wrap, html: 1, rounded: nil, shadow: nil, sketch: nil, glass: nil)
|
41
44
|
|
42
|
-
|
43
|
-
@square = ShapeDefaults.new(:square , 0, 0, 160, 160, '')
|
44
|
-
@rectangle = ShapeDefaults.new(:rectangle , 0, 0, 200, 120, '')
|
45
|
-
@circle = ShapeDefaults.new(:circle , 0, 0, 160, 160, 'ellipse')
|
46
|
-
@process = ShapeDefaults.new(:process , 0, 0, 200, 120, 'shape=process')
|
47
|
-
@ellipse = ShapeDefaults.new(:ellipse , 0, 0, 200, 120, 'ellipse')
|
48
|
-
@triangle = ShapeDefaults.new(:triangle , 0, 0, 160, 160, 'rhombus')
|
49
|
-
|
50
|
-
@themes = {}
|
45
|
+
add_shapes
|
51
46
|
add_themes
|
52
47
|
end
|
53
48
|
|
@@ -61,12 +56,30 @@ module DrawioDsl
|
|
61
56
|
|
62
57
|
private
|
63
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
|
+
|
64
75
|
def add_theme(name, **opts)
|
65
76
|
@themes[name] = ShapeThemeStyle.new(**opts)
|
66
77
|
end
|
67
78
|
|
68
79
|
# rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
69
80
|
def add_themes
|
81
|
+
@themes = {}
|
82
|
+
|
70
83
|
add_theme(:style_01 , fill_color: '#f5f5f5', stroke_color: '#666666', font_color: '#333333')
|
71
84
|
add_theme(:style_02 , fill_color: '#dae8fc', stroke_color: '#6c8ebf', font_color: '#333333')
|
72
85
|
add_theme(:style_03 , fill_color: '#d5e8d4', stroke_color: '#82b366', font_color: '#333333')
|
@@ -90,26 +103,26 @@ module DrawioDsl
|
|
90
103
|
add_theme(:style_21 , fill_color: '#647687', stroke_color: '#314354', font_color: '#ffffff')
|
91
104
|
add_theme(:style_22 , fill_color: '#76608a', stroke_color: '#432D57', font_color: '#ffffff')
|
92
105
|
add_theme(:style_23 , fill_color: '#a0522d', stroke_color: '#6D1F00', font_color: '#ffffff')
|
93
|
-
add_theme(:style_24 , fill_color: '#fad7ac', stroke_color: '#b46504')
|
94
|
-
add_theme(:style_25 , fill_color: '#fad9d5', stroke_color: '#ae4132')
|
95
|
-
add_theme(:style_26 , fill_color: '#b0e3e6', stroke_color: '#0e8088')
|
96
|
-
add_theme(:style_27 , fill_color: '#b1ddf0', stroke_color: '#10739e')
|
97
|
-
add_theme(:style_28 , fill_color: '#d0cee2', stroke_color: '#56517e')
|
98
|
-
add_theme(:style_29 , fill_color: '#bac8d3', stroke_color: '#23445d')
|
99
|
-
add_theme(:style_30 , fill_color: '#f5f5f5', stroke_color: '#666666', gradient: '#b3b3b3')
|
100
|
-
add_theme(:style_31 , fill_color: '#dae8fc', stroke_color: '#6c8ebf', gradient: '#7ea6e0')
|
101
|
-
add_theme(:style_32 , fill_color: '#d5e8d4', stroke_color: '#82b366', gradient: '#97d077')
|
102
|
-
add_theme(:style_33 , fill_color: '#ffcd28', stroke_color: '#d79b00', gradient: '#ffa500')
|
103
|
-
add_theme(:style_34 , fill_color: '#fff2cc', stroke_color: '#d6b656', gradient: '#ffd966')
|
104
|
-
add_theme(:style_35 , fill_color: '#f8cecc', stroke_color: '#b85450', gradient: '#ea6b66')
|
105
|
-
add_theme(:style_36 , fill_color: '#e6d0de', stroke_color: '#996185', gradient: '#d5739d')
|
106
|
-
add_theme(:style_37 , fill_color: '#eeeeee', stroke_color: '#36393d')
|
107
|
-
add_theme(:style_38 , fill_color: '#f9f7ed', stroke_color: '#36393d')
|
108
|
-
add_theme(:style_39 , fill_color: '#ffcc99', stroke_color: '#36393d')
|
109
|
-
add_theme(:style_40 , fill_color: '#cce5ff', stroke_color: '#36393d')
|
110
|
-
add_theme(:style_41 , fill_color: '#ffff88', stroke_color: '#36393d')
|
111
|
-
add_theme(:style_42 , fill_color: '#cdeb8b', stroke_color: '#36393d')
|
112
|
-
add_theme(:style_43 , fill_color: '#ffcccc', stroke_color: '#36393d')
|
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')
|
113
126
|
end
|
114
127
|
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength
|
115
128
|
end
|