lutaml 0.9.16 → 0.9.18
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/formatter/graphviz.rb +1 -1
- data/lib/lutaml/uml/formatter/graphviz.rb +3 -3
- data/lib/lutaml/version.rb +1 -1
- data/lib/lutaml/xmi/liquid_drops/cardinality_drop.rb +2 -2
- data/lib/lutaml/xmi/liquid_drops/generalization_attribute_drop.rb +22 -18
- data/lib/lutaml/xmi/liquid_drops/generalization_drop.rb +6 -5
- data/lib/lutaml/xmi/liquid_drops/klass_drop.rb +13 -3
- data/lib/lutaml/xmi/liquid_drops/package_drop.rb +4 -3
- data/lib/lutaml/xmi/liquid_drops/root_drop.rb +3 -2
- data/lib/lutaml/xmi/parsers/xml.rb +23 -28
- 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: a78a8cd7a54dcb75279728cff484e7a8bfcbc3258f8a8ee155a2368ce21ade87
|
4
|
+
data.tar.gz: 823a52c70df804f61e430d143471daf3580f271331e02306501f06925ed55346
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0466df4efa98e478bbfdb1e5739425bd02b59e20d8c780d3caea203ce87e99183a5c8f003c6418a76be7dc0abb0346a57403b7b7fde9b6d11f2810186f24ce4f
|
7
|
+
data.tar.gz: 2c342890469f5022c5d3040e9ca7f2c7dbe302f339356458fb62558c6da382c7281133acc344a1de9649815bca5ea0175265aae1eaf7373c44c87ed3f51acd57
|
@@ -148,13 +148,13 @@ module Lutaml
|
|
148
148
|
if node.owner_end_attribute_name
|
149
149
|
attributes["headlabel"] = format_label(
|
150
150
|
node.owner_end_attribute_name,
|
151
|
-
node.owner_end_cardinality
|
151
|
+
node.owner_end_cardinality,
|
152
152
|
)
|
153
153
|
end
|
154
154
|
if node.member_end_attribute_name
|
155
155
|
attributes["taillabel"] = format_label(
|
156
156
|
node.member_end_attribute_name,
|
157
|
-
node.member_end_cardinality
|
157
|
+
node.member_end_cardinality,
|
158
158
|
)
|
159
159
|
end
|
160
160
|
|
@@ -192,7 +192,7 @@ module Lutaml
|
|
192
192
|
def format_label(name, cardinality = {})
|
193
193
|
res = "+#{name}"
|
194
194
|
if cardinality.nil? ||
|
195
|
-
(cardinality[
|
195
|
+
(cardinality[:min].nil? || cardinality[:max].nil?)
|
196
196
|
return res
|
197
197
|
end
|
198
198
|
|
data/lib/lutaml/version.rb
CHANGED
@@ -3,15 +3,11 @@
|
|
3
3
|
module Lutaml
|
4
4
|
module XMI
|
5
5
|
class GeneralizationAttributeDrop < Liquid::Drop
|
6
|
-
|
7
|
-
"C" => "0",
|
8
|
-
"M" => "1",
|
9
|
-
}.freeze
|
10
|
-
|
11
|
-
def initialize(attr, upper_klass, gen_name) # rubocop:disable Lint/MissingSuper
|
6
|
+
def initialize(attr, upper_klass, gen_name, guidance = nil) # rubocop:disable Lint/MissingSuper
|
12
7
|
@attr = attr
|
13
8
|
@upper_klass = upper_klass
|
14
9
|
@gen_name = gen_name
|
10
|
+
@guidance = guidance
|
15
11
|
end
|
16
12
|
|
17
13
|
def id
|
@@ -35,18 +31,7 @@ module Lutaml
|
|
35
31
|
end
|
36
32
|
|
37
33
|
def cardinality
|
38
|
-
|
39
|
-
min = min.nil? ? nil : LOWER_VALUE_MAPPINGS[min]
|
40
|
-
|
41
|
-
"#{min}..#{@attr[:cardinality]['max']}"
|
42
|
-
end
|
43
|
-
|
44
|
-
def min_cardinality
|
45
|
-
@attr[:cardinality]["min"]
|
46
|
-
end
|
47
|
-
|
48
|
-
def max_cardinality
|
49
|
-
@attr[:cardinality]["max"]
|
34
|
+
::Lutaml::XMI::CardinalityDrop.new(@attr[:cardinality])
|
50
35
|
end
|
51
36
|
|
52
37
|
def definition
|
@@ -84,6 +69,25 @@ module Lutaml
|
|
84
69
|
name_ns = upper_klass if name_ns.nil?
|
85
70
|
name_ns
|
86
71
|
end
|
72
|
+
|
73
|
+
def used?
|
74
|
+
if @guidance
|
75
|
+
col_name = "#{name_ns}:#{name}"
|
76
|
+
attr = @guidance["attributes"].find { |a| a["name"] == col_name }
|
77
|
+
return attr["used"] if attr
|
78
|
+
end
|
79
|
+
|
80
|
+
true
|
81
|
+
end
|
82
|
+
|
83
|
+
def guidance
|
84
|
+
if @guidance
|
85
|
+
col_name = "#{name_ns}:#{name}"
|
86
|
+
attr = @guidance["attributes"].find { |a| a["name"] == col_name }
|
87
|
+
|
88
|
+
attr["guidance"] if attr
|
89
|
+
end
|
90
|
+
end
|
87
91
|
end
|
88
92
|
end
|
89
93
|
end
|
@@ -3,11 +3,12 @@
|
|
3
3
|
module Lutaml
|
4
4
|
module XMI
|
5
5
|
class GeneralizationDrop < Liquid::Drop
|
6
|
-
def initialize(gen) # rubocop:disable Lint/MissingSuper
|
6
|
+
def initialize(gen, guidance = nil) # rubocop:disable Lint/MissingSuper
|
7
7
|
@gen = gen
|
8
8
|
@looped_general_item = false
|
9
9
|
@inherited_props = []
|
10
10
|
@inherited_assoc_props = []
|
11
|
+
@guidance = guidance
|
11
12
|
end
|
12
13
|
|
13
14
|
def id
|
@@ -23,7 +24,7 @@ module Lutaml
|
|
23
24
|
end
|
24
25
|
|
25
26
|
def general
|
26
|
-
GeneralizationDrop.new(@gen[:general]) if @gen[:general]
|
27
|
+
GeneralizationDrop.new(@gen[:general], @guidance) if @gen[:general]
|
27
28
|
end
|
28
29
|
|
29
30
|
def has_general?
|
@@ -54,7 +55,7 @@ module Lutaml
|
|
54
55
|
attributes.select do |attr|
|
55
56
|
attr[:association].nil?
|
56
57
|
end.map do |attr|
|
57
|
-
GeneralizationAttributeDrop.new(attr, upper_klass, name)
|
58
|
+
GeneralizationAttributeDrop.new(attr, upper_klass, name, @guidance)
|
58
59
|
end
|
59
60
|
end
|
60
61
|
|
@@ -63,7 +64,7 @@ module Lutaml
|
|
63
64
|
attributes.select do |attr|
|
64
65
|
attr[:association]
|
65
66
|
end.map do |attr|
|
66
|
-
GeneralizationAttributeDrop.new(attr, upper_klass, name)
|
67
|
+
GeneralizationAttributeDrop.new(attr, upper_klass, name, @guidance)
|
67
68
|
end
|
68
69
|
end
|
69
70
|
|
@@ -89,7 +90,7 @@ module Lutaml
|
|
89
90
|
# reverse the order to show super class first
|
90
91
|
general_item.attributes.reverse_each do |attr|
|
91
92
|
attr_drop = GeneralizationAttributeDrop.new(attr, gen_upper_klass,
|
92
|
-
gen_name)
|
93
|
+
gen_name, @guidance)
|
93
94
|
if attr[:association]
|
94
95
|
@inherited_assoc_props << attr_drop
|
95
96
|
else
|
@@ -3,8 +3,17 @@
|
|
3
3
|
module Lutaml
|
4
4
|
module XMI
|
5
5
|
class KlassDrop < Liquid::Drop
|
6
|
-
def initialize(model) # rubocop:disable Lint/MissingSuper
|
6
|
+
def initialize(model, guidance = nil) # rubocop:disable Lint/MissingSuper
|
7
7
|
@model = model
|
8
|
+
@guidance = guidance
|
9
|
+
|
10
|
+
if guidance && guidance["classes"].map do |c|
|
11
|
+
c["name"]
|
12
|
+
end.include?(@model[:name])
|
13
|
+
@klass_guidance = guidance["classes"].find do |klass|
|
14
|
+
klass["name"] == @model[:name]
|
15
|
+
end
|
16
|
+
end
|
8
17
|
end
|
9
18
|
|
10
19
|
def xmi_id
|
@@ -16,7 +25,7 @@ module Lutaml
|
|
16
25
|
end
|
17
26
|
|
18
27
|
def package
|
19
|
-
::Lutaml::XMI::PackageDrop.new(@model[:package])
|
28
|
+
::Lutaml::XMI::PackageDrop.new(@model[:package], @guidance)
|
20
29
|
end
|
21
30
|
|
22
31
|
def type
|
@@ -50,7 +59,8 @@ module Lutaml
|
|
50
59
|
def generalization
|
51
60
|
return {} if @model[:generalization].nil?
|
52
61
|
|
53
|
-
::Lutaml::XMI::GeneralizationDrop.new(@model[:generalization]
|
62
|
+
::Lutaml::XMI::GeneralizationDrop.new(@model[:generalization],
|
63
|
+
@klass_guidance)
|
54
64
|
end
|
55
65
|
|
56
66
|
def is_abstract
|
@@ -3,8 +3,9 @@
|
|
3
3
|
module Lutaml
|
4
4
|
module XMI
|
5
5
|
class PackageDrop < Liquid::Drop
|
6
|
-
def initialize(model) # rubocop:disable Lint/MissingSuper
|
6
|
+
def initialize(model, guidance = nil) # rubocop:disable Lint/MissingSuper
|
7
7
|
@model = model
|
8
|
+
@guidance = guidance
|
8
9
|
@children_packages ||= packages.map do |pkg|
|
9
10
|
[pkg, pkg.packages, pkg.packages.map(&:children_packages)]
|
10
11
|
end.flatten.uniq
|
@@ -20,7 +21,7 @@ module Lutaml
|
|
20
21
|
|
21
22
|
def klasses
|
22
23
|
@model[:classes].map do |klass|
|
23
|
-
::Lutaml::XMI::KlassDrop.new(klass)
|
24
|
+
::Lutaml::XMI::KlassDrop.new(klass, @guidance)
|
24
25
|
end
|
25
26
|
end
|
26
27
|
alias classes klasses
|
@@ -45,7 +46,7 @@ module Lutaml
|
|
45
46
|
|
46
47
|
def packages
|
47
48
|
@model[:packages].map do |package|
|
48
|
-
::Lutaml::XMI::PackageDrop.new(package)
|
49
|
+
::Lutaml::XMI::PackageDrop.new(package, @guidance)
|
49
50
|
end
|
50
51
|
end
|
51
52
|
|
@@ -3,8 +3,9 @@
|
|
3
3
|
module Lutaml
|
4
4
|
module XMI
|
5
5
|
class RootDrop < Liquid::Drop
|
6
|
-
def initialize(model) # rubocop:disable Lint/MissingSuper
|
6
|
+
def initialize(model, guidance = nil) # rubocop:disable Lint/MissingSuper
|
7
7
|
@model = model
|
8
|
+
@guidance = guidance
|
8
9
|
@children_packages ||= packages.map do |pkg|
|
9
10
|
[pkg, pkg.packages, pkg.packages.map(&:children_packages)]
|
10
11
|
end.flatten.uniq
|
@@ -16,7 +17,7 @@ module Lutaml
|
|
16
17
|
|
17
18
|
def packages
|
18
19
|
@model[:packages].map do |package|
|
19
|
-
::Lutaml::XMI::PackageDrop.new(package)
|
20
|
+
::Lutaml::XMI::PackageDrop.new(package, @guidance)
|
20
21
|
end
|
21
22
|
end
|
22
23
|
|
@@ -10,10 +10,6 @@ module Lutaml
|
|
10
10
|
module Parsers
|
11
11
|
# Class for parsing .xmi schema files into ::Lutaml::Uml::Document
|
12
12
|
class XML
|
13
|
-
LOWER_VALUE_MAPPINGS = {
|
14
|
-
"0" => "C",
|
15
|
-
"1" => "M",
|
16
|
-
}.freeze
|
17
13
|
attr_reader :xmi_cache, :xmi_root_model
|
18
14
|
|
19
15
|
class << self
|
@@ -35,17 +31,17 @@ module Lutaml
|
|
35
31
|
|
36
32
|
# @param xml [String] path to xml
|
37
33
|
# @return [Liquid::Drop]
|
38
|
-
def serialize_xmi_to_liquid(xml)
|
34
|
+
def serialize_xmi_to_liquid(xml, guidance = nil)
|
39
35
|
xmi_model = get_xmi_model(xml)
|
40
|
-
new.serialize_xmi_to_liquid(xmi_model)
|
36
|
+
new.serialize_xmi_to_liquid(xmi_model, guidance)
|
41
37
|
end
|
42
38
|
|
43
39
|
# @param xml [String] path to xml
|
44
40
|
# @param name [String]
|
45
41
|
# @return [Hash]
|
46
|
-
def serialize_generalization_by_name(xml, name)
|
42
|
+
def serialize_generalization_by_name(xml, name, guidance = nil)
|
47
43
|
xmi_model = get_xmi_model(xml)
|
48
|
-
new.serialize_generalization_by_name(xmi_model, name)
|
44
|
+
new.serialize_generalization_by_name(xmi_model, name, guidance)
|
49
45
|
end
|
50
46
|
|
51
47
|
private
|
@@ -81,23 +77,32 @@ module Lutaml
|
|
81
77
|
|
82
78
|
# @param xmi_model [Shale::Mapper]
|
83
79
|
# return [Liquid::Drop]
|
84
|
-
def serialize_xmi_to_liquid(xmi_model)
|
80
|
+
def serialize_xmi_to_liquid(xmi_model, guidance_yaml = nil)
|
85
81
|
set_xmi_model(xmi_model)
|
86
82
|
serialized_hash = serialize_xmi(xmi_model, with_gen: true)
|
83
|
+
guidance = get_guidance(guidance_yaml)
|
84
|
+
::Lutaml::XMI::RootDrop.new(serialized_hash, guidance)
|
85
|
+
end
|
86
|
+
|
87
|
+
# @param yaml [String]
|
88
|
+
# @return [Hash]
|
89
|
+
def get_guidance(yaml)
|
90
|
+
return unless yaml
|
87
91
|
|
88
|
-
|
92
|
+
YAML.safe_load(File.read(yaml, encoding: "UTF-8"))
|
89
93
|
end
|
90
94
|
|
91
95
|
# @param xmi_model [Shale::Mapper]
|
92
96
|
# @param name [String]
|
93
97
|
# @return [Hash]
|
94
|
-
def serialize_generalization_by_name(xmi_model, name
|
98
|
+
def serialize_generalization_by_name(xmi_model, name,
|
99
|
+
guidance_yaml = nil)
|
95
100
|
set_xmi_model(xmi_model)
|
96
101
|
model = xmi_model.model
|
97
102
|
klass = find_klass_packaged_element_by_name(name)
|
98
103
|
serialized_hash = build_klass_hash(klass, model, with_gen: true)
|
99
|
-
|
100
|
-
::Lutaml::XMI::KlassDrop.new(serialized_hash)
|
104
|
+
guidance = get_guidance(guidance_yaml)
|
105
|
+
::Lutaml::XMI::KlassDrop.new(serialized_hash, guidance)
|
101
106
|
end
|
102
107
|
|
103
108
|
private
|
@@ -255,11 +260,10 @@ module Lutaml
|
|
255
260
|
end
|
256
261
|
|
257
262
|
# @param general_node [Shale::Mapper]
|
258
|
-
#
|
263
|
+
# @return [Hash]
|
259
264
|
def get_general_attributes(general_node)
|
260
|
-
serialize_class_attributes(general_node, with_assoc: true)
|
261
|
-
|
262
|
-
# attrs.sort_by { |i| i[:name] }
|
265
|
+
attrs = serialize_class_attributes(general_node, with_assoc: true)
|
266
|
+
attrs.sort_by { |i| i[:name].to_s }
|
263
267
|
end
|
264
268
|
|
265
269
|
# @param general_node [Shale::Mapper]
|
@@ -767,20 +771,11 @@ module Lutaml
|
|
767
771
|
# @return [Hash]
|
768
772
|
def cardinality_min_max_value(min, max)
|
769
773
|
{
|
770
|
-
|
771
|
-
|
774
|
+
min: min,
|
775
|
+
max: max,
|
772
776
|
}
|
773
777
|
end
|
774
778
|
|
775
|
-
# @param value [String]
|
776
|
-
# @param is_min [Boolean]
|
777
|
-
# @return [String]
|
778
|
-
def cardinality_value(value, is_min = false)
|
779
|
-
return unless value
|
780
|
-
|
781
|
-
is_min ? LOWER_VALUE_MAPPINGS[value.to_s] : value
|
782
|
-
end
|
783
|
-
|
784
779
|
# @node [Shale::Mapper]
|
785
780
|
# @attr_name [String]
|
786
781
|
# @return [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.18
|
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-10-
|
11
|
+
date: 2024-10-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: liquid
|