lutaml 0.9.17 → 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/version.rb +1 -1
- data/lib/lutaml/xmi/liquid_drops/generalization_attribute_drop.rb +21 -1
- 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 +18 -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: 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
|
data/lib/lutaml/version.rb
CHANGED
@@ -3,10 +3,11 @@
|
|
3
3
|
module Lutaml
|
4
4
|
module XMI
|
5
5
|
class GeneralizationAttributeDrop < Liquid::Drop
|
6
|
-
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
|
7
7
|
@attr = attr
|
8
8
|
@upper_klass = upper_klass
|
9
9
|
@gen_name = gen_name
|
10
|
+
@guidance = guidance
|
10
11
|
end
|
11
12
|
|
12
13
|
def id
|
@@ -68,6 +69,25 @@ module Lutaml
|
|
68
69
|
name_ns = upper_klass if name_ns.nil?
|
69
70
|
name_ns
|
70
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
|
71
91
|
end
|
72
92
|
end
|
73
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
|
|
@@ -31,17 +31,17 @@ module Lutaml
|
|
31
31
|
|
32
32
|
# @param xml [String] path to xml
|
33
33
|
# @return [Liquid::Drop]
|
34
|
-
def serialize_xmi_to_liquid(xml)
|
34
|
+
def serialize_xmi_to_liquid(xml, guidance = nil)
|
35
35
|
xmi_model = get_xmi_model(xml)
|
36
|
-
new.serialize_xmi_to_liquid(xmi_model)
|
36
|
+
new.serialize_xmi_to_liquid(xmi_model, guidance)
|
37
37
|
end
|
38
38
|
|
39
39
|
# @param xml [String] path to xml
|
40
40
|
# @param name [String]
|
41
41
|
# @return [Hash]
|
42
|
-
def serialize_generalization_by_name(xml, name)
|
42
|
+
def serialize_generalization_by_name(xml, name, guidance = nil)
|
43
43
|
xmi_model = get_xmi_model(xml)
|
44
|
-
new.serialize_generalization_by_name(xmi_model, name)
|
44
|
+
new.serialize_generalization_by_name(xmi_model, name, guidance)
|
45
45
|
end
|
46
46
|
|
47
47
|
private
|
@@ -77,23 +77,32 @@ module Lutaml
|
|
77
77
|
|
78
78
|
# @param xmi_model [Shale::Mapper]
|
79
79
|
# return [Liquid::Drop]
|
80
|
-
def serialize_xmi_to_liquid(xmi_model)
|
80
|
+
def serialize_xmi_to_liquid(xmi_model, guidance_yaml = nil)
|
81
81
|
set_xmi_model(xmi_model)
|
82
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
|
83
91
|
|
84
|
-
|
92
|
+
YAML.safe_load(File.read(yaml, encoding: "UTF-8"))
|
85
93
|
end
|
86
94
|
|
87
95
|
# @param xmi_model [Shale::Mapper]
|
88
96
|
# @param name [String]
|
89
97
|
# @return [Hash]
|
90
|
-
def serialize_generalization_by_name(xmi_model, name
|
98
|
+
def serialize_generalization_by_name(xmi_model, name,
|
99
|
+
guidance_yaml = nil)
|
91
100
|
set_xmi_model(xmi_model)
|
92
101
|
model = xmi_model.model
|
93
102
|
klass = find_klass_packaged_element_by_name(name)
|
94
103
|
serialized_hash = build_klass_hash(klass, model, with_gen: true)
|
95
|
-
|
96
|
-
::Lutaml::XMI::KlassDrop.new(serialized_hash)
|
104
|
+
guidance = get_guidance(guidance_yaml)
|
105
|
+
::Lutaml::XMI::KlassDrop.new(serialized_hash, guidance)
|
97
106
|
end
|
98
107
|
|
99
108
|
private
|
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
|