lutaml 0.9.0 → 0.9.2
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 +37 -6
- data/lutaml.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7fe23c8f2af27bf3016adc461338dab47dcbf0179237fef38e2b30ef068e2adc
|
4
|
+
data.tar.gz: 2382b0189342f7e559129af75829c642b4737f934cc2a83821cb2300484813d3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a722350e941888b75fd6437fc7e2b491247cfae144414b400c49d77f522b38cea9b70579010f3bb6bfc5b859058cba6985e65b885e997780bd1aa6d7c3be40b8
|
7
|
+
data.tar.gz: 160e71a7c27b78b4d2c582a8de3b6b3fc1815e3f1c915b487cf0dbd06ddd7436ddb0b18e331b4c76483f621982fd2ce0697744b5cd25620436c8374c9bae513f
|
data/lib/lutaml/version.rb
CHANGED
@@ -57,10 +57,12 @@ module Lutaml
|
|
57
57
|
# @return [Array<Hash>]
|
58
58
|
# @note xpath ./packagedElement[@xmi:type="uml:Package"]
|
59
59
|
def serialize_model_packages(model)
|
60
|
-
model.packaged_element.
|
60
|
+
model.packaged_element.select do |e|
|
61
|
+
e.type?("uml:Package")
|
62
|
+
end.map do |package|
|
61
63
|
{
|
62
64
|
xmi_id: package.id,
|
63
|
-
name: package
|
65
|
+
name: get_package_name(package),
|
64
66
|
classes: serialize_model_classes(package, model),
|
65
67
|
enums: serialize_model_enums(package),
|
66
68
|
data_types: serialize_model_data_types(package),
|
@@ -72,6 +74,18 @@ module Lutaml
|
|
72
74
|
end
|
73
75
|
end
|
74
76
|
|
77
|
+
def get_package_name(package)
|
78
|
+
return package.name unless package.name.nil?
|
79
|
+
|
80
|
+
connector = fetch_connector(package.id)
|
81
|
+
if connector.target&.model && connector.target.model&.name
|
82
|
+
return "#{connector.target.model.name} " \
|
83
|
+
"(#{package.type.split(':').last})"
|
84
|
+
end
|
85
|
+
|
86
|
+
"unnamed"
|
87
|
+
end
|
88
|
+
|
75
89
|
# @param package [Shale::Mapper]
|
76
90
|
# @param model [Shale::Mapper]
|
77
91
|
# @return [Array<Hash>]
|
@@ -164,7 +178,8 @@ module Lutaml
|
|
164
178
|
matched_element = @xmi_root_model.extension.elements.element
|
165
179
|
.find { |e| e.idref == xmi_id }
|
166
180
|
|
167
|
-
return if !matched_element
|
181
|
+
return if !matched_element ||
|
182
|
+
!matched_element.links ||
|
168
183
|
matched_element.links.association.empty?
|
169
184
|
|
170
185
|
matched_element.links.association.map do |assoc|
|
@@ -468,14 +483,30 @@ module Lutaml
|
|
468
483
|
doc_node.properties.send(Shale::Utils.snake_case(attr_name).to_sym)
|
469
484
|
end
|
470
485
|
|
486
|
+
# @param xmi_id [String]
|
487
|
+
# @return [Shale::Mapper]
|
488
|
+
# @note xpath %(//attribute[@xmi:idref="#{xmi_id}"])
|
489
|
+
def fetch_attribute_node(xmi_id)
|
490
|
+
attribute_node = nil
|
491
|
+
@xmi_root_model.extension.elements.element.each do |e|
|
492
|
+
if e.attributes&.attribute
|
493
|
+
e.attributes.attribute.each do |a|
|
494
|
+
attribute_node = a if a.idref == xmi_id
|
495
|
+
end
|
496
|
+
end
|
497
|
+
end
|
498
|
+
attribute_node
|
499
|
+
end
|
500
|
+
|
471
501
|
# @param xmi_id [String]
|
472
502
|
# @return [String]
|
473
503
|
# @note xpath %(//attribute[@xmi:idref="#{xmi_id}"]/documentation)
|
474
504
|
def lookup_attribute_documentation(xmi_id)
|
475
|
-
|
476
|
-
|
505
|
+
attribute_node = fetch_attribute_node(xmi_id)
|
506
|
+
|
507
|
+
return unless attribute_node&.documentation
|
477
508
|
|
478
|
-
|
509
|
+
attribute_node&.documentation&.value
|
479
510
|
end
|
480
511
|
|
481
512
|
# @param xmi_id [String]
|
data/lutaml.gemspec
CHANGED
@@ -36,7 +36,7 @@ Gem::Specification.new do |spec|
|
|
36
36
|
spec.add_runtime_dependency "parslet", "~> 2.0.0"
|
37
37
|
spec.add_runtime_dependency "ruby-graphviz", "~> 1.2"
|
38
38
|
spec.add_runtime_dependency "thor", "~> 1.0"
|
39
|
-
spec.add_runtime_dependency "xmi"
|
39
|
+
spec.add_runtime_dependency "xmi", ">= 0.3.0"
|
40
40
|
|
41
41
|
spec.add_development_dependency "byebug"
|
42
42
|
spec.add_development_dependency "equivalent-xml", "~> 0.6.0"
|
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.2
|
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
|
@@ -114,14 +114,14 @@ dependencies:
|
|
114
114
|
requirements:
|
115
115
|
- - ">="
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version:
|
117
|
+
version: 0.3.0
|
118
118
|
type: :runtime
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version:
|
124
|
+
version: 0.3.0
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: byebug
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|