lutaml 0.9.39 → 0.9.41

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 (89) hide show
  1. checksums.yaml +4 -4
  2. data/README.adoc +7 -1
  3. data/docs/lutaml-express.adoc +35 -0
  4. data/docs/lutaml-sysml.adoc +10 -0
  5. data/docs/lutaml-uml.adoc +111 -0
  6. data/docs/lutaml-xmi.adoc +33 -0
  7. data/exe/lutaml-yaml2uml +1 -1
  8. data/lib/lutaml/command_line.rb +1 -1
  9. data/lib/lutaml/converter/dsl_to_uml.rb +235 -0
  10. data/lib/lutaml/converter/xmi_hash_to_uml.rb +196 -0
  11. data/lib/lutaml/express.rb +0 -1
  12. data/lib/lutaml/formatter/base.rb +7 -7
  13. data/lib/lutaml/formatter/graphviz.rb +19 -8
  14. data/lib/lutaml/formatter.rb +0 -2
  15. data/lib/lutaml/parser.rb +1 -1
  16. data/lib/lutaml/sysml/allocate.rb +1 -1
  17. data/lib/lutaml/sysml/allocated.rb +1 -1
  18. data/lib/lutaml/sysml/binding_connector.rb +1 -1
  19. data/lib/lutaml/sysml/block.rb +1 -1
  20. data/lib/lutaml/sysml/constraint_block.rb +1 -1
  21. data/lib/lutaml/sysml/copy.rb +1 -1
  22. data/lib/lutaml/sysml/derive_requirement.rb +1 -1
  23. data/lib/lutaml/sysml/nested_connector_end.rb +1 -1
  24. data/lib/lutaml/sysml/refine.rb +1 -1
  25. data/lib/lutaml/sysml/requirement_related.rb +1 -1
  26. data/lib/lutaml/sysml/satisfy.rb +1 -1
  27. data/lib/lutaml/sysml/test_case.rb +1 -1
  28. data/lib/lutaml/sysml/trace.rb +1 -1
  29. data/lib/lutaml/sysml/verify.rb +1 -1
  30. data/lib/lutaml/sysml/xmi_file.rb +1 -1
  31. data/lib/lutaml/sysml.rb +0 -1
  32. data/lib/lutaml/uml/action.rb +15 -0
  33. data/lib/lutaml/uml/actor.rb +0 -8
  34. data/lib/lutaml/uml/association.rb +25 -34
  35. data/lib/lutaml/uml/cardinality.rb +10 -0
  36. data/lib/lutaml/uml/class.rb +43 -68
  37. data/lib/lutaml/uml/classifier.rb +5 -3
  38. data/lib/lutaml/uml/connector.rb +5 -8
  39. data/lib/lutaml/uml/connector_end.rb +20 -0
  40. data/lib/lutaml/uml/constraint.rb +11 -1
  41. data/lib/lutaml/uml/data_type.rb +48 -64
  42. data/lib/lutaml/uml/dependency.rb +5 -8
  43. data/lib/lutaml/uml/document.rb +46 -73
  44. data/lib/lutaml/uml/enum.rb +12 -35
  45. data/lib/lutaml/uml/event.rb +0 -1
  46. data/lib/lutaml/uml/fidelity.rb +10 -0
  47. data/lib/lutaml/uml/group.rb +17 -0
  48. data/lib/lutaml/uml/instance.rb +5 -7
  49. data/lib/lutaml/uml/model.rb +3 -3
  50. data/lib/lutaml/uml/namespace.rb +10 -0
  51. data/lib/lutaml/uml/node/base.rb +1 -1
  52. data/lib/lutaml/uml/operation.rb +6 -22
  53. data/lib/lutaml/uml/package.rb +23 -44
  54. data/lib/lutaml/uml/parsers/dsl.rb +5 -2
  55. data/lib/lutaml/uml/parsers/yaml.rb +2 -28
  56. data/lib/lutaml/uml/primitive_type.rb +3 -4
  57. data/lib/lutaml/uml/property.rb +15 -17
  58. data/lib/lutaml/uml/region.rb +0 -1
  59. data/lib/lutaml/uml/state.rb +9 -1
  60. data/lib/lutaml/uml/state_machine.rb +0 -1
  61. data/lib/lutaml/uml/top_element.rb +61 -39
  62. data/lib/lutaml/uml/top_element_attribute.rb +33 -22
  63. data/lib/lutaml/uml/transition.rb +11 -1
  64. data/lib/lutaml/uml/trigger.rb +5 -1
  65. data/lib/lutaml/uml/value.rb +18 -14
  66. data/lib/lutaml/uml.rb +40 -2
  67. data/lib/lutaml/version.rb +1 -1
  68. data/lib/lutaml/xmi/liquid_drops/enum_drop.rb +1 -1
  69. data/lib/lutaml/xmi/liquid_drops/klass_drop.rb +2 -1
  70. data/lib/lutaml/xmi/parsers/xmi_base.rb +20 -2
  71. data/lib/lutaml/xmi/parsers/xml.rb +5 -4
  72. metadata +15 -19
  73. data/lib/lutaml/express/README.adoc +0 -55
  74. data/lib/lutaml/express/version.rb +0 -7
  75. data/lib/lutaml/sysml/README.md +0 -40
  76. data/lib/lutaml/sysml/version.rb +0 -5
  77. data/lib/lutaml/uml/README.adoc +0 -44
  78. data/lib/lutaml/uml/constructor_end.rb +0 -16
  79. data/lib/lutaml/uml/formatter/base.rb +0 -67
  80. data/lib/lutaml/uml/formatter/graphviz.rb +0 -332
  81. data/lib/lutaml/uml/formatter.rb +0 -21
  82. data/lib/lutaml/uml/serializers/association.rb +0 -58
  83. data/lib/lutaml/uml/serializers/base.rb +0 -16
  84. data/lib/lutaml/uml/serializers/class.rb +0 -29
  85. data/lib/lutaml/uml/serializers/top_element_attribute.rb +0 -14
  86. data/lib/lutaml/uml/serializers/yaml_view.rb +0 -18
  87. data/lib/lutaml/uml/version.rb +0 -7
  88. data/lib/lutaml/xmi/README.adoc +0 -24
  89. /data/{LUTAML.adoc → docs/lutaml_syntax.adoc} +0 -0
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Lutaml
4
- module Express
5
- VERSION = "0.2.1"
6
- end
7
- end
@@ -1,40 +0,0 @@
1
- # Lutaml::Sysml
2
-
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/lutaml/sysml`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
6
-
7
- ## Installation
8
-
9
- Add this line to your application's Gemfile:
10
-
11
- ```ruby
12
- gem 'lutaml-sysml'
13
- ```
14
-
15
- And then execute:
16
-
17
- $ bundle install
18
-
19
- Or install it yourself as:
20
-
21
- $ gem install lutaml-sysml
22
-
23
- ## Usage
24
-
25
- TODO: Write usage instructions here
26
-
27
- ## Development
28
-
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
-
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
-
33
- ## Contributing
34
-
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/lutaml-sysml. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/lutaml-sysml/blob/master/CODE_OF_CONDUCT.md).
36
-
37
-
38
- ## Code of Conduct
39
-
40
- Everyone interacting in the Lutaml::Sysml project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/lutaml-sysml/blob/master/CODE_OF_CONDUCT.md).
@@ -1,5 +0,0 @@
1
- module Lutaml
2
- module Sysml
3
- VERSION = "0.1.0".freeze
4
- end
5
- end
@@ -1,44 +0,0 @@
1
- # Lutaml::Uml
2
-
3
- image:https://badge.fury.io/rb/lutaml-uml.svg["Gem Version", link="https://badge.fury.io/rb/lutaml-uml"]
4
-
5
- image:https://github.com/lutaml/lutaml-uml/actions/workflows/macos.yml/badge.svg["macos", link="https://github.com/lutaml/lutaml-uml/actions/workflows/macos.yml"]
6
- image:https://github.com/lutaml/lutaml-uml/actions/workflows/ubuntu.yml/badge.svg["ubuntu", link="https://github.com/lutaml/lutaml-uml/actions/workflows/ubuntu.yml"]
7
- image:https://github.com/lutaml/lutaml-uml/actions/workflows/windows.yml/badge.svg["windows", link="https://github.com/lutaml/lutaml-uml/actions/workflows/windows.yml"]
8
-
9
- Lutaml is a language for specifying UML class diagrams and a tool for converting it into various different formats.
10
-
11
- ## Install
12
-
13
- ### Bundler: `gem "lutaml-uml"`
14
-
15
- ### RubyGems: `gem install lutaml-uml`
16
-
17
- ## Language
18
-
19
- See link:LUTAML.adoc[LUTAML.adoc]
20
-
21
- ## Usage
22
-
23
- Converter executables are available:
24
-
25
- * PlantUML WSD to LutaML UML: `lutaml-wsd2uml`
26
- * LutaML YAML to LutaML UML: `lutaml-yaml2uml`
27
-
28
- EXAMPLE: `lutaml-wsd2uml mn/metanorma-model-standoc/models/StandardDoc_Blocks_New.wsd`
29
-
30
-
31
- ## Development
32
-
33
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
34
-
35
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
36
-
37
- ## Contributing
38
-
39
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/lutaml-uml. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/lutaml-uml/blob/master/CODE_OF_CONDUCT.md).
40
-
41
-
42
- ## Code of Conduct
43
-
44
- Everyone interacting in the Lutaml::Uml project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/lutaml-uml/blob/master/CODE_OF_CONDUCT.md).
@@ -1,16 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- ##
4
- ## Behaviour metamodel
5
- ##
6
- module Lutaml
7
- module Uml
8
- class ConnectorEnd < TopElement
9
- attr_accessor :role, :part_with_port, :connector
10
-
11
- def initialize # rubocop:disable Lint/MissingSuper
12
- @role = nil
13
- end
14
- end
15
- end
16
- end
@@ -1,67 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "lutaml/uml/formatter"
4
- require "lutaml/uml/has_attributes"
5
-
6
- module Lutaml
7
- module Uml
8
- module Formatter
9
- class Base
10
- class << self
11
- def inherited(subclass) # rubocop:disable Lint/MissingSuper
12
- Formatter.all << subclass
13
- end
14
-
15
- def format(node, attributes = {})
16
- new(attributes).format(node)
17
- end
18
-
19
- def name
20
- to_s.split("::").last.downcase.to_sym
21
- end
22
- end
23
-
24
- include HasAttributes
25
-
26
- # rubocop:disable Rails/ActiveRecordAliases
27
- def initialize(attributes = {})
28
- update_attributes(attributes)
29
- end
30
- # rubocop:enable Rails/ActiveRecordAliases
31
-
32
- def name
33
- self.class.name
34
- end
35
-
36
- attr_reader :type
37
-
38
- def type=(value)
39
- @type = value.to_s.strip.downcase.to_sym
40
- end
41
-
42
- def format(node) # rubocop:disable Metrics/CyclomaticComplexity
43
- case node
44
- when Node::Field then format_field(node)
45
- when Node::Method then format_method(node)
46
- when Node::Relationship then format_relationship(node)
47
- when Node::ClassRelationship then format_class_relationship(node)
48
- when Node::ClassNode then format_class(node)
49
- when Lutaml::Uml::Document then format_document(node)
50
- end
51
- end
52
-
53
- def format_field(_node); raise NotImplementedError; end
54
-
55
- def format_method(_node); raise NotImplementedError; end
56
-
57
- def format_relationship(_node); raise NotImplementedError; end
58
-
59
- def format_class_relationship(_node); raise NotImplementedError; end
60
-
61
- def format_class(_node); raise NotImplementedError; end
62
-
63
- def format_document(_node); raise NotImplementedError; end
64
- end
65
- end
66
- end
67
- end
@@ -1,332 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "open3"
4
- require "lutaml/uml/formatter/base"
5
- require "lutaml/layout/graph_viz_engine"
6
-
7
- module Lutaml
8
- module Uml
9
- module Formatter
10
- class Graphviz < Base
11
- class Attributes < Hash
12
- def to_s
13
- to_a
14
- .reject { |(_k, val)| val.nil? }
15
- .map { |(a, b)| "#{a}=#{b.inspect}" }
16
- .join(" ")
17
- end
18
- end
19
-
20
- ACCESS_SYMBOLS = {
21
- "public" => "+",
22
- "protected" => "#",
23
- "private" => "-",
24
- }.freeze
25
- DEFAULT_CLASS_FONT = "Helvetica"
26
-
27
- VALID_TYPES = %i[
28
- dot
29
- xdot
30
- ps
31
- pdf
32
- svg
33
- svgz
34
- fig
35
- png
36
- gif
37
- jpg
38
- jpeg
39
- json
40
- imap
41
- cmapx
42
- ].freeze
43
-
44
- def initialize(attributes = {}) # rubocop:disable Metrics/MethodLength
45
- super
46
-
47
- @graph = Attributes.new
48
- # Associations lines style, `true` gives curved lines
49
- # https://graphviz.org/doc/info/attrs.html#d:splines
50
- @graph["splines"] = "ortho"
51
- # Padding between outside of picture and nodes
52
- @graph["pad"] = 0.5
53
- # Padding between levels
54
- @graph["ranksep"] = "1.2.equally"
55
- # Padding between nodes
56
- @graph["nodesep"] = "1.2.equally"
57
- # TODO: set rankdir
58
- # @graph['rankdir'] = 'BT'
59
-
60
- @edge = Attributes.new
61
- @edge["color"] = "gray50"
62
-
63
- @node = Attributes.new
64
- @node["shape"] = "box"
65
-
66
- @type = :dot
67
- end
68
-
69
- attr_reader :graph, :edge, :node
70
-
71
- def type=(value)
72
- super
73
-
74
- @type = :dot unless VALID_TYPES.include?(@type)
75
- end
76
-
77
- def format(node)
78
- dot = super.lines.map(&:rstrip).join("\n")
79
-
80
- generate_from_dot(dot)
81
- end
82
-
83
- def escape_html_chars(text)
84
- text
85
- .gsub("<", "&#60;")
86
- .gsub(">", "&#62;")
87
- .gsub("[", "&#91;")
88
- .gsub("]", "&#93;")
89
- end
90
-
91
- def format_field(node) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
92
- symbol = ACCESS_SYMBOLS[node.visibility]
93
- result = "#{symbol}#{node.name}"
94
- if node.type
95
- keyword = node.keyword ? "«#{node.keyword}»" : ""
96
- result += " : #{keyword}#{node.type}"
97
- end
98
- if node.cardinality
99
- result += "[#{node.cardinality[:min]}..#{node.cardinality[:max]}]"
100
- end
101
- result = escape_html_chars(result)
102
- result = "<U>#{result}</U>" if node.static
103
-
104
- result
105
- end
106
-
107
- def format_method(node) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength
108
- symbol = ACCESS_SYMBOLS[node.access]
109
- result = "#{symbol} #{node.name}"
110
- if node.arguments
111
- arguments = node.arguments.map do |argument|
112
- "#{argument.name}#{" : #{argument.type}" if argument.type}"
113
- end.join(", ")
114
- end
115
-
116
- result << "(#{arguments})"
117
- result << " : #{node.type}" if node.type
118
- result = "<U>#{result}</U>" if node.static
119
- result = "<I>#{result}</I>" if node.abstract
120
-
121
- result
122
- end
123
-
124
- def format_relationship(node)
125
- graph_parent_name = generate_graph_name(node.owner_end)
126
- graph_node_name = generate_graph_name(node.member_end)
127
- attributes = generate_graph_relationship_attributes(node)
128
- graph_attributes = " [#{attributes}]" unless attributes.empty?
129
-
130
- %{#{graph_parent_name} -> #{graph_node_name}#{graph_attributes}}
131
- end
132
-
133
- def generate_graph_relationship_attributes(node) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
134
- attributes = Attributes.new
135
- if %w[dependency realizes].include?(node.member_end_type)
136
- attributes["style"] = "dashed"
137
- end
138
- attributes["dir"] = if node.owner_end_type && node.member_end_type
139
- "both"
140
- elsif node.owner_end_type
141
- "back"
142
- else
143
- "direct"
144
- end
145
- attributes["label"] = node.action if node.action
146
- if node.owner_end_attribute_name
147
- attributes["headlabel"] = format_label(
148
- node.owner_end_attribute_name,
149
- node.owner_end_cardinality,
150
- )
151
- end
152
- if node.member_end_attribute_name
153
- attributes["taillabel"] = format_label(
154
- node.member_end_attribute_name,
155
- node.member_end_cardinality,
156
- )
157
- end
158
-
159
- attributes["arrowtail"] = case node.owner_end_type
160
- when "composition"
161
- "diamond"
162
- when "aggregation"
163
- "odiamond"
164
- when "direct"
165
- "vee"
166
- else
167
- "onormal"
168
- end
169
-
170
- attributes["arrowhead"] = case node.member_end_type
171
- when "composition"
172
- "diamond"
173
- when "aggregation"
174
- "odiamond"
175
- when "direct"
176
- "vee"
177
- else
178
- "onormal"
179
- end
180
- # swap labels and arrows if `dir` eq to `back`
181
- if attributes["dir"] == "back"
182
- attributes["arrowhead"], attributes["arrowtail"] =
183
- [attributes["arrowtail"], attributes["arrowhead"]]
184
- attributes["headlabel"], attributes["taillabel"] =
185
- [attributes["taillabel"], attributes["headlabel"]]
186
- end
187
- attributes
188
- end
189
-
190
- def format_label(name, cardinality = {})
191
- res = "+#{name}"
192
- if cardinality.nil? ||
193
- (cardinality[:min].nil? || cardinality[:max].nil?)
194
- return res
195
- end
196
-
197
- "#{res} #{cardinality['min']}..#{cardinality['max']}"
198
- end
199
-
200
- def format_member_rows(members, hide_members) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity
201
- unless !hide_members && members&.length&.positive?
202
- return <<~HEREDOC.chomp
203
- <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0">
204
- <TR><TD ALIGN="LEFT"></TD></TR>
205
- </TABLE>
206
- HEREDOC
207
- end
208
-
209
- field_rows = members.map do |field|
210
- %{<TR><TD ALIGN="LEFT">#{format_field(field)}</TD></TR>}
211
- end
212
- field_table = <<~HEREDOC.chomp
213
- <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0">
214
- #{field_rows.map { |row| (' ' * 10) + row }.join("\n")}
215
- </TABLE>
216
- HEREDOC
217
- field_table << "\n" << (" " * 6)
218
- field_table
219
- end
220
-
221
- def format_class(node, hide_members) # rubocop:disable Metrics/AbcSize
222
- name = ["<B>#{node.name}</B>"]
223
- name.unshift("«#{node.keyword}»") if node.keyword
224
- name_html = <<~HEREDOC
225
- <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0">
226
- #{name.map { |n| %(<TR><TD ALIGN="CENTER">#{n}</TD></TR>) }.join('\n')}
227
- </TABLE>
228
- HEREDOC
229
-
230
- field_table = format_member_rows(node.attributes, hide_members)
231
- method_table = format_member_rows(node.methods, hide_members)
232
- table_body = [name_html, field_table, method_table].map do |type|
233
- next if type.nil?
234
-
235
- <<~TEXT
236
- <TR>
237
- <TD>#{type}</TD>
238
- </TR>
239
- TEXT
240
- end
241
-
242
- <<~HEREDOC.chomp
243
- <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="10">
244
- #{table_body.compact.join("\n")}
245
- </TABLE>
246
- HEREDOC
247
- end
248
-
249
- def format_document(node) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
250
- @fontname = node.fontname || DEFAULT_CLASS_FONT
251
- @node["fontname"] = "#{@fontname}-bold"
252
-
253
- if node.fidelity
254
- hide_members = node.fidelity["hideMembers"]
255
- hide_other_classes = node.fidelity["hideOtherClasses"]
256
- end
257
- classes = (node.classes +
258
- node.enums +
259
- node.data_types +
260
- node.primitives).map do |class_node|
261
- graph_node_name = generate_graph_name(class_node.name)
262
-
263
- <<~HEREDOC
264
- #{graph_node_name} [
265
- shape="plain"
266
- fontname="#{@fontname || DEFAULT_CLASS_FONT}"
267
- label=<#{format_class(class_node, hide_members)}>]
268
- HEREDOC
269
- end.join("\n")
270
- associations = node.classes.map(&:associations).compact.flatten +
271
- node.associations
272
- if node.groups
273
- associations = sort_by_document_grouping(node.groups,
274
- associations)
275
- end
276
- classes_names = node.classes.map(&:name)
277
- associations = associations.map do |assoc_node|
278
- if hide_other_classes &&
279
- !classes_names.include?(assoc_node.member_end)
280
- next
281
- end
282
-
283
- format_relationship(assoc_node)
284
- end.join("\n")
285
-
286
- classes = classes.lines.map { |line| " #{line}" }.join.chomp
287
- associations = associations
288
- .lines.map { |line| " #{line}" }.join.chomp
289
-
290
- <<~HEREDOC
291
- digraph G {
292
- graph [#{@graph}]
293
- edge [#{@edge}]
294
- node [#{@node}]
295
-
296
- #{classes}
297
-
298
- #{associations}
299
- }
300
- HEREDOC
301
- end
302
-
303
- protected
304
-
305
- def sort_by_document_grouping(groups, associations) # rubocop:disable Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
306
- result = []
307
- groups.each do |batch|
308
- batch.each do |group_name|
309
- associations
310
- .select { |assc| assc.owner_end == group_name }
311
- .each do |association|
312
- result.push(association) unless result.include?(association)
313
- end
314
- end
315
- end
316
- associations.each do |association|
317
- result.push(association) unless result.include?(association)
318
- end
319
- result
320
- end
321
-
322
- def generate_from_dot(input)
323
- Lutaml::Layout::GraphVizEngine.new(input: input).render(@type)
324
- end
325
-
326
- def generate_graph_name(name)
327
- name.gsub(/[^0-9a-zA-Z]/i, "")
328
- end
329
- end
330
- end
331
- end
332
- end
@@ -1,21 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Lutaml
4
- module Uml
5
- module Formatter
6
- class << self
7
- def all
8
- @all ||= []
9
- end
10
-
11
- def find_by_name(name)
12
- name = name.to_sym
13
-
14
- all.detect { |formatter_class| formatter_class.name == name }
15
- end
16
- end
17
- end
18
- end
19
- end
20
-
21
- require "lutaml/uml/formatter/graphviz"
@@ -1,58 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "lutaml/uml/serializers/base"
4
- require "lutaml/uml/serializers/class"
5
-
6
- module Lutaml
7
- module Uml
8
- module Serializers
9
- class Association < Base
10
- property :member_end, from: :target
11
- property :member_end_attribute_name,
12
- from: "relationship",
13
- transform_with: (lambda do |val|
14
- val.dig("target", "attributes")&.keys&.first ||
15
- val.dig("target", "attribute")&.keys&.first
16
- end)
17
- property :member_end_cardinality,
18
- from: "relationship",
19
- transform_with: (lambda do |val|
20
- res = val.dig("source", "attributes")&.values&.first ||
21
- val.dig("source", "attribute")&.values&.first
22
- res["cardinality"] if res
23
- end)
24
- property :member_end_type,
25
- from: "relationship",
26
- transform_with: (lambda do |val|
27
- val.dig("target", "type")
28
- end)
29
- property :owner_end_attribute_name,
30
- from: "relationship",
31
- transform_with: (lambda do |val|
32
- val.dig("source", "attributes")&.keys&.first ||
33
- val.dig("source", "attribute")&.keys&.first
34
- end)
35
- property :owner_end_cardinality,
36
- from: "relationship",
37
- transform_with: (lambda do |val|
38
- res = val.dig("source", "attributes")&.values&.first ||
39
- val.dig("source", "attribute")&.values&.first
40
- res["cardinality"] if res
41
- end)
42
- property :owner_end_type,
43
- from: "relationship",
44
- transform_with: (lambda do |val|
45
- val.dig("source", "type")
46
- end)
47
- property :action,
48
- transform_with: (lambda do |val|
49
- if val["direction"] == "target"
50
- "#{val['verb']} ▶"
51
- else
52
- "◀ #{val['verb']}"
53
- end
54
- end)
55
- end
56
- end
57
- end
58
- end
@@ -1,16 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "hashie"
4
-
5
- module Lutaml
6
- module Uml
7
- module Serializers
8
- class Base < Hashie::Dash
9
- include Hashie::Extensions::Dash::PropertyTranslation
10
- include Hashie::Extensions::Dash::IndifferentAccess
11
- include Hashie::Extensions::Dash::Coercion
12
- include Hashie::Extensions::IgnoreUndeclared
13
- end
14
- end
15
- end
16
- end
@@ -1,29 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "lutaml/uml/serializers/base"
4
- require "lutaml/uml/serializers/top_element_attribute"
5
- require "lutaml/uml/serializers/association"
6
-
7
- module Lutaml
8
- module Uml
9
- module Serializers
10
- class Class < Base
11
- property :attributes,
12
- transform_with: (lambda do |entry|
13
- entry
14
- .to_a
15
- .map do |(name, attributes)|
16
- attributes.merge(name: name)
17
- end
18
- end)
19
- property :associations,
20
- from: :relations,
21
- coerce: [::Lutaml::Uml::Serializers::Association]
22
- property :name
23
- # property :type, from: :modelType
24
- # property :relations,
25
- # coerce: Array[Relation]
26
- end
27
- end
28
- end
29
- end
@@ -1,14 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "lutaml/uml/serializers/base"
4
-
5
- module Lutaml
6
- module Uml
7
- module Serializers
8
- class TopElementAttribute < Base
9
- property :cardinality
10
- property :type
11
- end
12
- end
13
- end
14
- end
@@ -1,18 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "lutaml/uml/serializers/base"
4
- require "lutaml/uml/serializers/class"
5
-
6
- module Lutaml
7
- module Uml
8
- module Serializers
9
- class YamlView < Base
10
- property :name
11
- property :title
12
- property :caption
13
- property :groups
14
- property :fidelity
15
- end
16
- end
17
- end
18
- end
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Lutaml
4
- module Uml
5
- VERSION = "0.4.3"
6
- end
7
- end