lutaml 0.9.35 → 0.9.37
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/version.rb +1 -1
- data/lib/lutaml/xmi/liquid_drops/association_drop.rb +1 -1
- data/lib/lutaml/xmi/liquid_drops/attribute_drop.rb +11 -0
- data/lib/lutaml/xmi/liquid_drops/connector_drop.rb +7 -2
- data/lib/lutaml/xmi/liquid_drops/data_type_drop.rb +7 -4
- data/lib/lutaml/xmi/liquid_drops/dependency_drop.rb +37 -0
- data/lib/lutaml/xmi/liquid_drops/enum_drop.rb +7 -0
- data/lib/lutaml/xmi/liquid_drops/klass_drop.rb +36 -9
- data/lib/lutaml/xmi/liquid_drops/source_target_drop.rb +8 -0
- data/lib/lutaml/xmi/parsers/xmi_base.rb +29 -5
- data/lib/lutaml/xmi/parsers/xml.rb +42 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a4c517e395c6c0fddc0deb4e81f9fd767092565b5715341e87dd008ceb0bffd4
|
4
|
+
data.tar.gz: 1f96edd32cfd1f783970f5d33652d8487c5627d1be2e5624face9875591ff647
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8829361ee8fd6b045af520511b5635921af2042856ce0d4c511f5e9f690588ba9666a8252d831d8f878b79df0a7e82e24831c34a204f749317447cf47d27fc05
|
7
|
+
data.tar.gz: 62b04af256d7b07f61c5b7343969f85e3ad6534c9402f4db0c6ebfcd7cc2adfbc40d8bd205659349205437b3ff4d6eb77147f9fbc9c558a0ec2f0e815ef8824e
|
data/lib/lutaml/version.rb
CHANGED
@@ -55,11 +55,22 @@ module Lutaml
|
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
|
+
def association_connector
|
59
|
+
connector = fetch_connector(@model.association)
|
60
|
+
if connector
|
61
|
+
::Lutaml::XMI::ConnectorDrop.new(connector, @options)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
58
65
|
def type_ns
|
59
66
|
if @options[:with_assoc] && @model.association
|
60
67
|
get_ns_by_xmi_id(xmi_id)
|
61
68
|
end
|
62
69
|
end
|
70
|
+
|
71
|
+
def stereotype
|
72
|
+
doc_node_attribute_value(@model.id, "stereotype")
|
73
|
+
end
|
63
74
|
end
|
64
75
|
end
|
65
76
|
end
|
@@ -37,11 +37,16 @@ module Lutaml
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def source
|
40
|
-
::Lutaml::XMI::SourceTargetDrop.new(@model.source)
|
40
|
+
::Lutaml::XMI::SourceTargetDrop.new(@model.source, @options)
|
41
41
|
end
|
42
42
|
|
43
43
|
def target
|
44
|
-
::Lutaml::XMI::SourceTargetDrop.new(@model.target)
|
44
|
+
::Lutaml::XMI::SourceTargetDrop.new(@model.target, @options)
|
45
|
+
end
|
46
|
+
|
47
|
+
def recognized?
|
48
|
+
!!@id_name_mapping[@model.source.idref] &&
|
49
|
+
!!@id_name_mapping[@model.target.idref]
|
45
50
|
end
|
46
51
|
end
|
47
52
|
end
|
@@ -47,11 +47,14 @@ module Lutaml
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def associations # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity,Metrics/MethodLength
|
50
|
-
return if !@matched_element ||
|
51
|
-
!@matched_element.links ||
|
52
|
-
@matched_element.links.association.empty?
|
50
|
+
return if !@matched_element || !@matched_element.links
|
53
51
|
|
54
|
-
|
52
|
+
links = []
|
53
|
+
@matched_element.links.each do |link|
|
54
|
+
links << link.association if link.association.any?
|
55
|
+
end
|
56
|
+
|
57
|
+
links.flatten.compact.map do |assoc|
|
55
58
|
link_member = assoc.start == xmi_id ? "end" : "start"
|
56
59
|
link_owner_name = link_member == "start" ? "end" : "start"
|
57
60
|
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Lutaml
|
4
|
+
module XMI
|
5
|
+
class DependencyDrop < Liquid::Drop
|
6
|
+
include Parsers::XMIBase
|
7
|
+
|
8
|
+
def initialize(model, options = {}) # rubocop:disable Lint/MissingSuper
|
9
|
+
@model = model
|
10
|
+
@options = options
|
11
|
+
@xmi_root_model = options[:xmi_root_model]
|
12
|
+
@id_name_mapping = options[:id_name_mapping]
|
13
|
+
end
|
14
|
+
|
15
|
+
def id
|
16
|
+
@model.id
|
17
|
+
end
|
18
|
+
|
19
|
+
def name
|
20
|
+
@model.name
|
21
|
+
end
|
22
|
+
|
23
|
+
def ea_type
|
24
|
+
@model&.properties&.ea_type
|
25
|
+
end
|
26
|
+
|
27
|
+
def documentation
|
28
|
+
@model&.documentation&.value
|
29
|
+
end
|
30
|
+
|
31
|
+
def connector
|
32
|
+
connector = fetch_connector(@model.id)
|
33
|
+
::Lutaml::XMI::ConnectorDrop.new(connector, @options)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -37,6 +37,13 @@ module Lutaml
|
|
37
37
|
def stereotype
|
38
38
|
doc_node_attribute_value(@model.id, "stereotype")
|
39
39
|
end
|
40
|
+
|
41
|
+
# @return name of the upper packaged element
|
42
|
+
def upper_packaged_element
|
43
|
+
if @options[:with_gen]
|
44
|
+
find_upper_level_packaged_element(@model.id)
|
45
|
+
end
|
46
|
+
end
|
40
47
|
end
|
41
48
|
end
|
42
49
|
end
|
@@ -24,6 +24,14 @@ module Lutaml
|
|
24
24
|
@matched_element = @xmi_root_model&.extension&.elements&.element&.find do |e| # rubocop:disable Layout/LineLength,Style/SafeNavigationChainLength
|
25
25
|
e.idref == @model.id
|
26
26
|
end
|
27
|
+
|
28
|
+
@dependencies = select_dependencies_by_supplier(@model.id)
|
29
|
+
|
30
|
+
@inheritance_ids = @matched_element&.links&.map do |link|
|
31
|
+
link.generalization.select do |gen|
|
32
|
+
gen.end == @model.id
|
33
|
+
end.map(&:id)
|
34
|
+
end&.flatten&.compact || []
|
27
35
|
end
|
28
36
|
|
29
37
|
if guidance
|
@@ -69,17 +77,36 @@ module Lutaml
|
|
69
77
|
end.compact
|
70
78
|
end
|
71
79
|
|
80
|
+
def owned_attributes
|
81
|
+
@owned_attributes.map do |owned_attr|
|
82
|
+
::Lutaml::XMI::AttributeDrop.new(owned_attr, @options)
|
83
|
+
end.compact
|
84
|
+
end
|
85
|
+
|
86
|
+
def dependencies
|
87
|
+
@dependencies.map do |dependency|
|
88
|
+
::Lutaml::XMI::DependencyDrop.new(dependency, @options)
|
89
|
+
end.compact
|
90
|
+
end
|
91
|
+
|
92
|
+
def inheritances
|
93
|
+
@inheritance_ids.map do |inheritance_id|
|
94
|
+
# ::Lutaml::XMI::InheritanceDrop.new(dependency, @options)
|
95
|
+
connector = fetch_connector(inheritance_id)
|
96
|
+
::Lutaml::XMI::ConnectorDrop.new(connector, @options)
|
97
|
+
end.compact
|
98
|
+
end
|
99
|
+
|
72
100
|
def associations # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity,Metrics/MethodLength
|
73
|
-
return if !@matched_element ||
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
101
|
+
return if !@matched_element || !@matched_element.links
|
102
|
+
|
103
|
+
links = []
|
104
|
+
@matched_element.links.each do |link|
|
105
|
+
links << link.association if link.association.any?
|
106
|
+
links << link.generalization if link.generalization.any?
|
107
|
+
end
|
79
108
|
|
80
|
-
links
|
81
|
-
@matched_element.links.generalization
|
82
|
-
links.map do |assoc|
|
109
|
+
links.flatten.compact.map do |assoc|
|
83
110
|
link_member = assoc.start == xmi_id ? "end" : "start"
|
84
111
|
link_owner_name = link_member == "start" ? "end" : "start"
|
85
112
|
|
@@ -371,7 +371,28 @@ module Lutaml
|
|
371
371
|
# @return [Lutaml::Model::Serializable]
|
372
372
|
def find_klass_packaged_element_by_name(name)
|
373
373
|
all_packaged_elements.find do |e|
|
374
|
-
e.
|
374
|
+
e.name == name &&
|
375
|
+
(
|
376
|
+
e.type?("uml:Class") ||
|
377
|
+
e.type?("uml:AssociationClass")
|
378
|
+
)
|
379
|
+
end
|
380
|
+
end
|
381
|
+
|
382
|
+
# @param name [String]
|
383
|
+
# @return [Lutaml::Model::Serializable]
|
384
|
+
def find_enum_packaged_element_by_name(name)
|
385
|
+
all_packaged_elements.find do |e|
|
386
|
+
e.name == name && e.type?("uml:Enumeration")
|
387
|
+
end
|
388
|
+
end
|
389
|
+
|
390
|
+
# @param supplier_id [String]
|
391
|
+
# @return [Lutaml::Model::Serializable]
|
392
|
+
def select_dependencies_by_supplier(supplier_id)
|
393
|
+
all_packaged_elements.select do |e|
|
394
|
+
e.supplier == supplier_id &&
|
395
|
+
e.type?("uml:Dependency")
|
375
396
|
end
|
376
397
|
end
|
377
398
|
|
@@ -473,11 +494,14 @@ module Lutaml
|
|
473
494
|
matched_element = @xmi_root_model.extension.elements.element
|
474
495
|
.find { |e| e.idref == xmi_id }
|
475
496
|
|
476
|
-
return if !matched_element ||
|
477
|
-
|
478
|
-
|
497
|
+
return if !matched_element || !matched_element.links
|
498
|
+
|
499
|
+
links = []
|
500
|
+
matched_element.links.each do |link|
|
501
|
+
links << link.association if link.association.any?
|
502
|
+
end
|
479
503
|
|
480
|
-
|
504
|
+
links.flatten.compact.map do |assoc|
|
481
505
|
link_member = assoc.start == xmi_id ? "end" : "start"
|
482
506
|
linke_owner_name = link_member == "start" ? "end" : "start"
|
483
507
|
|
@@ -67,6 +67,30 @@ module Lutaml
|
|
67
67
|
|
68
68
|
ret_val
|
69
69
|
end
|
70
|
+
|
71
|
+
# @param xmi_path [String] path to xml
|
72
|
+
# @param name [String]
|
73
|
+
# @return [Hash]
|
74
|
+
def serialize_enumeration_by_name( # rubocop:disable Metrics/MethodLength
|
75
|
+
xmi_path, name
|
76
|
+
)
|
77
|
+
# Load from cache or file
|
78
|
+
xml_cache_key = (Digest::SHA256.file xmi_path).hexdigest
|
79
|
+
xmi_model = @xmi_root_model_cache_static[xml_cache_key] ||
|
80
|
+
get_xmi_model(xmi_path)
|
81
|
+
id_name_mapping = @id_name_mapping_static[xml_cache_key]
|
82
|
+
|
83
|
+
instance = new
|
84
|
+
enum = instance.serialize_enumeration_by_name(
|
85
|
+
xmi_model, name, id_name_mapping
|
86
|
+
)
|
87
|
+
|
88
|
+
# Put xmi_model and id_name_mapping to cache
|
89
|
+
@id_name_mapping_static[xml_cache_key] ||= instance.id_name_mapping
|
90
|
+
@xmi_root_model_cache_static[xml_cache_key] ||= xmi_model
|
91
|
+
|
92
|
+
enum
|
93
|
+
end
|
70
94
|
end
|
71
95
|
|
72
96
|
# @param xmi_model [Lutaml::Model::Serializable]
|
@@ -128,6 +152,24 @@ module Lutaml
|
|
128
152
|
options,
|
129
153
|
)
|
130
154
|
end
|
155
|
+
|
156
|
+
# @param xmi_model [Lutaml::Model::Serializable]
|
157
|
+
# @param name [String]
|
158
|
+
# @param id_name_mapping [Hash]
|
159
|
+
# @return [Hash]
|
160
|
+
def serialize_enumeration_by_name( # rubocop:disable Metrics/MethodLength
|
161
|
+
xmi_model, name, id_name_mapping = nil
|
162
|
+
)
|
163
|
+
set_xmi_model(xmi_model, id_name_mapping)
|
164
|
+
enum = find_enum_packaged_element_by_name(name)
|
165
|
+
options = {
|
166
|
+
xmi_root_model: @xmi_root_model,
|
167
|
+
id_name_mapping: @id_name_mapping,
|
168
|
+
with_gen: true,
|
169
|
+
with_absolute_path: true,
|
170
|
+
}
|
171
|
+
::Lutaml::XMI::EnumDrop.new(enum, options)
|
172
|
+
end
|
131
173
|
end
|
132
174
|
end
|
133
175
|
end
|
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.37
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-08-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: expressir
|
@@ -314,6 +314,7 @@ files:
|
|
314
314
|
- lib/lutaml/xmi/liquid_drops/connector_drop.rb
|
315
315
|
- lib/lutaml/xmi/liquid_drops/constraint_drop.rb
|
316
316
|
- lib/lutaml/xmi/liquid_drops/data_type_drop.rb
|
317
|
+
- lib/lutaml/xmi/liquid_drops/dependency_drop.rb
|
317
318
|
- lib/lutaml/xmi/liquid_drops/diagram_drop.rb
|
318
319
|
- lib/lutaml/xmi/liquid_drops/enum_drop.rb
|
319
320
|
- lib/lutaml/xmi/liquid_drops/enum_owned_literal_drop.rb
|