lutaml 0.9.22 → 0.9.24

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: b8a04369340abee752a7fd1b241302fd0eff0f8c273e9723d818f03b7c38f42f
4
- data.tar.gz: 0170f7a02d5f4a097217657825d7301ac277f601d7b5ca713a65ae6bc8b5d31f
3
+ metadata.gz: 19fd561389d0337b037854de3e9e1e3d6ec212299c9a62af17f90195972b2403
4
+ data.tar.gz: 7722f61ff3b0d5b362bdcc5a7c63ade823edfd12c63b82d7c974915429392fa1
5
5
  SHA512:
6
- metadata.gz: 0d6394b187e9b3941f274259705ffd1e13ba98ffbc1c2a17079d1ef42bea8f119db028768471b2b4076a2222420cf4f93023a2c002578624b9a10f50531b794e
7
- data.tar.gz: ca20d68f282ba839e82744a90cee46b169b3528e02dc3c7ba10be51018cfdfa3617fd6c0fefedc51089d1f382bfdeb372e6ecda2e0c469bb099fcd886b4f1faf
6
+ metadata.gz: 5993e7dce5923f0560479ecd92bdb5b7181c22c21dc41165f9448aeb6d83dac4da78aed76a77eaa65b6afae9f045c032958db9ea55638ce41b5188870231cdb0
7
+ data.tar.gz: c9b002cbd79894f25c4edf397d645190734e3352bf95477334ef973cb6d5420b8afb779f53cb929c29033aa31430db33b18259db4a069b56591a1d46ed3da08d
@@ -1,3 +1,3 @@
1
1
  module Lutaml
2
- VERSION = "0.9.22".freeze
2
+ VERSION = "0.9.24".freeze
3
3
  end
@@ -7,11 +7,9 @@ module Lutaml
7
7
  @model = model
8
8
  @guidance = guidance
9
9
 
10
- if guidance && guidance["classes"].map do |c|
11
- c["name"]
12
- end.include?(@model[:name])
10
+ if guidance
13
11
  @klass_guidance = guidance["classes"].find do |klass|
14
- klass["name"] == @model[:name]
12
+ klass["name"] == name || klass["name"] == absolute_path
15
13
  end
16
14
  end
17
15
  end
@@ -24,6 +22,10 @@ module Lutaml
24
22
  @model[:name]
25
23
  end
26
24
 
25
+ def absolute_path
26
+ "#{@model[:absolute_path]}::#{name}"
27
+ end
28
+
27
29
  def package
28
30
  ::Lutaml::XMI::PackageDrop.new(@model[:package], @guidance)
29
31
  end
@@ -6,6 +6,7 @@ module Lutaml
6
6
  def initialize(model, guidance = nil) # rubocop:disable Lint/MissingSuper
7
7
  @model = model
8
8
  @guidance = guidance
9
+
9
10
  @children_packages ||= packages.map do |pkg|
10
11
  [pkg, pkg.packages, pkg.packages.map(&:children_packages)]
11
12
  end.flatten.uniq
@@ -19,6 +20,10 @@ module Lutaml
19
20
  @model[:name]
20
21
  end
21
22
 
23
+ def absolute_path
24
+ @model[:absolute_path]
25
+ end
26
+
22
27
  def klasses
23
28
  @model[:classes].map do |klass|
24
29
  ::Lutaml::XMI::KlassDrop.new(klass, @guidance)
@@ -70,17 +70,28 @@ module Lutaml
70
70
  end
71
71
 
72
72
  # @param xmi_model [Shale::Mapper]
73
+ # @param with_gen: [Boolean]
74
+ # @param with_absolute_path: [Boolean]
73
75
  # return [Hash]
74
- def serialize_xmi(xmi_model, with_gen: false)
76
+ def serialize_xmi(xmi_model, with_gen: false, with_absolute_path: false)
75
77
  set_xmi_model(xmi_model)
76
- serialize_to_hash(xmi_model, with_gen: with_gen)
78
+ serialize_to_hash(
79
+ xmi_model,
80
+ with_gen: with_gen,
81
+ with_absolute_path: with_absolute_path,
82
+ )
77
83
  end
78
84
 
79
85
  # @param xmi_model [Shale::Mapper]
86
+ # @param guidance_yaml [String]
80
87
  # return [Liquid::Drop]
81
88
  def serialize_xmi_to_liquid(xmi_model, guidance_yaml = nil)
82
89
  set_xmi_model(xmi_model)
83
- serialized_hash = serialize_xmi(xmi_model, with_gen: true)
90
+ serialized_hash = serialize_xmi(
91
+ xmi_model,
92
+ with_gen: true,
93
+ with_absolute_path: true,
94
+ )
84
95
  guidance = get_guidance(guidance_yaml)
85
96
  ::Lutaml::XMI::RootDrop.new(serialized_hash, guidance)
86
97
  end
@@ -110,38 +121,67 @@ module Lutaml
110
121
  private
111
122
 
112
123
  # @param xmi_model [Shale::Mapper]
124
+ # @param with_gen: [Boolean]
125
+ # @param with_absolute_path: [Boolean]
113
126
  # @return [Hash]
114
127
  # @note xpath: //uml:Model[@xmi:type="uml:Model"]
115
- def serialize_to_hash(xmi_model, with_gen: false)
128
+ def serialize_to_hash(xmi_model,
129
+ with_gen: false, with_absolute_path: false)
116
130
  model = xmi_model.model
117
131
  {
118
132
  name: model.name,
119
- packages: serialize_model_packages(model, with_gen: with_gen),
133
+ packages: serialize_model_packages(
134
+ model,
135
+ with_gen: with_gen,
136
+ with_absolute_path: with_absolute_path,
137
+ ),
120
138
  }
121
139
  end
122
140
 
123
141
  # @param model [Shale::Mapper]
124
142
  # @param with_gen: [Boolean]
143
+ # @param with_absolute_path: [Boolean]
144
+ # @param absolute_path: [String]
125
145
  # @return [Array<Hash>]
126
146
  # @note xpath ./packagedElement[@xmi:type="uml:Package"]
127
- def serialize_model_packages(model, with_gen: false) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
147
+ def serialize_model_packages(model, # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
148
+ with_gen: false, with_absolute_path: false, absolute_path: "")
128
149
  packages = model.packaged_element.select do |e|
129
150
  e.type?("uml:Package")
130
151
  end
131
152
 
153
+ if with_absolute_path
154
+ absolute_path = "#{absolute_path}::#{model.name}"
155
+ end
156
+
132
157
  packages.map do |package|
133
- {
158
+ h = {
134
159
  xmi_id: package.id,
135
160
  name: get_package_name(package),
136
- classes: serialize_model_classes(package, model,
137
- with_gen: with_gen),
161
+ classes: serialize_model_classes(
162
+ package, model,
163
+ with_gen: with_gen,
164
+ with_absolute_path: with_absolute_path,
165
+ absolute_path: "#{absolute_path}::#{package.name}"
166
+ ),
138
167
  enums: serialize_model_enums(package),
139
168
  data_types: serialize_model_data_types(package),
140
169
  diagrams: serialize_model_diagrams(package.id),
141
- packages: serialize_model_packages(package, with_gen: with_gen),
170
+ packages: serialize_model_packages(
171
+ package,
172
+ with_gen: with_gen,
173
+ with_absolute_path: with_absolute_path,
174
+ absolute_path: absolute_path,
175
+ ),
142
176
  definition: doc_node_attribute_value(package.id, "documentation"),
143
177
  stereotype: doc_node_attribute_value(package.id, "stereotype"),
144
178
  }
179
+
180
+ if with_absolute_path
181
+ h[:absolute_path] = "#{absolute_path}::#{package.name}"
182
+ end
183
+
184
+ h
145
185
  end
146
186
  end
147
187
 
@@ -162,28 +202,36 @@ module Lutaml
162
202
  # @param package [Shale::Mapper]
163
203
  # @param model [Shale::Mapper]
164
204
  # @param with_gen: [Boolean]
205
+ # @param with_absolute_path: [Boolean]
165
206
  # @return [Array<Hash>]
166
207
  # @note xpath ./packagedElement[@xmi:type="uml:Class" or
167
208
  # @xmi:type="uml:AssociationClass"]
168
- def serialize_model_classes(package, model, with_gen: false) # rubocop:disable Metrics/MethodLength
209
+ def serialize_model_classes(package, model, # rubocop:disable Metrics/MethodLength
210
+ with_gen: false, with_absolute_path: false, absolute_path: "")
169
211
  klasses = package.packaged_element.select do |e|
170
212
  e.type?("uml:Class") || e.type?("uml:AssociationClass") ||
171
213
  e.type?("uml:Interface")
172
214
  end
173
215
 
174
216
  klasses.map do |klass|
175
- build_klass_hash(
217
+ h = build_klass_hash(
176
218
  klass, model,
177
219
  with_gen: with_gen
178
220
  )
221
+
222
+ h[:absolute_path] = absolute_path if with_absolute_path
223
+
224
+ h
179
225
  end
180
226
  end
181
227
 
182
228
  # @param klass [Shale::Mapper]
183
229
  # @param model [Shale::Mapper]
184
230
  # @param with_gen: [Boolean]
231
+ # @param with_absolute_path: [Boolean]
185
232
  # @return [Hash]
186
- def build_klass_hash(klass, model, with_gen: false) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
233
+ def build_klass_hash(klass, model, # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
234
+ with_gen: false, with_absolute_path: false, absolute_path: "")
187
235
  klass_hash = {
188
236
  xmi_id: klass.id,
189
237
  name: klass.name,
@@ -198,6 +246,8 @@ module Lutaml
198
246
  stereotype: doc_node_attribute_value(klass.id, "stereotype"),
199
247
  }
200
248
 
249
+ klass_hash[:absolute_path] = absolute_path if with_absolute_path
250
+
201
251
  if with_gen && klass.type?("uml:Class")
202
252
  klass_hash[:generalization] = serialize_generalization(klass)
203
253
  end
data/lutaml.gemspec CHANGED
@@ -29,7 +29,7 @@ Gem::Specification.new do |spec|
29
29
 
30
30
  spec.required_ruby_version = ">= 2.7.0"
31
31
 
32
- spec.add_dependency "expressir", "~> 1.3"
32
+ spec.add_dependency "expressir", "~> 2.1.0"
33
33
  spec.add_dependency "hashie", "~> 4.1.0"
34
34
  spec.add_dependency "htmlentities"
35
35
  spec.add_dependency "liquid"
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.22
4
+ version: 0.9.24
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-13 00:00:00.000000000 Z
11
+ date: 2024-11-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: expressir
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.3'
19
+ version: 2.1.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.3'
26
+ version: 2.1.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: hashie
29
29
  requirement: !ruby/object:Gem::Requirement