lutaml 0.9.21 → 0.9.22
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 +82 -9
- data/lib/lutaml/xmi.rb +1 -0
- data/lutaml.gemspec +12 -10
- metadata +31 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b8a04369340abee752a7fd1b241302fd0eff0f8c273e9723d818f03b7c38f42f
|
4
|
+
data.tar.gz: 0170f7a02d5f4a097217657825d7301ac277f601d7b5ca713a65ae6bc8b5d31f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0d6394b187e9b3941f274259705ffd1e13ba98ffbc1c2a17079d1ef42bea8f119db028768471b2b4076a2222420cf4f93023a2c002578624b9a10f50531b794e
|
7
|
+
data.tar.gz: ca20d68f282ba839e82744a90cee46b169b3528e02dc3c7ba10be51018cfdfa3617fd6c0fefedc51089d1f382bfdeb372e6ecda2e0c469bb099fcd886b4f1faf
|
data/lib/lutaml/version.rb
CHANGED
@@ -38,6 +38,7 @@ module Lutaml
|
|
38
38
|
|
39
39
|
# @param xml [String] path to xml
|
40
40
|
# @param name [String]
|
41
|
+
# @param guidance [String]
|
41
42
|
# @return [Hash]
|
42
43
|
def serialize_generalization_by_name(xml, name, guidance = nil)
|
43
44
|
xmi_model = get_xmi_model(xml)
|
@@ -94,12 +95,13 @@ module Lutaml
|
|
94
95
|
|
95
96
|
# @param xmi_model [Shale::Mapper]
|
96
97
|
# @param name [String]
|
98
|
+
# @param guidance_yaml [String]
|
97
99
|
# @return [Hash]
|
98
100
|
def serialize_generalization_by_name(xmi_model, name,
|
99
101
|
guidance_yaml = nil)
|
100
102
|
set_xmi_model(xmi_model)
|
101
103
|
model = xmi_model.model
|
102
|
-
klass =
|
104
|
+
klass = find_klass_packaged_element(name)
|
103
105
|
serialized_hash = build_klass_hash(klass, model, with_gen: true)
|
104
106
|
guidance = get_guidance(guidance_yaml)
|
105
107
|
::Lutaml::XMI::KlassDrop.new(serialized_hash, guidance)
|
@@ -119,12 +121,15 @@ module Lutaml
|
|
119
121
|
end
|
120
122
|
|
121
123
|
# @param model [Shale::Mapper]
|
124
|
+
# @param with_gen: [Boolean]
|
122
125
|
# @return [Array<Hash>]
|
123
126
|
# @note xpath ./packagedElement[@xmi:type="uml:Package"]
|
124
|
-
def serialize_model_packages(model, with_gen: false)
|
125
|
-
model.packaged_element.select do |e|
|
127
|
+
def serialize_model_packages(model, with_gen: false) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
|
128
|
+
packages = model.packaged_element.select do |e|
|
126
129
|
e.type?("uml:Package")
|
127
|
-
end
|
130
|
+
end
|
131
|
+
|
132
|
+
packages.map do |package|
|
128
133
|
{
|
129
134
|
xmi_id: package.id,
|
130
135
|
name: get_package_name(package),
|
@@ -140,7 +145,9 @@ module Lutaml
|
|
140
145
|
end
|
141
146
|
end
|
142
147
|
|
143
|
-
|
148
|
+
# @param package [Shale::Mapper]
|
149
|
+
# @return [String]
|
150
|
+
def get_package_name(package) # rubocop:disable Metrics/AbcSize
|
144
151
|
return package.name unless package.name.nil?
|
145
152
|
|
146
153
|
connector = fetch_connector(package.id)
|
@@ -154,20 +161,27 @@ module Lutaml
|
|
154
161
|
|
155
162
|
# @param package [Shale::Mapper]
|
156
163
|
# @param model [Shale::Mapper]
|
164
|
+
# @param with_gen: [Boolean]
|
157
165
|
# @return [Array<Hash>]
|
158
166
|
# @note xpath ./packagedElement[@xmi:type="uml:Class" or
|
159
167
|
# @xmi:type="uml:AssociationClass"]
|
160
|
-
def serialize_model_classes(package, model, with_gen: false)
|
161
|
-
package.packaged_element.select do |e|
|
168
|
+
def serialize_model_classes(package, model, with_gen: false) # rubocop:disable Metrics/MethodLength
|
169
|
+
klasses = package.packaged_element.select do |e|
|
162
170
|
e.type?("uml:Class") || e.type?("uml:AssociationClass") ||
|
163
171
|
e.type?("uml:Interface")
|
164
|
-
end
|
165
|
-
|
172
|
+
end
|
173
|
+
|
174
|
+
klasses.map do |klass|
|
175
|
+
build_klass_hash(
|
176
|
+
klass, model,
|
177
|
+
with_gen: with_gen
|
178
|
+
)
|
166
179
|
end
|
167
180
|
end
|
168
181
|
|
169
182
|
# @param klass [Shale::Mapper]
|
170
183
|
# @param model [Shale::Mapper]
|
184
|
+
# @param with_gen: [Boolean]
|
171
185
|
# @return [Hash]
|
172
186
|
def build_klass_hash(klass, model, with_gen: false) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
|
173
187
|
klass_hash = {
|
@@ -308,6 +322,65 @@ module Lutaml
|
|
308
322
|
upper_klass&.name
|
309
323
|
end
|
310
324
|
|
325
|
+
# @param path [String]
|
326
|
+
# @return [Shale::Mapper]
|
327
|
+
def find_klass_packaged_element(path)
|
328
|
+
lutaml_path = Lutaml::Path.parse(path)
|
329
|
+
if lutaml_path.segments.count == 1
|
330
|
+
return find_klass_packaged_element_by_name(path)
|
331
|
+
end
|
332
|
+
|
333
|
+
find_klass_packaged_element_by_path(lutaml_path)
|
334
|
+
end
|
335
|
+
|
336
|
+
# @param path [Lutaml::Path::ElementPath]
|
337
|
+
# @return [Shale::Mapper]
|
338
|
+
def find_klass_packaged_element_by_path(path)
|
339
|
+
if path.absolute?
|
340
|
+
iterate_packaged_element(
|
341
|
+
@xmi_root_model.model, path.segments.map(&:name)
|
342
|
+
)
|
343
|
+
else
|
344
|
+
iterate_relative_packaged_element(path.segments.map(&:name))
|
345
|
+
end
|
346
|
+
end
|
347
|
+
|
348
|
+
# @param name_array [Array<String>]
|
349
|
+
# @return [Shale::Mapper]
|
350
|
+
def iterate_relative_packaged_element(name_array)
|
351
|
+
# match the first element in the name_array
|
352
|
+
matched_elements = all_packaged_elements.select do |e|
|
353
|
+
e.type?("uml:Package") && e.name == name_array[0]
|
354
|
+
end
|
355
|
+
|
356
|
+
# match the rest elements in the name_array
|
357
|
+
result = matched_elements.map do |e|
|
358
|
+
iterate_packaged_element(e, name_array, type: "uml:Class")
|
359
|
+
end
|
360
|
+
|
361
|
+
result.compact.first
|
362
|
+
end
|
363
|
+
|
364
|
+
# @param model [Shale::Mapper]
|
365
|
+
# @param name_array [Array<String>]
|
366
|
+
# @param index: [Integer]
|
367
|
+
# @param type: [String]
|
368
|
+
# @return [Shale::Mapper]
|
369
|
+
def iterate_packaged_element(model, name_array,
|
370
|
+
index: 1, type: "uml:Package")
|
371
|
+
return model if index == name_array.count
|
372
|
+
|
373
|
+
model = model.packaged_element.find do |p|
|
374
|
+
p.name == name_array[index] && p.type?(type)
|
375
|
+
end
|
376
|
+
|
377
|
+
return nil if model.nil?
|
378
|
+
|
379
|
+
index += 1
|
380
|
+
type = index == name_array.count - 1 ? "uml:Class" : "uml:Package"
|
381
|
+
iterate_packaged_element(model, name_array, index: index, type: type)
|
382
|
+
end
|
383
|
+
|
311
384
|
# @param name [String]
|
312
385
|
# @return [Shale::Mapper]
|
313
386
|
def find_klass_packaged_element_by_name(name)
|
data/lib/lutaml/xmi.rb
CHANGED
data/lutaml.gemspec
CHANGED
@@ -29,15 +29,16 @@ Gem::Specification.new do |spec|
|
|
29
29
|
|
30
30
|
spec.required_ruby_version = ">= 2.7.0"
|
31
31
|
|
32
|
-
spec.
|
33
|
-
spec.
|
34
|
-
spec.
|
35
|
-
spec.
|
36
|
-
spec.
|
37
|
-
spec.
|
38
|
-
spec.
|
39
|
-
spec.
|
40
|
-
spec.
|
32
|
+
spec.add_dependency "expressir", "~> 1.3"
|
33
|
+
spec.add_dependency "hashie", "~> 4.1.0"
|
34
|
+
spec.add_dependency "htmlentities"
|
35
|
+
spec.add_dependency "liquid"
|
36
|
+
spec.add_dependency "lutaml-path"
|
37
|
+
spec.add_dependency "nokogiri", "~> 1.10"
|
38
|
+
spec.add_dependency "parslet", "~> 2.0.0"
|
39
|
+
spec.add_dependency "ruby-graphviz", "~> 1.2"
|
40
|
+
spec.add_dependency "thor", "~> 1.0"
|
41
|
+
spec.add_dependency "xmi", "~> 0.3.10"
|
41
42
|
|
42
43
|
spec.add_development_dependency "byebug"
|
43
44
|
spec.add_development_dependency "equivalent-xml", "~> 0.6.0"
|
@@ -46,4 +47,5 @@ Gem::Specification.new do |spec|
|
|
46
47
|
spec.add_development_dependency "rspec", "~> 3.11"
|
47
48
|
spec.add_development_dependency "rubocop", "~> 1.58"
|
48
49
|
spec.add_development_dependency "rubocop-performance", "~> 1.19"
|
49
|
-
|
50
|
+
spec.metadata["rubygems_mfa_required"] = "true"
|
51
|
+
end
|
metadata
CHANGED
@@ -1,29 +1,15 @@
|
|
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.22
|
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-
|
11
|
+
date: 2024-11-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: liquid
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: expressir
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,6 +52,34 @@ dependencies:
|
|
66
52
|
- - ">="
|
67
53
|
- !ruby/object:Gem::Version
|
68
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: liquid
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: lutaml-path
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: nokogiri
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -396,6 +410,7 @@ metadata:
|
|
396
410
|
homepage_uri: https://github.com/lutaml/lutaml
|
397
411
|
source_code_uri: https://github.com/lutaml/lutaml
|
398
412
|
changelog_uri: https://github.com/lutaml/lutaml/releases
|
413
|
+
rubygems_mfa_required: 'true'
|
399
414
|
post_install_message:
|
400
415
|
rdoc_options: []
|
401
416
|
require_paths:
|