lutaml 0.9.39 → 0.9.40
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.
- checksums.yaml +4 -4
- data/lib/lutaml/command_line.rb +1 -1
- data/lib/lutaml/converter/dsl_to_uml.rb +235 -0
- data/lib/lutaml/converter/xmi_hash_to_uml.rb +196 -0
- data/lib/lutaml/formatter/base.rb +7 -7
- data/lib/lutaml/formatter/graphviz.rb +19 -8
- data/lib/lutaml/formatter.rb +0 -2
- data/lib/lutaml/parser.rb +1 -1
- data/lib/lutaml/uml/action.rb +15 -0
- data/lib/lutaml/uml/actor.rb +0 -8
- data/lib/lutaml/uml/association.rb +25 -34
- data/lib/lutaml/uml/cardinality.rb +10 -0
- data/lib/lutaml/uml/class.rb +43 -68
- data/lib/lutaml/uml/classifier.rb +5 -3
- data/lib/lutaml/uml/connector.rb +5 -8
- data/lib/lutaml/uml/connector_end.rb +20 -0
- data/lib/lutaml/uml/constraint.rb +11 -1
- data/lib/lutaml/uml/data_type.rb +48 -64
- data/lib/lutaml/uml/dependency.rb +5 -8
- data/lib/lutaml/uml/document.rb +46 -73
- data/lib/lutaml/uml/enum.rb +12 -35
- data/lib/lutaml/uml/event.rb +0 -1
- data/lib/lutaml/uml/fidelity.rb +10 -0
- data/lib/lutaml/uml/group.rb +17 -0
- data/lib/lutaml/uml/instance.rb +5 -7
- data/lib/lutaml/uml/model.rb +3 -3
- data/lib/lutaml/uml/namespace.rb +10 -0
- data/lib/lutaml/uml/node/base.rb +1 -1
- data/lib/lutaml/uml/operation.rb +6 -22
- data/lib/lutaml/uml/package.rb +23 -44
- data/lib/lutaml/uml/parsers/dsl.rb +5 -2
- data/lib/lutaml/uml/parsers/yaml.rb +2 -28
- data/lib/lutaml/uml/primitive_type.rb +3 -4
- data/lib/lutaml/uml/property.rb +15 -17
- data/lib/lutaml/uml/region.rb +0 -1
- data/lib/lutaml/uml/state.rb +9 -1
- data/lib/lutaml/uml/state_machine.rb +0 -1
- data/lib/lutaml/uml/top_element.rb +61 -39
- data/lib/lutaml/uml/top_element_attribute.rb +33 -22
- data/lib/lutaml/uml/transition.rb +11 -1
- data/lib/lutaml/uml/trigger.rb +5 -1
- data/lib/lutaml/uml/value.rb +18 -14
- data/lib/lutaml/uml.rb +40 -2
- data/lib/lutaml/version.rb +1 -1
- data/lib/lutaml/xmi/liquid_drops/enum_drop.rb +1 -1
- data/lib/lutaml/xmi/liquid_drops/klass_drop.rb +2 -1
- data/lib/lutaml/xmi/parsers/xmi_base.rb +20 -2
- data/lib/lutaml/xmi/parsers/xml.rb +5 -4
- metadata +11 -13
- data/lib/lutaml/uml/constructor_end.rb +0 -16
- data/lib/lutaml/uml/formatter/base.rb +0 -67
- data/lib/lutaml/uml/formatter/graphviz.rb +0 -332
- data/lib/lutaml/uml/formatter.rb +0 -21
- data/lib/lutaml/uml/serializers/association.rb +0 -58
- data/lib/lutaml/uml/serializers/base.rb +0 -16
- data/lib/lutaml/uml/serializers/class.rb +0 -29
- data/lib/lutaml/uml/serializers/top_element_attribute.rb +0 -14
- data/lib/lutaml/uml/serializers/yaml_view.rb +0 -18
- data/lib/lutaml/uml/version.rb +0 -7
- /data/{lib/lutaml/uml/README.adoc → docs/UML_README.adoc} +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3a25bacbf3519d5503fcd4170350b61fe5ab7eda2b375a93e4b3d1897bbe7b4b
|
4
|
+
data.tar.gz: 7f10420fd2ac6ef7bbb963790b935096c9767ff15fbe60561e93a86270cc99f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 06cdd75854cf6ab4a665deafd86437d9a8e793d925ac998fd2195d7c2dbea92229844b847ac85cb9ac656b13d9aba58e3d399664a9ad80c4d5d51961ab5a9c9e
|
7
|
+
data.tar.gz: 6b3385b7cef67d5e7aee600c56397c0bb780676788c62b8beb388e6d6386dd6b89dcab3b9191be703a76b98c855d200a078d3618151fd751ac8d9d46a259e38b
|
data/lib/lutaml/command_line.rb
CHANGED
@@ -52,7 +52,7 @@ module Lutaml
|
|
52
52
|
|
53
53
|
def formatter=(value)
|
54
54
|
value = value.to_s.strip.downcase.to_sym
|
55
|
-
value = Lutaml::
|
55
|
+
value = Lutaml::Formatter.find_by(name: value)
|
56
56
|
raise Error, "Formatter not found: #{value}" if value.nil?
|
57
57
|
|
58
58
|
@formatter = value
|
@@ -0,0 +1,235 @@
|
|
1
|
+
module Lutaml
|
2
|
+
module Converter
|
3
|
+
module DslToUml
|
4
|
+
def create_uml_document(hash)
|
5
|
+
::Lutaml::Uml::Document.new.tap do |model|
|
6
|
+
set_uml_model(model, hash)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def create_uml_package(hash)
|
11
|
+
::Lutaml::Uml::Package.new.tap do |model|
|
12
|
+
set_uml_model(model, hash)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def create_uml_class(hash)
|
17
|
+
::Lutaml::Uml::Class.new.tap do |model|
|
18
|
+
set_uml_model(model, hash)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def create_uml_enum(hash)
|
23
|
+
::Lutaml::Uml::Enum.new.tap do |model|
|
24
|
+
set_uml_model(model, hash)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def create_uml_data_type(hash)
|
29
|
+
::Lutaml::Uml::DataType.new.tap do |model|
|
30
|
+
set_uml_model(model, hash)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def create_uml_diagram(hash)
|
35
|
+
::Lutaml::Uml::Diagram.new.tap do |model|
|
36
|
+
set_uml_model(model, hash)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def create_uml_attribute(hash) # rubocop:disable Metrics/AbcSize
|
41
|
+
::Lutaml::Uml::TopElementAttribute.new.tap do |model|
|
42
|
+
set_uml_model(model, hash)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def create_uml_cardinality(hash)
|
47
|
+
::Lutaml::Uml::Cardinality.new.tap do |cardinality|
|
48
|
+
cardinality.min = hash[:min]
|
49
|
+
cardinality.max = hash[:max]
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def create_uml_association(hash) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
|
54
|
+
::Lutaml::Uml::Association.new.tap do |model|
|
55
|
+
member_end_cardinality = hash.delete(:member_end_cardinality)
|
56
|
+
if member_end_cardinality
|
57
|
+
model.member_end_cardinality = create_uml_cardinality(
|
58
|
+
member_end_cardinality,
|
59
|
+
)
|
60
|
+
end
|
61
|
+
owner_end_cardinality = hash.delete(:owner_end_cardinality)
|
62
|
+
if owner_end_cardinality
|
63
|
+
model.owner_end_cardinality = create_uml_cardinality(
|
64
|
+
owner_end_cardinality,
|
65
|
+
)
|
66
|
+
end
|
67
|
+
|
68
|
+
set_uml_model(model, hash)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def create_uml_operation(hash)
|
73
|
+
::Lutaml::Uml::Operation.new.tap do |model|
|
74
|
+
set_uml_model(model, hash)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def create_uml_constraint(hash)
|
79
|
+
::Lutaml::Uml::Constraint.new.tap do |model|
|
80
|
+
set_uml_model(model, hash)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def create_uml_value(hash)
|
85
|
+
::Lutaml::Uml::Value.new.tap do |model|
|
86
|
+
set_uml_model(model, hash)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def set_uml_model(model, hash)
|
91
|
+
hash = create_uml_members(model, hash)
|
92
|
+
set_model_attribute(model, hash)
|
93
|
+
end
|
94
|
+
|
95
|
+
def set_model_attribute(model, hash) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
|
96
|
+
hash.each do |key, value|
|
97
|
+
if key == :definition
|
98
|
+
value = value.to_s.gsub(/\\}/, "}").gsub(/\\{/, "{")
|
99
|
+
.split("\n").map(&:strip).join("\n")
|
100
|
+
end
|
101
|
+
|
102
|
+
if model.respond_to?("#{key}=")
|
103
|
+
if model.class.attributes[key.to_sym].options[:collection]
|
104
|
+
values = model.send(key.to_sym).to_a
|
105
|
+
values << value
|
106
|
+
model.send("#{key}=", values)
|
107
|
+
else
|
108
|
+
model.send("#{key}=", value)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
def create_uml_members(model, hash) # rubocop:disable Metrics/MethodLength,Metrics/AbcSize
|
115
|
+
members = hash.delete(:members)
|
116
|
+
members.to_a.each do |member_hash|
|
117
|
+
member_hash.each do
|
118
|
+
create_uml_packages(model, member_hash)
|
119
|
+
create_uml_classes(model, member_hash)
|
120
|
+
create_uml_enums(model, member_hash)
|
121
|
+
create_uml_data_types(model, member_hash)
|
122
|
+
create_uml_diagrams(model, member_hash)
|
123
|
+
create_uml_attributes(model, member_hash)
|
124
|
+
create_uml_associations(model, member_hash)
|
125
|
+
create_uml_operations(model, member_hash)
|
126
|
+
create_uml_constraints(model, member_hash)
|
127
|
+
create_uml_values(model, member_hash)
|
128
|
+
set_model_attribute(model, member_hash)
|
129
|
+
end
|
130
|
+
end
|
131
|
+
hash
|
132
|
+
end
|
133
|
+
|
134
|
+
def create_uml_packages(model, hash)
|
135
|
+
packages = hash.delete(:packages)
|
136
|
+
return [] if packages.nil?
|
137
|
+
|
138
|
+
attr = create_uml_package(packages)
|
139
|
+
model.packages = [] if model.packages.nil?
|
140
|
+
model.packages << attr
|
141
|
+
hash
|
142
|
+
end
|
143
|
+
|
144
|
+
def create_uml_classes(model, hash)
|
145
|
+
classes = hash.delete(:classes)
|
146
|
+
return [] if classes.nil?
|
147
|
+
|
148
|
+
attr = create_uml_class(classes)
|
149
|
+
model.classes = [] if model.classes.nil?
|
150
|
+
model.classes << attr
|
151
|
+
hash
|
152
|
+
end
|
153
|
+
|
154
|
+
def create_uml_enums(model, hash)
|
155
|
+
enums = hash.delete(:enums)
|
156
|
+
return [] if enums.nil?
|
157
|
+
|
158
|
+
attr = create_uml_enum(enums)
|
159
|
+
model.enums = [] if model.enums.nil?
|
160
|
+
model.enums << attr
|
161
|
+
hash
|
162
|
+
end
|
163
|
+
|
164
|
+
def create_uml_data_types(model, hash)
|
165
|
+
data_types = hash.delete(:data_types)
|
166
|
+
return [] if data_types.nil?
|
167
|
+
|
168
|
+
attr = create_uml_data_type(data_types)
|
169
|
+
model.data_types = [] if model.data_types.nil?
|
170
|
+
model.data_types << attr
|
171
|
+
hash
|
172
|
+
end
|
173
|
+
|
174
|
+
def create_uml_diagrams(model, hash)
|
175
|
+
diagrams = hash.delete(:diagrams)
|
176
|
+
return [] if diagrams.nil?
|
177
|
+
|
178
|
+
attr = create_uml_diagram(diagrams)
|
179
|
+
model.diagrams = [] if model.diagrams.nil?
|
180
|
+
model.diagrams << attr
|
181
|
+
hash
|
182
|
+
end
|
183
|
+
|
184
|
+
def create_uml_attributes(model, hash)
|
185
|
+
attributes = hash.delete(:attributes)
|
186
|
+
return [] if attributes.nil?
|
187
|
+
|
188
|
+
attr = create_uml_attribute(attributes)
|
189
|
+
model.attributes = [] if model.attributes.nil?
|
190
|
+
model.attributes << attr
|
191
|
+
hash
|
192
|
+
end
|
193
|
+
|
194
|
+
def create_uml_associations(model, hash)
|
195
|
+
associations = hash.delete(:associations)
|
196
|
+
return [] if associations.nil?
|
197
|
+
|
198
|
+
attr = create_uml_association(associations)
|
199
|
+
model.associations = [] if model.associations.nil?
|
200
|
+
model.associations << attr
|
201
|
+
hash
|
202
|
+
end
|
203
|
+
|
204
|
+
def create_uml_operations(model, hash)
|
205
|
+
operations = hash.delete(:operations)
|
206
|
+
return [] if operations.nil?
|
207
|
+
|
208
|
+
attr = create_uml_operation(operations)
|
209
|
+
model.operations = [] if model.operations.nil?
|
210
|
+
model.operations << attr
|
211
|
+
hash
|
212
|
+
end
|
213
|
+
|
214
|
+
def create_uml_constraints(model, hash)
|
215
|
+
constraints = hash.delete(:constraints)
|
216
|
+
return [] if constraints.nil?
|
217
|
+
|
218
|
+
attr = create_uml_constraint(constraints)
|
219
|
+
model.constraints = [] if model.constraints.nil?
|
220
|
+
model.constraints << attr
|
221
|
+
hash
|
222
|
+
end
|
223
|
+
|
224
|
+
def create_uml_values(model, hash)
|
225
|
+
values = hash.delete(:values)
|
226
|
+
return [] if values.nil?
|
227
|
+
|
228
|
+
attr = create_uml_value(values)
|
229
|
+
model.values = [] if model.values.nil?
|
230
|
+
model.values << attr
|
231
|
+
hash
|
232
|
+
end
|
233
|
+
end
|
234
|
+
end
|
235
|
+
end
|
@@ -0,0 +1,196 @@
|
|
1
|
+
module Lutaml
|
2
|
+
module Converter
|
3
|
+
module XmiHashToUml
|
4
|
+
def create_uml_document(hash)
|
5
|
+
::Lutaml::Uml::Document.new.tap do |doc|
|
6
|
+
doc.name = hash[:name]
|
7
|
+
hash[:packages]&.each do |package_hash|
|
8
|
+
pkg = create_uml_package(package_hash)
|
9
|
+
doc.packages = [] if doc.packages.nil?
|
10
|
+
doc.packages << pkg
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def create_uml_package(hash) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
|
16
|
+
package = ::Lutaml::Uml::Package.new
|
17
|
+
package.xmi_id = hash[:xmi_id]
|
18
|
+
package.name = hash[:name]
|
19
|
+
package.definition = hash[:definition]
|
20
|
+
package.stereotype = hash[:stereotype]
|
21
|
+
|
22
|
+
hash[:classes]&.each do |class_hash|
|
23
|
+
class_obj = create_uml_class(class_hash)
|
24
|
+
package.classes = [] if package.classes.nil?
|
25
|
+
package.classes << class_obj
|
26
|
+
end
|
27
|
+
hash[:enums]&.each do |enum_hash|
|
28
|
+
enum_obj = create_uml_enum(enum_hash)
|
29
|
+
package.enums = [] if package.enums.nil?
|
30
|
+
package.enums << enum_obj
|
31
|
+
end
|
32
|
+
hash[:data_types]&.each do |data_type_hash|
|
33
|
+
data_type_obj = create_uml_data_type(data_type_hash)
|
34
|
+
package.data_types = [] if package.data_types.nil?
|
35
|
+
package.data_types << data_type_obj
|
36
|
+
end
|
37
|
+
hash[:diagrams]&.each do |diagram_hash|
|
38
|
+
diagram_obj = create_uml_diagram(diagram_hash)
|
39
|
+
package.diagrams = [] if package.diagrams.nil?
|
40
|
+
package.diagrams << diagram_obj
|
41
|
+
end
|
42
|
+
hash[:packages]&.each do |package_hash|
|
43
|
+
pkg = create_uml_package(package_hash)
|
44
|
+
package.packages = [] if package.packages.nil?
|
45
|
+
package.packages << pkg
|
46
|
+
end
|
47
|
+
|
48
|
+
package
|
49
|
+
end
|
50
|
+
|
51
|
+
def create_uml_class(hash) # rubocop:disable Metrics/MethodLength,Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
|
52
|
+
::Lutaml::Uml::Class.new.tap do |klass| # rubocop:disable Metrics/BlockLength
|
53
|
+
klass.xmi_id = hash[:xmi_id]
|
54
|
+
klass.name = hash[:name]
|
55
|
+
klass.type = hash[:type]
|
56
|
+
klass.is_abstract = hash[:is_abstract]
|
57
|
+
klass.definition = hash[:definition]
|
58
|
+
klass.stereotype = hash[:stereotype]
|
59
|
+
hash[:attributes]&.each do |attr_hash|
|
60
|
+
attr = create_uml_attribute(attr_hash)
|
61
|
+
klass.attributes = [] if klass.attributes.nil?
|
62
|
+
klass.attributes << attr
|
63
|
+
end
|
64
|
+
hash[:associations]&.each do |assoc_hash|
|
65
|
+
assoc = create_uml_association(assoc_hash)
|
66
|
+
klass.associations = [] if klass.associations.nil?
|
67
|
+
klass.associations << assoc
|
68
|
+
end
|
69
|
+
hash[:operations]&.each do |op_hash|
|
70
|
+
op = create_uml_operation(op_hash)
|
71
|
+
klass.operations = [] if klass.operations.nil?
|
72
|
+
klass.operations << op
|
73
|
+
end
|
74
|
+
hash[:constraints]&.each do |constraint_hash|
|
75
|
+
constraint = create_uml_constraint(constraint_hash)
|
76
|
+
klass.constraints = [] if klass.constraints
|
77
|
+
klass.constraints << constraint
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def create_uml_enum(hash) # rubocop:disable Metrics/MethodLength,Metrics/AbcSize
|
83
|
+
::Lutaml::Uml::Enum.new.tap do |enum|
|
84
|
+
enum.xmi_id = hash[:xmi_id]
|
85
|
+
enum.name = hash[:name]
|
86
|
+
hash[:values]&.each do |value_hash|
|
87
|
+
value = create_uml_value(value_hash)
|
88
|
+
enum.values = [] if enum.values.nil?
|
89
|
+
enum.values << value
|
90
|
+
end
|
91
|
+
enum.definition = hash[:definition]
|
92
|
+
enum.stereotype = hash[:stereotype]
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
def create_uml_data_type(hash) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
|
97
|
+
::Lutaml::Uml::DataType.new.tap do |data_type|
|
98
|
+
data_type.xmi_id = hash[:xmi_id]
|
99
|
+
data_type.name = hash[:name]
|
100
|
+
data_type.is_abstract = hash[:is_abstract]
|
101
|
+
data_type.definition = hash[:definition]
|
102
|
+
data_type.stereotype = hash[:stereotype]
|
103
|
+
hash[:attributes]&.each do |attr_hash|
|
104
|
+
attr = create_uml_attribute(attr_hash)
|
105
|
+
data_type.attributes = [] if data_type.attributes.nil?
|
106
|
+
data_type.attributes << attr
|
107
|
+
end
|
108
|
+
hash[:operations]&.each do |op_hash|
|
109
|
+
op = create_uml_operation(op_hash)
|
110
|
+
data_type.operations = [] if data_type.operations.nil?
|
111
|
+
data_type.operations << op
|
112
|
+
end
|
113
|
+
hash[:associations]&.each do |assoc_hash|
|
114
|
+
assoc = create_uml_association(assoc_hash)
|
115
|
+
data_type.associations = [] if data_type.associations.nil?
|
116
|
+
data_type.associations << assoc
|
117
|
+
end
|
118
|
+
hash[:constraints]&.each do |constraint_hash|
|
119
|
+
constraint = create_uml_constraint(constraint_hash)
|
120
|
+
data_type.constraints = [] if data_type.constraints
|
121
|
+
data_type.constraints << constraint
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
def create_uml_diagram(hash)
|
127
|
+
::Lutaml::Uml::Diagram.new.tap do |diagram|
|
128
|
+
diagram.xmi_id = hash[:xmi_id]
|
129
|
+
diagram.name = hash[:name]
|
130
|
+
diagram.definition = hash[:definition]
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
def create_uml_attribute(hash) # rubocop:disable Metrics/AbcSize
|
135
|
+
::Lutaml::Uml::TopElementAttribute.new.tap do |attr|
|
136
|
+
attr.id = hash[:id]
|
137
|
+
attr.name = hash[:name]
|
138
|
+
attr.type = hash[:type]
|
139
|
+
attr.xmi_id = hash[:xmi_id]
|
140
|
+
attr.is_derived = hash[:is_derived]
|
141
|
+
attr.cardinality = create_uml_cardinality(hash[:cardinality])
|
142
|
+
attr.definition = hash[:definition]
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
def create_uml_cardinality(hash)
|
147
|
+
::Lutaml::Uml::Cardinality.new.tap do |cardinality|
|
148
|
+
cardinality.min = hash[:min]
|
149
|
+
cardinality.max = hash[:max]
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
def create_uml_association(hash) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
|
154
|
+
::Lutaml::Uml::Association.new.tap do |assoc|
|
155
|
+
assoc.xmi_id = hash[:xmi_id]
|
156
|
+
assoc.member_end = hash[:member_end]
|
157
|
+
assoc.member_end_type = hash[:member_end_type]
|
158
|
+
assoc.member_end_cardinality = create_uml_cardinality(
|
159
|
+
hash[:member_end_cardinality],
|
160
|
+
)
|
161
|
+
assoc.member_end_attribute_name = hash[:member_end_attribute_name]
|
162
|
+
assoc.member_end_xmi_id = hash[:member_end_xmi_id]
|
163
|
+
assoc.owner_end = hash[:owner_end]
|
164
|
+
assoc.owner_end_xmi_id = hash[:owner_end_xmi_id]
|
165
|
+
assoc.definition = hash[:definition]
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
def create_uml_operation(hash)
|
170
|
+
::Lutaml::Uml::Operation.new.tap do |op|
|
171
|
+
op.id = hash[:id]
|
172
|
+
op.xmi_id = hash[:xmi_id]
|
173
|
+
op.name = hash[:name]
|
174
|
+
op.definition = hash[:definition]
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
def create_uml_constraint(hash)
|
179
|
+
::Lutaml::Uml::Constraint.new.tap do |constraint|
|
180
|
+
constraint.name = hash[:name]
|
181
|
+
constraint.type = hash[:type]
|
182
|
+
constraint.weight = hash[:weight]
|
183
|
+
constraint.status = hash[:status]
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
def create_uml_value(hash)
|
188
|
+
::Lutaml::Uml::Value.new.tap do |value|
|
189
|
+
value.name = hash[:name]
|
190
|
+
value.type = hash[:type]
|
191
|
+
value.definition = hash[:definition]
|
192
|
+
end
|
193
|
+
end
|
194
|
+
end
|
195
|
+
end
|
196
|
+
end
|
@@ -40,27 +40,27 @@ module Lutaml
|
|
40
40
|
|
41
41
|
def format(node) # rubocop:disable Metrics/CyclomaticComplexity
|
42
42
|
case node
|
43
|
-
when ::Lutaml::Uml::Node::Field
|
43
|
+
when ::Lutaml::Uml::Node::Field then format_field(node)
|
44
44
|
when ::Lutaml::Uml::Node::Method then format_method(node)
|
45
45
|
when ::Lutaml::Uml::Node::Relationship then format_relationship(node)
|
46
46
|
when ::Lutaml::Uml::Node::ClassRelationship
|
47
47
|
format_class_relationship(node)
|
48
48
|
when ::Lutaml::Uml::Node::ClassNode then format_class(node)
|
49
|
-
when Lutaml::Uml::Document then format_document(node)
|
49
|
+
when ::Lutaml::Uml::Document then format_document(node)
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
|
-
def format_field(_node);
|
53
|
+
def format_field(_node); raise NotImplementedError; end
|
54
54
|
|
55
|
-
def format_method(_node);
|
55
|
+
def format_method(_node); raise NotImplementedError; end
|
56
56
|
|
57
|
-
def format_relationship(_node);
|
57
|
+
def format_relationship(_node); raise NotImplementedError; end
|
58
58
|
|
59
59
|
def format_class_relationship(_node); raise NotImplementedError; end
|
60
60
|
|
61
|
-
def format_class(_node);
|
61
|
+
def format_class(_node); raise NotImplementedError; end
|
62
62
|
|
63
|
-
def format_document(_node);
|
63
|
+
def format_document(_node); raise NotImplementedError; end
|
64
64
|
end
|
65
65
|
end
|
66
66
|
end
|
@@ -95,7 +95,8 @@ module Lutaml
|
|
95
95
|
result += " : #{keyword}#{node.type}"
|
96
96
|
end
|
97
97
|
if node.cardinality
|
98
|
-
result += "[#{node.cardinality
|
98
|
+
result += "[#{node.cardinality.min}.." \
|
99
|
+
"#{node.cardinality.max}]"
|
99
100
|
end
|
100
101
|
result = escape_html_chars(result)
|
101
102
|
result = "<U>#{result}</U>" if node.static
|
@@ -141,7 +142,17 @@ module Lutaml
|
|
141
142
|
else
|
142
143
|
"direct"
|
143
144
|
end
|
144
|
-
|
145
|
+
|
146
|
+
if node&.action&.verb
|
147
|
+
attributes["label"] = node.action.verb
|
148
|
+
end
|
149
|
+
case node&.action&.direction
|
150
|
+
when "target"
|
151
|
+
attributes["label"] = "#{attributes['label']} \u25b6"
|
152
|
+
when "source"
|
153
|
+
attributes["label"] = "\u25c0 #{attributes['label']}"
|
154
|
+
end
|
155
|
+
|
145
156
|
if node.owner_end_attribute_name
|
146
157
|
attributes["headlabel"] = format_label(
|
147
158
|
node.owner_end_attribute_name,
|
@@ -189,11 +200,11 @@ module Lutaml
|
|
189
200
|
def format_label(name, cardinality = {})
|
190
201
|
res = "+#{name}"
|
191
202
|
if cardinality.nil? ||
|
192
|
-
(cardinality
|
203
|
+
(cardinality.min.nil? || cardinality.max.nil?)
|
193
204
|
return res
|
194
205
|
end
|
195
206
|
|
196
|
-
"#{res} #{cardinality
|
207
|
+
"#{res} #{cardinality.min}..#{cardinality.max}"
|
197
208
|
end
|
198
209
|
|
199
210
|
def format_member_rows(members, hide_members) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity
|
@@ -250,8 +261,8 @@ module Lutaml
|
|
250
261
|
@node["fontname"] = "#{@fontname}-bold"
|
251
262
|
|
252
263
|
if node.fidelity
|
253
|
-
hide_members = node.fidelity
|
254
|
-
hide_other_classes = node.fidelity
|
264
|
+
hide_members = node.fidelity.hideMembers
|
265
|
+
hide_other_classes = node.fidelity.hideOtherClasses
|
255
266
|
end
|
256
267
|
classes = (node.classes +
|
257
268
|
node.enums +
|
@@ -303,8 +314,8 @@ module Lutaml
|
|
303
314
|
|
304
315
|
def sort_by_document_grouping(groups, associations) # rubocop:disable Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
|
305
316
|
result = []
|
306
|
-
groups.each do |
|
307
|
-
|
317
|
+
groups.each do |group|
|
318
|
+
group.values.each do |group_name| # rubocop:disable Style/HashEachMethods
|
308
319
|
associations
|
309
320
|
.select { |assc| assc.owner_end == group_name }
|
310
321
|
.each do |association|
|
data/lib/lutaml/formatter.rb
CHANGED
data/lib/lutaml/parser.rb
CHANGED
@@ -35,7 +35,7 @@ module Lutaml
|
|
35
35
|
file_list.map { |file| Lutaml::Xml::Parsers::Xml.parse(file) }
|
36
36
|
when "lutaml"
|
37
37
|
file_list.map { |file| Lutaml::Uml::Parsers::Dsl.parse(file) }
|
38
|
-
when "yml"
|
38
|
+
when "yml", "yaml"
|
39
39
|
file_list.map { |file| Lutaml::Uml::Parsers::Yaml.parse(file.path) }
|
40
40
|
else
|
41
41
|
raise ArgumentError, "Unsupported file format"
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Lutaml
|
4
|
+
module Uml
|
5
|
+
class Action < Lutaml::Model::Serializable
|
6
|
+
attribute :verb, :string
|
7
|
+
attribute :direction, :string
|
8
|
+
|
9
|
+
yaml do
|
10
|
+
map "verb", to: :verb
|
11
|
+
map "direction", to: :direction
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/lutaml/uml/actor.rb
CHANGED
@@ -3,17 +3,9 @@
|
|
3
3
|
##
|
4
4
|
## Behaviour metamodel
|
5
5
|
##
|
6
|
-
|
7
6
|
module Lutaml
|
8
7
|
module Uml
|
9
8
|
class Actor < Classifier
|
10
|
-
def initialize # rubocop:disable Lint/MissingSuper
|
11
|
-
@name = nil
|
12
|
-
@xmi_id = nil
|
13
|
-
@stereotype = []
|
14
|
-
@generalization = []
|
15
|
-
@namespace = nil
|
16
|
-
end
|
17
9
|
end
|
18
10
|
end
|
19
11
|
end
|
@@ -3,41 +3,32 @@
|
|
3
3
|
module Lutaml
|
4
4
|
module Uml
|
5
5
|
class Association < TopElement
|
6
|
-
|
6
|
+
attribute :owner_end, :string
|
7
|
+
attribute :owner_end_attribute_name, :string
|
8
|
+
attribute :owner_end_cardinality, Cardinality
|
9
|
+
attribute :owner_end_type, :string
|
10
|
+
attribute :owner_end_xmi_id, :string
|
11
|
+
attribute :member_end, :string
|
12
|
+
attribute :member_end_attribute_name, :string
|
13
|
+
attribute :member_end_xmi_id, :string
|
14
|
+
attribute :member_end_cardinality, Cardinality
|
15
|
+
attribute :member_end_type, :string
|
16
|
+
attribute :static, :string
|
17
|
+
attribute :action, Action
|
7
18
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
# TODO: move to Parslet::Transform
|
22
|
-
def members=(value) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
|
23
|
-
value.group_by { |member| member.keys.first }
|
24
|
-
.each do |(type, group)|
|
25
|
-
if %w[owner_end member_end].include?(type) # rubocop:disable Performance/CollectionLiteralInLoop
|
26
|
-
group.each do |member|
|
27
|
-
member.each_pair do |key, member_value|
|
28
|
-
public_send(:"#{association_type(key)}=", member_value)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
next
|
32
|
-
end
|
33
|
-
attribute_value = group.map(&:values).flatten
|
34
|
-
if attribute_value.length == 1 && !attribute_value.first.is_a?(Hash)
|
35
|
-
next public_send(:"#{association_type(type)}=",
|
36
|
-
attribute_value.first)
|
37
|
-
end
|
38
|
-
|
39
|
-
public_send(:"#{association_type(type)}=", attribute_value)
|
40
|
-
end
|
19
|
+
yaml do
|
20
|
+
map "owner_end", to: :owner_end
|
21
|
+
map "owner_end_attribute_name", to: :owner_end_attribute_name
|
22
|
+
map "owner_end_cardinality", to: :owner_end_cardinality
|
23
|
+
map "owner_end_type", to: :owner_end_type
|
24
|
+
map "owner_end_xmi_id", to: :owner_end_xmi_id
|
25
|
+
map "member_end", to: :member_end
|
26
|
+
map "member_end_attribute_name", to: :member_end_attribute_name
|
27
|
+
map "member_end_xmi_id", to: :member_end_xmi_id
|
28
|
+
map "member_end_cardinality", to: :member_end_cardinality
|
29
|
+
map "member_end_type", to: :member_end_type
|
30
|
+
map "static", to: :static
|
31
|
+
map "action", to: :action
|
41
32
|
end
|
42
33
|
end
|
43
34
|
end
|