lutaml 0.9.19 → 0.9.20
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 73252a1880283e31b2954654b4e046f1eda11e43eb3bd4eaf75e5e066ddaf539
|
4
|
+
data.tar.gz: 0e189f762028fe432169d63a19755f1fea34ca22575beb454bbdcbe46219bf4e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 99014430718d84a8e56361b06962ddeb75ba369e05d54d53a1b55d181ba681c4a3d04c5a31c40e1142ca4621e91a063e3ac7767d6feb859d276f6cd23406cb56
|
7
|
+
data.tar.gz: e484203747c7501e8ec17ae454e72ffeba6fdf72d29edf673ddb6274ae9925435fe8e6389014b463635f45debecba9ca4c5cb96e4865a211589bb3b3a4a37679
|
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.20
|
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-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: liquid
|