drawio_dsl 0.8.8 → 0.8.9

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 (48) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +7 -0
  3. data/{.builders/.data/shapes.json → config/configuration.json} +49 -49
  4. data/docs/domain-modal/domain_model_custom.drawio +134 -134
  5. data/docs/domain-modal/domain_model_custom.svg +1 -1
  6. data/docs/domain_model.drawio +89 -89
  7. data/docs/domain_model.json +178 -178
  8. data/docs/parking_app.drawio +24 -24
  9. data/docs/parking_app.svg +1 -1
  10. data/docs/printspeak-architecture-generator.drawio +42 -30
  11. data/docs/printspeak-architecture-generator.svg +1 -1
  12. data/docs/project-plan/project.drawio +72 -60
  13. data/docs/project-plan/project_done.svg +1 -1
  14. data/docs/project-plan/project_in_progress.svg +1 -1
  15. data/lib/drawio_dsl/configuration.rb +99 -0
  16. data/lib/drawio_dsl/version.rb +1 -1
  17. data/lib/drawio_dsl.rb +2 -0
  18. data/package-lock.json +2 -2
  19. data/package.json +1 -1
  20. metadata +3 -31
  21. data/.builders/.templates/basic/configuration_shapes.rb +0 -27
  22. data/.builders/.templates/basic/dom_builder_shapes.rb +0 -17
  23. data/.builders/.templates/basic/drawio_extensions.rb +0 -58
  24. data/.builders/.templates/basic/drawio_shapes.rb +0 -23
  25. data/.builders/.templates/basic/schema_require.rb +0 -19
  26. data/.builders/.templates/basic/schema_shape.rb +0 -9
  27. data/.builders/.templates/basic/schema_shape_spec.rb +0 -13
  28. data/.builders/_.rb +0 -1
  29. data/.builders/blueprint/shapes.rb +0 -173
  30. data/.builders/boot.rb +0 -72
  31. data/.builders/generators/01-bootstrap.rb +0 -130
  32. data/.builders/generators/02-generate-app.rb +0 -47
  33. data/.builders/generators/10-transform-drawio-js.rb +0 -195
  34. data/.builders/generators/20-drawio-extensions.rb +0 -41
  35. data/.builders/generators/domain_diagram.rb +0 -474
  36. data/.builders/generators/parking-map.png +0 -0
  37. data/.builders/generators/parking_app.rb +0 -110
  38. data/.builders/generators/printspeak-architecture-generator.rb +0 -45
  39. data/.builders/generators/project-plan.rb +0 -85
  40. data/.builders/generators/sample_diagrams/05-samples.rb +0 -36
  41. data/.builders/generators/sample_diagrams/10-page-margin.rb +0 -42
  42. data/.builders/generators/sample_diagrams/15-grid-direction.rb +0 -34
  43. data/.builders/generators/sample_diagrams/16-grid-alignment.rb +0 -70
  44. data/.builders/generators/sample_diagrams/20-styles.rb +0 -61
  45. data/.builders/generators/sample_diagrams/25-themes.rb +0 -37
  46. data/.builders/generators/sample_diagrams/30-html-shapes.rb +0 -70
  47. data/.builders/generators/sample_diagrams/35-ids-and-arrows.rb +0 -28
  48. data/.builders/generators/sample_diagrams/50-willoughby-council.rb +0 -51
data/.builders/boot.rb DELETED
@@ -1,72 +0,0 @@
1
- # Boot Sequence
2
-
3
- include KLog::Logging
4
-
5
- CONFIG_KEY = :drawio_dsl
6
-
7
- log.kv 'working folder', Dir.pwd
8
-
9
- Handlebars::Helpers.configure do |config|
10
- config.helper_config_file = File.join(Gem.loaded_specs['handlebars-helpers'].full_gem_path, '.handlebars_helpers.json')
11
- config.string_formatter_config_file = File.join(Gem.loaded_specs['handlebars-helpers'].full_gem_path, '.handlebars_string_formatters.json')
12
- end
13
-
14
- def camel
15
- require 'handlebars/helpers/string_formatting/camel'
16
- Handlebars::Helpers::StringFormatting::Camel.new
17
- end
18
-
19
- def titleize
20
- require 'handlebars/helpers/string_formatting/titleize'
21
- Handlebars::Helpers::StringFormatting::Titleize.new
22
- end
23
-
24
- def pluralize
25
- require 'handlebars/helpers/inflection/pluralize'
26
- Handlebars::Helpers::Inflection::Pluralize.new
27
- end
28
-
29
- def singularize
30
- require 'handlebars/helpers/inflection/singularize'
31
- Handlebars::Helpers::Inflection::Singularize.new
32
- end
33
-
34
- def dasherize
35
- require 'handlebars/helpers/string_formatting/dasherize'
36
- Handlebars::Helpers::StringFormatting::Dasherize.new
37
- end
38
-
39
- def k_builder
40
- @k_builder ||= KBuilder::BaseBuilder.init(KConfig.configuration(CONFIG_KEY))
41
- end
42
-
43
- KConfig.configure(CONFIG_KEY) do |config|
44
- builder_folder = Dir.pwd
45
- base_folder = File.expand_path('../', builder_folder)
46
- global_template = File.expand_path('~/dev/kgems/k_templates/templates')
47
-
48
- # Templates
49
- config.template_folders.add(:global_template , global_template)
50
- config.template_folders.add(:template , File.expand_path('.templates', Dir.pwd))
51
-
52
- # Target Folders
53
- config.target_folders.add(:app , base_folder)
54
- config.target_folders.add(:lib , :app, 'lib', 'drawio_dsl')
55
- config.target_folders.add(:spec , :app, 'spec', 'drawio_dsl')
56
- config.target_folders.add(:docs , :app, 'docs')
57
- config.target_folders.add(:builder , builder_folder)
58
- config.target_folders.add(:data , :builder, '.data')
59
- end
60
-
61
- KConfig.configuration(CONFIG_KEY).debug
62
-
63
- area = KManager.add_area(CONFIG_KEY)
64
- resource_manager = area.resource_manager
65
- resource_manager
66
- .fileset
67
- .glob('*.rb', exclude: ['boot.rb'])
68
- .glob('generators/**/*.rb')
69
- .glob('blueprint/**/*.rb')
70
- resource_manager.add_resources
71
-
72
- KManager.boot
@@ -1,130 +0,0 @@
1
- KManager.action :bootstrap do
2
- action do
3
- application_name = :drawio_dsl
4
- director = KDirector::Dsls::RubyGemDsl
5
- .init(k_builder,
6
- on_exist: :skip, # %i[skip write compare]
7
- on_action: :queue # %i[queue execute]
8
- )
9
- .data(
10
- ruby_version: '2.7',
11
- application: application_name,
12
- application_description: 'DrawIO DSL can build DrawIO diagrams using a Domain Specific Language',
13
- application_lib_path: application_name.to_s,
14
- application_lib_namespace: 'DrawioDsl',
15
- namespaces: ['DrawioDsl'],
16
- author: 'David Cruwys',
17
- author_email: 'david@ideasmen.com.au',
18
- initial_semver: '0.0.1',
19
- main_story: 'As a Developer, I to use natural language to build diagrams quickly, so that I can create visual documentation',
20
- copyright_date: '2022',
21
- website: 'http://appydave.com/gems/drawio_dsl'
22
- )
23
- .github(
24
- active: false,
25
- repo_name: application_name
26
- ) do
27
- create_repository
28
- # delete_repository
29
- # list_repositories
30
- open_repository
31
- # run_command('git init')
32
- end
33
- .blueprint(
34
- active: false,
35
- name: :bin_hook,
36
- description: 'initialize repository',
37
- on_exist: :write) do
38
-
39
- cd(:app)
40
-
41
- run_template_script('bin/runonce/git-setup.sh', dom: dom)
42
-
43
- add('.githooks/commit-msg').run_command('chmod +x .githooks/commit-msg')
44
- add('.githooks/pre-commit').run_command('chmod +x .githooks/pre-commit')
45
-
46
- add('.gitignore')
47
-
48
- run_command('git config core.hooksPath .githooks') # enable sharable githooks (developer needs to turn this on before editing rep)
49
-
50
- run_command("git add .; git commit -m 'chore: #{self.options.description.downcase}'; git push")
51
- run_command("gh repo edit -d \"#{dom[:application_description]}\"")
52
- end
53
- .package_json(
54
- active: false,
55
- name: :package_json,
56
- description: 'Set up the package.json file for semantic versioning'
57
- ) do
58
- self
59
- .add('package.json', dom: dom)
60
- .play_actions
61
-
62
- self
63
- .add_script('release', 'semantic-release')
64
- .sort
65
- .development
66
- .npm_add_group('semver-ruby')
67
-
68
- run_command("git add .; git commit -m 'chore: #{self.options.description.downcase}'; git push")
69
- end
70
- .blueprint(
71
- active: false,
72
- name: :opinionated,
73
- description: 'opinionated GEM files',
74
- on_exist: :write) do
75
-
76
- cd(:app)
77
-
78
- add('bin/setup')
79
- add('bin/console')
80
-
81
- add("lib/#{typed_dom.application}.rb" , template_file: 'lib/applet_name.rb' , dom: dom)
82
- add("lib/#{typed_dom.application}/version.rb" , template_file: 'lib/applet_name/version.rb' , dom: dom)
83
-
84
- add('spec/spec_helper.rb')
85
- add("spec/#{typed_dom.application}_spec.rb" , template_file: 'spec/applet_name_spec.rb', dom: dom)
86
-
87
- add("#{typed_dom.application}.gemspec" , template_file: 'applet_name.gemspec', dom: dom)
88
- add('Gemfile', dom: dom)
89
- add('Guardfile', dom: dom)
90
- add('Rakefile', dom: dom)
91
- add('.rspec', dom: dom)
92
- add('.rubocop.yml', dom: dom)
93
- add('README.md', dom: dom)
94
- add('CODE_OF_CONDUCT.md', dom: dom)
95
- add('LICENSE.txt', dom: dom)
96
-
97
- run_command("rubocop -a")
98
-
99
- run_command("git add .; git commit -m 'chore: #{self.options.description.downcase}'; git push")
100
- end
101
- .blueprint(
102
- active: false,
103
- name: :ci_cd,
104
- description: 'github actions (CI/CD)',
105
- on_exist: :write) do
106
-
107
- cd(:app)
108
-
109
- run_command("gh secret set SLACK_WEBHOOK --body \"$SLACK_REPO_WEBHOOK\"")
110
- run_command("gh secret set GEM_HOST_API_KEY --body \"$GEM_HOST_API_KEY\"")
111
-
112
- add('.github/workflows/main.yml')
113
- add('.releaserc.json')
114
-
115
- run_command("git add .; git commit -m 'chore: #{self.options.description.downcase}'; git push")
116
- end
117
-
118
- director.play_actions
119
- # director.builder.logit
120
- end
121
- end
122
-
123
- KManager.opts.app_name = 'drawio_dsl'
124
- KManager.opts.sleep = 2
125
- KManager.opts.reboot_on_kill = 0
126
- KManager.opts.reboot_sleep = 4
127
- KManager.opts.exception_style = :short
128
- KManager.opts.show.time_taken = true
129
- KManager.opts.show.finished = true
130
- KManager.opts.show.finished_message = 'FINISHED :)'
@@ -1,47 +0,0 @@
1
- KManager.action :requires do
2
-
3
- action do
4
- shapes_file = k_builder.target_folders.get_filename(:data, 'shapes.json')
5
- shapes_configuration = JSON.parse(File.read(shapes_file))
6
- shapes = shapes_configuration['shapes']
7
- # strokes = shapes_configuration['strokes']
8
-
9
- KDirector::Dsls::BasicDsl
10
- .init(k_builder,
11
- on_exist: :write, # %i[skip write compare]
12
- on_action: :execute # %i[queue execute]
13
- )
14
- .blueprint(
15
- active: true,
16
- on_exist: :write) do
17
-
18
- cd(:lib)
19
-
20
- add('schema/_.rb', template_file: 'schema_require.rb', shapes: shapes)
21
-
22
- # build source code for each shape
23
- shapes.each do |shape|
24
- add("schema/shapes/#{shape['type']}.rb",
25
- template_file: 'schema_shape.rb',
26
- shape: shape)
27
- end
28
-
29
- add("drawio_shapes.rb" , template_file: 'drawio_shapes.rb' , shapes: shapes, shape_length: shapes.length)
30
- add("dom_builder_shapes.rb" , template_file: 'dom_builder_shapes.rb' , shapes: shapes)
31
- add("configuration_shapes.rb" , template_file: 'configuration_shapes.rb', shapes: shapes)
32
-
33
- cd(:spec)
34
-
35
- # build spec for each shape
36
- shapes.each do |shape|
37
- add("schema/shapes/#{shape['type']}_spec.rb",
38
- template_file: 'schema_shape_spec.rb',
39
- shape: shape)
40
- end
41
-
42
- cd(:app)
43
- run_command('rubocop -a')
44
-
45
- end
46
- end
47
- end
@@ -1,195 +0,0 @@
1
- KManager.action :transform_drawio_js do
2
-
3
- action do
4
- director = KDirector::Dsls::BasicDsl
5
- .init(k_builder,
6
- on_exist: :write, # %i[skip write compare]
7
- on_action: :execute # %i[queue execute]
8
- )
9
- .blueprint do
10
- cd(:data)
11
-
12
- source_file = '/Users/davidcruwys/dev/tools/drawio-desktop/drawio/src/main/webapp/js/diagramly/Extensions.js'
13
- target_file = k_builder.target_folders.get_filename(:data, 'extensions.js')
14
-
15
- clean = CleanExtensionsJs.new(source_file, target_file)
16
-
17
- cd(:lib)
18
-
19
- clean.parse
20
-
21
- add_file('drawio_extensions.json', content: clean.build_json)
22
- add('drawio_extensions.rb', constants: clean.constants, sections: clean.sections)
23
- end
24
- end
25
- end
26
-
27
- class CleanExtensionsJs
28
- def initialize(source_file, target_file)
29
- @source_file = source_file
30
- @target_file = target_file
31
- @source = File.read(@source_file)
32
- @constants = []
33
- @builder = ExtensionJsBuilder.new
34
- end
35
-
36
- def parse
37
- split_source
38
- end
39
-
40
- def build_json
41
- @builder.build_json
42
- end
43
-
44
- def build_ruby
45
- @builder.build_ruby
46
- end
47
-
48
- def constants
49
- @builder.constants.join("\n")
50
- end
51
-
52
- def sections
53
- @builder.sections.select { |s| s[:shapes].length > 0 }
54
- end
55
-
56
- private
57
-
58
- def split_source
59
- source_lines = @source.split("\n")
60
- section = :unknown
61
-
62
- source_lines.each do |line|
63
- if line.include?('// Global import transformation')
64
- section = :constants
65
- next
66
- elsif line.include?('var styleMap = {') && !line.include?('var styleMap = {};')
67
- puts '-----------------------------------'
68
- section = :style_map
69
- next
70
- elsif line.include?('};') ||
71
- line.include?('//Instead of doing a massive code refactoring, thees ugly global variables are used')
72
- section = :unknown
73
- end
74
-
75
- if section == :constants
76
- @builder.process_constant(line)
77
- end
78
-
79
- if section == :style_map
80
- @builder.process_style_map(line)
81
- end
82
- end
83
- end
84
-
85
- def process_style_map(line)
86
- line
87
- end
88
- end
89
-
90
- class ExtensionJsBuilder
91
- attr_accessor :constants
92
- attr_accessor :shapes
93
- attr_accessor :sections
94
- attr_accessor :current_section
95
-
96
- def initialize
97
- @constants = []
98
- @shapes = []
99
- @sections = []
100
- @current_section = nil
101
- end
102
-
103
- def process_constant(line)
104
- line = line.gsub(' ', '').gsub('var ', '').gsub(/;$/, '')
105
- @constants << " #{line}"
106
- end
107
-
108
- def process_style_map(line)
109
- line = clean_line(line)
110
-
111
- return if kill_line(line)
112
-
113
- if line.start_with?('#')
114
- set_section(line)
115
- return
116
- end
117
-
118
- return unless current_section
119
-
120
- parts = process_line(line)
121
-
122
- if parts.length == 2
123
- name = parts[0]
124
- style = parts[1]
125
- current_section[:shapes] << { name: name, style: style }
126
- shapes << line
127
- else
128
- puts 'length not 2'
129
- puts line
130
- end
131
- end
132
-
133
- def process_line(line)
134
- line.split(':').map { |s| s.strip.gsub('"', '') }
135
- end
136
-
137
- def clean_line(line)
138
- line
139
- .strip
140
- .gsub(' ', ' ')
141
- .gsub(' ', ' ')
142
- .gsub(' :', ':')
143
- .gsub("don't", 'do not')
144
- .gsub('//TODO', '')
145
- .gsub(/(\/\/)([^ ])/) do |_|
146
- match = Regexp.last_match
147
- "// #{match[2]}"
148
- end
149
- .gsub("'", '"')
150
- .gsub('not all variants covered', '')
151
- .gsub('Timeline shape', '')
152
- .gsub('# not all variants covered', '')
153
- .gsub('not all versions supported', '')
154
- .gsub('ss + "', '"#{ss}')
155
- .gsub('s + "', '"#{s}')
156
- .gsub('cs,', '#{cs}')
157
- .gsub(/cs$/, '#{cs}')
158
- .gsub('" + containerStyle', '#{containerStyle}"')
159
- .gsub('kupIcon + "', '"#{kupIcon}')
160
- .gsub('gcpIcon + "', '"#{gcpIcon}')
161
- .gsub('azur19 + "', '"#{azur19}')
162
- .gsub('ssAzure + "', '"#{ssAzure}')
163
- .gsub('" + arcSize + "', '#{arcSize}')
164
- .gsub('//', '#')
165
- .gsub(' ', ' ')
166
- .gsub(', #', '')
167
- .strip
168
- .gsub(/,$/, '')
169
- .strip
170
- end
171
-
172
- def kill_line(line)
173
- line.end_with?('NA') ||
174
- line.end_with?('not working properly, needs specific code)') ||
175
- line.start_with?('Timeline shapes are postponed, this code is a work-in-progress') ||
176
- line.start_with?('# *******') ||
177
- line.start_with?('# 2019 mapping') ||
178
- line.include?('# "') ||
179
- line.include?('# "') ||
180
- line.empty?
181
- end
182
-
183
- def set_section(line)
184
- section = line.gsub('#', '').strip
185
- @current_section = {
186
- name: section,
187
- shapes: []
188
- }
189
- @sections << current_section
190
- end
191
-
192
- def build_json
193
- JSON.pretty_generate(@sections)
194
- end
195
- end
@@ -1,41 +0,0 @@
1
- KManager.action :transform_drawio_js do
2
-
3
- action do
4
- director = DrawioDsl::Drawio
5
- .init(k_builder, on_exist: :write, on_action: :execute)
6
- .diagram(theme: :style_10)
7
-
8
- ext = DrawioDsl::DrawioExtensions.new
9
- ext.build_extensions
10
- puts ext.sections.length
11
-
12
- ext.sections.select { |s| s[:active] }.each do |section|
13
- director.page(section[:name]) do
14
- grid_layout(wrap_at: 5)
15
- puts section[:name]
16
- puts section[:shapes]
17
- section[:shapes].select { |s| s[:active] }.each do |shape|
18
- square(title: shape[:name], style_modifiers: shape[:style])
19
- log.kv(:title, shape[:name])
20
- log.kv(:style, shape[:style])
21
- end
22
- end
23
- end
24
- director
25
- .cd(:spec)
26
- .save('.samples/20-extensions.drawio')
27
- .cd(:docs)
28
-
29
- markdown = "# Extensions\n\n"
30
-
31
- director.builder.diagram.pages.each_with_index do |page, index|
32
- page_no = index+1
33
- puts "Page #{page_no}, #{page.name}"
34
- # director.export_svg("extensions/#{page.name}", page: page_no)
35
- markdown += "## #{page.name}\n\n![](./extensions/#{page.name}.svg)\n\n"
36
- end
37
-
38
- director
39
- .add('extensions.md', content: markdown)
40
- end
41
- end