lutaml 0.9.19 → 0.9.21
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aa2001799c50e05bc06d6f3f916a58ebb637c0ec5f2179b93d32b9983018c2f3
|
4
|
+
data.tar.gz: 482a18f5e8b462b23621d05e8790b1d6f650f2ac8ac3169f40915f2f88e8212a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 91e3ded5751df8d330c86fb909c3124ddc386c2f4a1fadd9e3f0a0ecfd4f60276c3e98d67f09e4819e585bf65c401c0a6173ad406b3227d9ebec4726f00103fd
|
7
|
+
data.tar.gz: 36668d33ab9be1528af87c4433e51ca73ce9f137bce9dd58c511aaf0ec3b3e410556097c2df5d0f35d34db970809b3c625a413c931dd01cb845b34ecf2f963c9
|
data/lib/lutaml/version.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
module Lutaml
|
4
4
|
module XMI
|
5
5
|
class GeneralizationAttributeDrop < Liquid::Drop
|
6
|
-
def initialize(attr, upper_klass, gen_name, guidance = nil) # rubocop:disable Lint/MissingSuper
|
6
|
+
def initialize(attr, upper_klass, gen_name, guidance = nil) # rubocop:disable Lint/MissingSuper,Metrics/ParameterLists,Layout/LineLength
|
7
7
|
@attr = attr
|
8
8
|
@upper_klass = upper_klass
|
9
9
|
@gen_name = gen_name
|
@@ -26,7 +26,7 @@ module Lutaml
|
|
26
26
|
@attr[:xmi_id]
|
27
27
|
end
|
28
28
|
|
29
|
-
def is_derived
|
29
|
+
def is_derived # rubocop:disable Naming/PredicateName
|
30
30
|
@attr[:is_derived]
|
31
31
|
end
|
32
32
|
|
@@ -59,15 +59,7 @@ module Lutaml
|
|
59
59
|
end
|
60
60
|
|
61
61
|
def name_ns
|
62
|
-
|
63
|
-
when "core", "gml"
|
64
|
-
upper_klass
|
65
|
-
else
|
66
|
-
@attr[:type_ns]
|
67
|
-
end
|
68
|
-
|
69
|
-
name_ns = upper_klass if name_ns.nil?
|
70
|
-
name_ns
|
62
|
+
@attr[:name_ns]
|
71
63
|
end
|
72
64
|
|
73
65
|
def used?
|
@@ -32,10 +32,19 @@ module Lutaml
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def attributes
|
35
|
-
@gen[:general_attributes]
|
36
|
-
|
37
|
-
|
38
|
-
|
35
|
+
attrs = @gen[:general_attributes]
|
36
|
+
attrs.each do |i|
|
37
|
+
name_ns = case i[:type_ns]
|
38
|
+
when "core", "gml"
|
39
|
+
upper_klass
|
40
|
+
else
|
41
|
+
i[:type_ns]
|
42
|
+
end
|
43
|
+
name_ns = upper_klass if name_ns.nil?
|
44
|
+
|
45
|
+
i[:name_ns] = name_ns
|
46
|
+
i[:name] = "" if i[:name].nil?
|
47
|
+
end
|
39
48
|
end
|
40
49
|
|
41
50
|
def type
|
@@ -51,53 +60,112 @@ module Lutaml
|
|
51
60
|
end
|
52
61
|
|
53
62
|
# get attributes without association
|
54
|
-
def owned_props
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
63
|
+
def owned_props(sort: false)
|
64
|
+
return [] unless attributes
|
65
|
+
|
66
|
+
props = attributes.select { |attr| attr[:association].nil? }
|
67
|
+
props = sort_props(props) if sort
|
68
|
+
props_to_liquid(props)
|
60
69
|
end
|
61
70
|
|
62
71
|
# get attributes with association
|
63
|
-
def assoc_props
|
64
|
-
|
65
|
-
|
66
|
-
|
72
|
+
def assoc_props(sort: false)
|
73
|
+
return [] unless attributes
|
74
|
+
|
75
|
+
props = attributes.select { |attr| attr[:association].nil? == false }
|
76
|
+
props = sort_props(props) if sort
|
77
|
+
props_to_liquid(props)
|
78
|
+
end
|
79
|
+
|
80
|
+
def props_to_liquid(props)
|
81
|
+
props.map do |attr|
|
67
82
|
GeneralizationAttributeDrop.new(attr, upper_klass, name, @guidance)
|
68
83
|
end
|
69
84
|
end
|
70
85
|
|
71
86
|
# get items without association by looping through the generation
|
72
|
-
def inherited_props
|
87
|
+
def inherited_props(sort: false)
|
73
88
|
loop_general_item unless @looped_general_item
|
74
89
|
|
75
|
-
@inherited_props.reverse
|
90
|
+
props = @inherited_props.reverse
|
91
|
+
props = sort_props_with_level(props) if sort
|
92
|
+
props_hash_to_liquid(props)
|
76
93
|
end
|
77
94
|
|
78
95
|
# get items with association by looping through the generation
|
79
|
-
def inherited_assoc_props
|
96
|
+
def inherited_assoc_props(sort: false)
|
80
97
|
loop_general_item unless @looped_general_item
|
81
98
|
|
82
|
-
@inherited_assoc_props.reverse
|
99
|
+
props = @inherited_assoc_props.reverse
|
100
|
+
props = sort_props_with_level(props) if sort
|
101
|
+
props_hash_to_liquid(props)
|
102
|
+
end
|
103
|
+
|
104
|
+
def sort_props_with_level(arr)
|
105
|
+
return [] if arr.nil? || arr.empty?
|
106
|
+
|
107
|
+
# level desc, name_ns asc, name asc
|
108
|
+
arr.sort_by { |i| [-i[:level], i[:attr][:name_ns], i[:attr][:name]] }
|
109
|
+
end
|
110
|
+
|
111
|
+
def props_hash_to_liquid(prop_hash_arr)
|
112
|
+
prop_hash_arr.map do |prop_hash|
|
113
|
+
GeneralizationAttributeDrop.new(
|
114
|
+
prop_hash[:attr],
|
115
|
+
prop_hash[:gen_upper_klass],
|
116
|
+
prop_hash[:gen_name],
|
117
|
+
prop_hash[:guidance],
|
118
|
+
)
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
def sorted_owned_props
|
123
|
+
owned_props(sort: true)
|
124
|
+
end
|
125
|
+
|
126
|
+
def sorted_assoc_props
|
127
|
+
assoc_props(sort: true)
|
83
128
|
end
|
84
129
|
|
85
|
-
def
|
130
|
+
def sorted_inherited_props
|
131
|
+
inherited_props(sort: true)
|
132
|
+
end
|
133
|
+
|
134
|
+
def sorted_inherited_assoc_props
|
135
|
+
inherited_assoc_props(sort: true)
|
136
|
+
end
|
137
|
+
|
138
|
+
def sort_props(arr)
|
139
|
+
return [] if arr.nil? || arr.empty?
|
140
|
+
|
141
|
+
arr.sort_by { |i| [i[:name_ns], i[:name]] }
|
142
|
+
end
|
143
|
+
|
144
|
+
def loop_general_item # rubocop:disable Metrics/MethodLength,Metrics/AbcSize
|
86
145
|
general_item = general
|
146
|
+
level = 0
|
147
|
+
|
87
148
|
while general_item.has_general?
|
88
149
|
gen_upper_klass = general_item.upper_klass
|
89
150
|
gen_name = general_item.name
|
90
151
|
# reverse the order to show super class first
|
91
152
|
general_item.attributes.reverse_each do |attr|
|
92
|
-
|
93
|
-
|
153
|
+
attr_hash = {
|
154
|
+
attr: attr,
|
155
|
+
gen_upper_klass: gen_upper_klass,
|
156
|
+
gen_name: gen_name,
|
157
|
+
guidance: @guidance,
|
158
|
+
}
|
159
|
+
attr_hash[:level] = level
|
160
|
+
|
94
161
|
if attr[:association]
|
95
|
-
@inherited_assoc_props <<
|
162
|
+
@inherited_assoc_props << attr_hash
|
96
163
|
else
|
97
|
-
@inherited_props <<
|
164
|
+
@inherited_props << attr_hash
|
98
165
|
end
|
99
166
|
end
|
100
167
|
|
168
|
+
level += 1
|
101
169
|
general_item = general_item.general
|
102
170
|
end
|
103
171
|
|
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.21
|
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-
|
11
|
+
date: 2024-11-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: liquid
|