lutaml-uml 0.4.3 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (135) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/release.yml +22 -0
  3. data/Gemfile +1 -5
  4. data/README.adoc +4 -42
  5. data/Rakefile +0 -5
  6. data/lutaml-uml.gemspec +23 -38
  7. metadata +20 -292
  8. data/.github/workflows/macos.yml +0 -38
  9. data/.github/workflows/ubuntu.yml +0 -40
  10. data/.github/workflows/windows.yml +0 -51
  11. data/.gitignore +0 -12
  12. data/.rspec +0 -3
  13. data/.travis.yml +0 -6
  14. data/CODE_OF_CONDUCT.md +0 -74
  15. data/LUTAML.adoc +0 -372
  16. data/bin/console +0 -15
  17. data/bin/folder_yaml2lutaml.sh +0 -6
  18. data/bin/plantuml2lutaml +0 -59
  19. data/bin/setup +0 -8
  20. data/bin/yaml2lutaml +0 -144
  21. data/exe/lutaml-wsd2uml +0 -59
  22. data/exe/lutaml-yaml2uml +0 -144
  23. data/lib/lutaml/layout/engine.rb +0 -15
  24. data/lib/lutaml/layout/graph_viz_engine.rb +0 -19
  25. data/lib/lutaml/uml/abstraction.rb +0 -11
  26. data/lib/lutaml/uml/activity.rb +0 -11
  27. data/lib/lutaml/uml/actor.rb +0 -19
  28. data/lib/lutaml/uml/association.rb +0 -43
  29. data/lib/lutaml/uml/behavior.rb +0 -11
  30. data/lib/lutaml/uml/class.rb +0 -83
  31. data/lib/lutaml/uml/classifier.rb +0 -11
  32. data/lib/lutaml/uml/connector.rb +0 -21
  33. data/lib/lutaml/uml/constraint.rb +0 -12
  34. data/lib/lutaml/uml/constructor_end.rb +0 -16
  35. data/lib/lutaml/uml/data_type.rb +0 -75
  36. data/lib/lutaml/uml/dependency.rb +0 -21
  37. data/lib/lutaml/uml/diagram.rb +0 -8
  38. data/lib/lutaml/uml/document.rb +0 -81
  39. data/lib/lutaml/uml/enum.rb +0 -45
  40. data/lib/lutaml/uml/event.rb +0 -12
  41. data/lib/lutaml/uml/final_state.rb +0 -11
  42. data/lib/lutaml/uml/formatter/base.rb +0 -67
  43. data/lib/lutaml/uml/formatter/graphviz.rb +0 -334
  44. data/lib/lutaml/uml/formatter.rb +0 -21
  45. data/lib/lutaml/uml/has_attributes.rb +0 -14
  46. data/lib/lutaml/uml/has_members.rb +0 -30
  47. data/lib/lutaml/uml/instance.rb +0 -17
  48. data/lib/lutaml/uml/model.rb +0 -13
  49. data/lib/lutaml/uml/node/base.rb +0 -21
  50. data/lib/lutaml/uml/node/class_node.rb +0 -57
  51. data/lib/lutaml/uml/node/class_relationship.rb +0 -14
  52. data/lib/lutaml/uml/node/document.rb +0 -18
  53. data/lib/lutaml/uml/node/field.rb +0 -34
  54. data/lib/lutaml/uml/node/has_name.rb +0 -15
  55. data/lib/lutaml/uml/node/has_type.rb +0 -15
  56. data/lib/lutaml/uml/node/method.rb +0 -29
  57. data/lib/lutaml/uml/node/method_argument.rb +0 -16
  58. data/lib/lutaml/uml/node/relationship.rb +0 -28
  59. data/lib/lutaml/uml/opaque_behavior.rb +0 -11
  60. data/lib/lutaml/uml/operation.rb +0 -31
  61. data/lib/lutaml/uml/package.rb +0 -53
  62. data/lib/lutaml/uml/parsers/attribute.rb +0 -70
  63. data/lib/lutaml/uml/parsers/dsl.rb +0 -413
  64. data/lib/lutaml/uml/parsers/dsl_preprocessor.rb +0 -59
  65. data/lib/lutaml/uml/parsers/dsl_transform.rb +0 -27
  66. data/lib/lutaml/uml/parsers/yaml.rb +0 -46
  67. data/lib/lutaml/uml/port.rb +0 -8
  68. data/lib/lutaml/uml/primitive_type.rb +0 -14
  69. data/lib/lutaml/uml/property.rb +0 -27
  70. data/lib/lutaml/uml/pseudostate.rb +0 -11
  71. data/lib/lutaml/uml/realization.rb +0 -11
  72. data/lib/lutaml/uml/region.rb +0 -12
  73. data/lib/lutaml/uml/serializers/association.rb +0 -58
  74. data/lib/lutaml/uml/serializers/base.rb +0 -16
  75. data/lib/lutaml/uml/serializers/class.rb +0 -29
  76. data/lib/lutaml/uml/serializers/top_element_attribute.rb +0 -14
  77. data/lib/lutaml/uml/serializers/yaml_view.rb +0 -18
  78. data/lib/lutaml/uml/state.rb +0 -12
  79. data/lib/lutaml/uml/state_machine.rb +0 -12
  80. data/lib/lutaml/uml/top_element.rb +0 -58
  81. data/lib/lutaml/uml/top_element_attribute.rb +0 -38
  82. data/lib/lutaml/uml/transition.rb +0 -12
  83. data/lib/lutaml/uml/trigger.rb +0 -12
  84. data/lib/lutaml/uml/value.rb +0 -30
  85. data/lib/lutaml/uml/version.rb +0 -7
  86. data/lib/lutaml/uml/vertex.rb +0 -11
  87. data/lib/lutaml/uml.rb +0 -13
  88. data/spec/fixtures/datamodel/models/AddressClassProfile.yml +0 -90
  89. data/spec/fixtures/datamodel/models/AddressComponentProfile.yml +0 -63
  90. data/spec/fixtures/datamodel/models/AddressComponentSpecification.yml +0 -15
  91. data/spec/fixtures/datamodel/models/AddressProfile.yml +0 -36
  92. data/spec/fixtures/datamodel/models/AttributeProfile.yml +0 -32
  93. data/spec/fixtures/datamodel/models/InterchangeAddressClassProfile.yml +0 -79
  94. data/spec/fixtures/datamodel/models/Localization copy.yml +0 -23
  95. data/spec/fixtures/datamodel/models/Localization.yml +0 -23
  96. data/spec/fixtures/datamodel/models/ProfileCompliantAddress.yml +0 -36
  97. data/spec/fixtures/datamodel/models/ProfileCompliantAddressComponent.yml +0 -15
  98. data/spec/fixtures/datamodel/models/Signature.yml +0 -20
  99. data/spec/fixtures/datamodel/models/SignatureBlankDefinition.yml +0 -20
  100. data/spec/fixtures/datamodel/models/TextDirectionCode copy.yml +0 -16
  101. data/spec/fixtures/datamodel/models/TextDirectionCode.yml +0 -16
  102. data/spec/fixtures/datamodel/models/Validity.yml +0 -14
  103. data/spec/fixtures/datamodel/models/iso19160-1/Address.yml +0 -22
  104. data/spec/fixtures/datamodel/models/iso19160-1/AddressComponent.yml +0 -2
  105. data/spec/fixtures/datamodel/style.uml.inc +0 -37
  106. data/spec/fixtures/datamodel/views/AddressClassProfile.yml +0 -12
  107. data/spec/fixtures/datamodel/views/AddressProfile.yml +0 -3
  108. data/spec/fixtures/datamodel/views/CommonModels.yml +0 -9
  109. data/spec/fixtures/datamodel/views/TopDown.yml +0 -62
  110. data/spec/fixtures/dsl/broken_diagram.lutaml +0 -34
  111. data/spec/fixtures/dsl/diagram.lutaml +0 -3
  112. data/spec/fixtures/dsl/diagram_attributes.lutaml +0 -6
  113. data/spec/fixtures/dsl/diagram_blank_definion.lutaml +0 -6
  114. data/spec/fixtures/dsl/diagram_blank_entities.lutaml +0 -8
  115. data/spec/fixtures/dsl/diagram_class_assocation.lutaml +0 -29
  116. data/spec/fixtures/dsl/diagram_class_fields.lutaml +0 -25
  117. data/spec/fixtures/dsl/diagram_commented_includes.lutaml +0 -5
  118. data/spec/fixtures/dsl/diagram_comments.lutaml +0 -28
  119. data/spec/fixtures/dsl/diagram_concept_model.lutaml +0 -132
  120. data/spec/fixtures/dsl/diagram_data_types.lutaml +0 -44
  121. data/spec/fixtures/dsl/diagram_definitions.lutaml +0 -25
  122. data/spec/fixtures/dsl/diagram_includes.lutaml +0 -6
  123. data/spec/fixtures/dsl/diagram_multiply_classes.lutaml +0 -7
  124. data/spec/fixtures/dsl/diagram_non_existing_include.lutaml +0 -6
  125. data/spec/fixtures/dsl/shared.lutaml +0 -3
  126. data/spec/fixtures/dsl/shared1.lutaml +0 -4
  127. data/spec/fixtures/generated_dot/AddressClassProfile.dot +0 -170
  128. data/spec/fixtures/generated_dot/AddressProfile.dot +0 -34
  129. data/spec/lutaml/layout/graph_viz_engine_spec.rb +0 -31
  130. data/spec/lutaml/uml/formatter/graphviz_spec.rb +0 -41
  131. data/spec/lutaml/uml/parsers/dsl_spec.rb +0 -345
  132. data/spec/lutaml/uml/parsers/yaml_spec.rb +0 -18
  133. data/spec/lutaml/uml/serializers/yaml_view_spec.rb +0 -20
  134. data/spec/lutaml/uml_spec.rb +0 -7
  135. data/spec/spec_helper.rb +0 -25
@@ -1,45 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "lutaml/uml/has_members"
4
- require "lutaml/uml/classifier"
5
- require "lutaml/uml/association"
6
- require "lutaml/uml/top_element_attribute"
7
- require "lutaml/uml/value"
8
-
9
- module Lutaml
10
- module Uml
11
- class Enum < Classifier
12
- include HasMembers
13
-
14
- attr_reader :attributes,
15
- :members,
16
- :modifier,
17
- :definition,
18
- :keyword,
19
- :values
20
-
21
- def initialize(attributes = {})
22
- super
23
- @keyword = "enumeration"
24
- end
25
-
26
- # TODO: delete?
27
- def attributes=(value)
28
- @attributes = value.to_a.map do |attr|
29
- TopElementAttribute.new(attr)
30
- end
31
- end
32
-
33
- def values=(value)
34
- @values = value.to_a.map do |attr|
35
- Value.new(attr)
36
- end
37
- end
38
-
39
- # TODO: reserved name, change
40
- def methods
41
- []
42
- end
43
- end
44
- end
45
- end
@@ -1,12 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- ##
4
- ## Behaviour metamodel
5
- ##
6
-
7
- module Lutaml
8
- module Uml
9
- class Event < TopElement
10
- end
11
- end
12
- end
@@ -1,11 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- ##
4
- ## Behaviour metamodel
5
- ##
6
- module Lutaml
7
- module Uml
8
- class FinalState < State
9
- end
10
- end
11
- 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)
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)
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,334 +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".freeze
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 = {})
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
70
- attr_reader :edge
71
- attr_reader :node
72
-
73
- def type=(value)
74
- super
75
-
76
- @type = :dot unless VALID_TYPES.include?(@type)
77
- end
78
-
79
- def format(node)
80
- dot = super.lines.map(&:rstrip).join("\n")
81
-
82
- generate_from_dot(dot)
83
- end
84
-
85
- def escape_html_chars(text)
86
- text
87
- .gsub(/</, "&#60;")
88
- .gsub(/>/, "&#62;")
89
- .gsub(/\[/, "&#91;")
90
- .gsub(/\]/, "&#93;")
91
- end
92
-
93
- def format_field(node)
94
- symbol = ACCESS_SYMBOLS[node.visibility]
95
- result = "#{symbol}#{node.name}"
96
- if node.type
97
- keyword = node.keyword ? "«#{node.keyword}»" : ""
98
- result += " : #{keyword}#{node.type}"
99
- end
100
- if node.cardinality
101
- result += "[#{node.cardinality[:min]}..#{node.cardinality[:max]}]"
102
- end
103
- result = escape_html_chars(result)
104
- result = "<U>#{result}</U>" if node.static
105
-
106
- result
107
- end
108
-
109
- def format_method(node)
110
- symbol = ACCESS_SYMBOLS[node.access]
111
- result = "#{symbol} #{node.name}"
112
- if node.arguments
113
- arguments = node.arguments.map do |argument|
114
- "#{argument.name}#{" : #{argument.type}" if argument.type}"
115
- end.join(", ")
116
- end
117
-
118
- result << "(#{arguments})"
119
- result << " : #{node.type}" if node.type
120
- result = "<U>#{result}</U>" if node.static
121
- result = "<I>#{result}</I>" if node.abstract
122
-
123
- result
124
- end
125
-
126
- def format_relationship(node)
127
- graph_parent_name = generate_graph_name(node.owner_end)
128
- graph_node_name = generate_graph_name(node.member_end)
129
- attributes = generate_graph_relationship_attributes(node)
130
- graph_attributes = " [#{attributes}]" unless attributes.empty?
131
-
132
- %{#{graph_parent_name} -> #{graph_node_name}#{graph_attributes}}
133
- end
134
-
135
- def generate_graph_relationship_attributes(node)
136
- attributes = Attributes.new
137
- if %w[dependency realizes].include?(node.member_end_type)
138
- attributes["style"] = "dashed"
139
- end
140
- attributes["dir"] = if node.owner_end_type && node.member_end_type
141
- "both"
142
- elsif node.owner_end_type
143
- "back"
144
- else
145
- "direct"
146
- end
147
- attributes["label"] = node.action if node.action
148
- if node.owner_end_attribute_name
149
- attributes["headlabel"] = format_label(
150
- node.owner_end_attribute_name,
151
- node.owner_end_cardinality
152
- )
153
- end
154
- if node.member_end_attribute_name
155
- attributes["taillabel"] = format_label(
156
- node.member_end_attribute_name,
157
- node.member_end_cardinality
158
- )
159
- end
160
-
161
- attributes["arrowtail"] = case node.owner_end_type
162
- when "composition"
163
- "diamond"
164
- when "aggregation"
165
- "odiamond"
166
- when "direct"
167
- "vee"
168
- else
169
- "onormal"
170
- end
171
-
172
- attributes["arrowhead"] = case node.member_end_type
173
- when "composition"
174
- "diamond"
175
- when "aggregation"
176
- "odiamond"
177
- when "direct"
178
- "vee"
179
- else
180
- "onormal"
181
- end
182
- # swap labels and arrows if `dir` eq to `back`
183
- if attributes["dir"] == "back"
184
- attributes["arrowhead"], attributes["arrowtail"] =
185
- [attributes["arrowtail"], attributes["arrowhead"]]
186
- attributes["headlabel"], attributes["taillabel"] =
187
- [attributes["taillabel"], attributes["headlabel"]]
188
- end
189
- attributes
190
- end
191
-
192
- def format_label(name, cardinality = {})
193
- res = "+#{name}"
194
- if cardinality.nil? ||
195
- (cardinality["min"].nil? || cardinality["max"].nil?)
196
- return res
197
- end
198
-
199
- "#{res} #{cardinality['min']}..#{cardinality['max']}"
200
- end
201
-
202
- def format_member_rows(members, hide_members)
203
- unless !hide_members && members && members.length.positive?
204
- return <<~HEREDOC.chomp
205
- <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0">
206
- <TR><TD ALIGN="LEFT"></TD></TR>
207
- </TABLE>
208
- HEREDOC
209
- end
210
-
211
- field_rows = members.map do |field|
212
- %{<TR><TD ALIGN="LEFT">#{format_field(field)}</TD></TR>}
213
- end
214
- field_table = <<~HEREDOC.chomp
215
- <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0">
216
- #{field_rows.map { |row| ' ' * 10 + row }.join("\n")}
217
- </TABLE>
218
- HEREDOC
219
- field_table << "\n" << " " * 6
220
- field_table
221
- end
222
-
223
- def format_class(node, hide_members)
224
- name = ["<B>#{node.name}</B>"]
225
- name.unshift("«#{node.keyword}»") if node.keyword
226
- name_html = <<~HEREDOC
227
- <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0">
228
- #{name.map { |n| %(<TR><TD ALIGN="CENTER">#{n}</TD></TR>) }.join('\n')}
229
- </TABLE>
230
- HEREDOC
231
-
232
- field_table = format_member_rows(node.attributes, hide_members)
233
- method_table = format_member_rows(node.methods, hide_members)
234
- table_body = [name_html, field_table, method_table].map do |type|
235
- next if type.nil?
236
-
237
- <<~TEXT
238
- <TR>
239
- <TD>#{type}</TD>
240
- </TR>
241
- TEXT
242
- end
243
-
244
- <<~HEREDOC.chomp
245
- <TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="10">
246
- #{table_body.compact.join("\n")}
247
- </TABLE>
248
- HEREDOC
249
- end
250
-
251
- def format_document(node)
252
- @fontname = node.fontname || DEFAULT_CLASS_FONT
253
- @node["fontname"] = "#{@fontname}-bold"
254
-
255
- if node.fidelity
256
- hide_members = node.fidelity["hideMembers"]
257
- hide_other_classes = node.fidelity["hideOtherClasses"]
258
- end
259
- classes = (node.classes +
260
- node.enums +
261
- node.data_types +
262
- node.primitives).map do |class_node|
263
- graph_node_name = generate_graph_name(class_node.name)
264
-
265
- <<~HEREDOC
266
- #{graph_node_name} [
267
- shape="plain"
268
- fontname="#{@fontname || DEFAULT_CLASS_FONT}"
269
- label=<#{format_class(class_node, hide_members)}>]
270
- HEREDOC
271
- end.join("\n")
272
- associations = node.classes.map(&:associations).compact.flatten +
273
- node.associations
274
- if node.groups
275
- associations = sort_by_document_groupping(node.groups,
276
- associations)
277
- end
278
- classes_names = node.classes.map(&:name)
279
- associations = associations.map do |assoc_node|
280
- if hide_other_classes &&
281
- !classes_names.include?(assoc_node.member_end)
282
- next
283
- end
284
-
285
- format_relationship(assoc_node)
286
- end.join("\n")
287
-
288
- classes = classes.lines.map { |line| " #{line}" }.join.chomp
289
- associations = associations
290
- .lines.map { |line| " #{line}" }.join.chomp
291
-
292
- <<~HEREDOC
293
- digraph G {
294
- graph [#{@graph}]
295
- edge [#{@edge}]
296
- node [#{@node}]
297
-
298
- #{classes}
299
-
300
- #{associations}
301
- }
302
- HEREDOC
303
- end
304
-
305
- protected
306
-
307
- def sort_by_document_groupping(groups, associations)
308
- result = []
309
- groups.each do |batch|
310
- batch.each do |group_name|
311
- associations
312
- .select { |assc| assc.owner_end == group_name }
313
- .each do |association|
314
- result.push(association) unless result.include?(association)
315
- end
316
- end
317
- end
318
- associations.each do |association|
319
- result.push(association) unless result.include?(association)
320
- end
321
- result
322
- end
323
-
324
- def generate_from_dot(input)
325
- Lutaml::Layout::GraphVizEngine.new(input: input).render(@type)
326
- end
327
-
328
- def generate_graph_name(name)
329
- name.gsub(/[^0-9a-zA-Z]/i, "")
330
- end
331
- end
332
- end
333
- end
334
- 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,14 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Lutaml
4
- module Uml
5
- module HasAttributes
6
- def update_attributes(attributes = {})
7
- attributes.to_h.each do |name, value|
8
- value = value.respond_to?(:str) ? value.str : value
9
- public_send("#{name}=", value)
10
- end
11
- end
12
- end
13
- end
14
- end
@@ -1,30 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Lutaml
4
- module Uml
5
- module HasMembers
6
- class UnknownMemberTypeError < StandardError; end
7
-
8
- # TODO: move to Parslet::Transform
9
- def members=(value)
10
- value.group_by { |member| member.keys.first }
11
- .each do |(type, group)|
12
- attribute_value = group.map(&:values).flatten
13
- if attribute_value.length == 1 && !attribute_value.first.is_a?(Hash)
14
- next public_send("#{associtaion_type(type)}=", attribute_value.first)
15
- end
16
-
17
- public_send("#{associtaion_type(type)}=", attribute_value)
18
- end
19
- end
20
-
21
- private
22
-
23
- def associtaion_type(type)
24
- return type if respond_to?("#{type}=")
25
-
26
- raise(UnknownMemberTypeError, "Unknown member type: #{type}")
27
- end
28
- end
29
- end
30
- end
@@ -1,17 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Lutaml
4
- module Uml
5
- class Instance < TopElement
6
- attr_accessor :classifier, :slot
7
-
8
- def initialize
9
- @name = nil
10
- @xmi_id = nil
11
- @xmi_uuid = nil
12
- @classifier = nil
13
- @slot = []
14
- end
15
- end
16
- end
17
- end
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Lutaml
4
- module Uml
5
- class Model < Package
6
- attr_accessor :viewpoint
7
-
8
- def initialize
9
- @contents = []
10
- end
11
- end
12
- end
13
- end
@@ -1,21 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "lutaml/uml/has_attributes"
4
-
5
- module Lutaml
6
- module Uml
7
- module Node
8
- class Base
9
- include HasAttributes
10
-
11
- # rubocop:disable Rails/ActiveRecordAliases
12
- def initialize(attributes = {})
13
- update_attributes(attributes)
14
- end
15
- # rubocop:enable Rails/ActiveRecordAliases
16
-
17
- attr_accessor :parent
18
- end
19
- end
20
- end
21
- end
@@ -1,57 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "lutaml/uml/node/base"
4
- require "lutaml/uml/node/field"
5
- require "lutaml/uml/node/method"
6
- require "lutaml/uml/node/relationship"
7
- require "lutaml/uml/node/class_relationship"
8
- require "lutaml/uml/node/has_name"
9
-
10
- module Lutaml
11
- module Uml
12
- module Node
13
- class ClassNode < Base
14
- include HasName
15
-
16
- attr_reader :modifier
17
-
18
- def modifier=(value)
19
- @modifier = value.to_s # TODO: Validate?
20
- end
21
-
22
- attr_reader :members
23
-
24
- def members=(value)
25
- @members = value.to_a.map do |member|
26
- type = member.to_a[0][0] # TODO: This is dumb
27
- attributes = member.to_a[0][1]
28
- attributes[:parent] = self
29
-
30
- case type
31
- when :field then Field.new(attributes)
32
- when :method then Method.new(attributes)
33
- when :relationship then Relationship.new(attributes)
34
- when :class_relationship then ClassRelationship.new(attributes)
35
- end
36
- end
37
- end
38
-
39
- def fields
40
- @members.select { |member| member.class == Field }
41
- end
42
-
43
- def methods
44
- @members.select { |member| member.class == Method }
45
- end
46
-
47
- def relationships
48
- @members.select { |member| member.class == Relationship }
49
- end
50
-
51
- def class_relationships
52
- @members.select { |member| member.class == ClassRelationship }
53
- end
54
- end
55
- end
56
- end
57
- end
@@ -1,14 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "lutaml/uml/node/relationship"
4
- require "lutaml/uml/node/has_name"
5
-
6
- module Lutaml
7
- module Uml
8
- module Node
9
- class ClassRelationship < Relationship
10
- include HasName
11
- end
12
- end
13
- end
14
- end
@@ -1,18 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "lutaml/uml/node/base"
4
- require "lutaml/uml/node/class_node"
5
-
6
- module Lutaml
7
- module Uml
8
- module Node
9
- class Document < Base
10
- attr_reader :classes
11
-
12
- def classes=(value)
13
- @classes = value.to_a.map { |attributes| ClassNode.new(attributes) }
14
- end
15
- end
16
- end
17
- end
18
- end