lutaml 0.9.1 → 0.9.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/lutaml/version.rb +1 -1
- data/lib/lutaml/xmi/parsers/xml.rb +40 -9
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '00689211648c9cfcc32eed2a9ef1e49c3992096cdc6441eae5c96bff2ce7830d'
|
4
|
+
data.tar.gz: 6be87ad65a48ef86856042a929538bc525ad9f6f347005bcfe1425c5c376ee58
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2693eb3a76f8ec311dc24e9af82dc549783156fabb7139afe2d8cfac3c28b27b9ad2bb7a9e5dc562ef4864963b52eddcff287075fc881284ac292020d83df3fb
|
7
|
+
data.tar.gz: d238a14995787d8555f7292c4354703d007a6ebb7f3908f7a10cbe599363f6d0ab646006d21933992dd9ecabab1ad3827c0d517d9ceb67ebe51eb41cc2a349ba
|
data/lib/lutaml/version.rb
CHANGED
@@ -117,21 +117,36 @@ module Lutaml
|
|
117
117
|
def serialize_model_enums(package)
|
118
118
|
package.packaged_element.select { |e| e.type?("uml:Enumeration") }
|
119
119
|
.map do |enum|
|
120
|
-
# xpath .//ownedLiteral[@xmi:type="uml:EnumerationLiteral"]
|
121
|
-
owned_literals = enum.owned_literal.map do |owned_literal|
|
122
|
-
owned_literal.to_hash.transform_keys(&:to_sym)
|
123
|
-
end
|
124
|
-
|
125
120
|
{
|
126
121
|
xmi_id: enum.id,
|
127
122
|
name: enum.name,
|
128
|
-
values:
|
123
|
+
values: serialize_enum_owned_literal(enum),
|
129
124
|
definition: doc_node_attribute_value(enum.id, "documentation"),
|
130
125
|
stereotype: doc_node_attribute_value(enum.id, "stereotype"),
|
131
126
|
}
|
132
127
|
end
|
133
128
|
end
|
134
129
|
|
130
|
+
# @param model [Shale::Mapper]
|
131
|
+
# @return [Hash]
|
132
|
+
# @note xpath .//ownedLiteral[@xmi:type="uml:EnumerationLiteral"]
|
133
|
+
def serialize_enum_owned_literal(enum)
|
134
|
+
owned_literals = enum.owned_literal.select do |owned_literal|
|
135
|
+
owned_literal.type? "uml:EnumerationLiteral"
|
136
|
+
end
|
137
|
+
|
138
|
+
owned_literals.map do |owned_literal|
|
139
|
+
# xpath .//type
|
140
|
+
uml_type_id = owned_literal&.uml_type&.idref
|
141
|
+
|
142
|
+
{
|
143
|
+
name: owned_literal.name,
|
144
|
+
type: lookup_entity_name(uml_type_id) || uml_type_id,
|
145
|
+
definition: lookup_attribute_documentation(owned_literal.id),
|
146
|
+
}
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
135
150
|
# @param model [Shale::Mapper]
|
136
151
|
# @return [Array<Hash>]
|
137
152
|
# @note xpath ./packagedElement[@xmi:type="uml:DataType"]
|
@@ -483,14 +498,30 @@ module Lutaml
|
|
483
498
|
doc_node.properties.send(Shale::Utils.snake_case(attr_name).to_sym)
|
484
499
|
end
|
485
500
|
|
501
|
+
# @param xmi_id [String]
|
502
|
+
# @return [Shale::Mapper]
|
503
|
+
# @note xpath %(//attribute[@xmi:idref="#{xmi_id}"])
|
504
|
+
def fetch_attribute_node(xmi_id)
|
505
|
+
attribute_node = nil
|
506
|
+
@xmi_root_model.extension.elements.element.each do |e|
|
507
|
+
if e.attributes&.attribute
|
508
|
+
e.attributes.attribute.each do |a|
|
509
|
+
attribute_node = a if a.idref == xmi_id
|
510
|
+
end
|
511
|
+
end
|
512
|
+
end
|
513
|
+
attribute_node
|
514
|
+
end
|
515
|
+
|
486
516
|
# @param xmi_id [String]
|
487
517
|
# @return [String]
|
488
518
|
# @note xpath %(//attribute[@xmi:idref="#{xmi_id}"]/documentation)
|
489
519
|
def lookup_attribute_documentation(xmi_id)
|
490
|
-
|
491
|
-
|
520
|
+
attribute_node = fetch_attribute_node(xmi_id)
|
521
|
+
|
522
|
+
return unless attribute_node&.documentation
|
492
523
|
|
493
|
-
|
524
|
+
attribute_node&.documentation&.value
|
494
525
|
end
|
495
526
|
|
496
527
|
# @param xmi_id [String]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lutaml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-06-
|
11
|
+
date: 2024-06-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: expressir
|