lutaml 0.9.24 → 0.9.26

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: 19fd561389d0337b037854de3e9e1e3d6ec212299c9a62af17f90195972b2403
4
- data.tar.gz: 7722f61ff3b0d5b362bdcc5a7c63ade823edfd12c63b82d7c974915429392fa1
3
+ metadata.gz: 63135b601a74ae7525807e9b57974a2db686e49f6e6992918e7d209bdbf27460
4
+ data.tar.gz: 529878c2d79c6f35130ef8c34eb5223d16c46a10f96cf470e43c8563457491a8
5
5
  SHA512:
6
- metadata.gz: 5993e7dce5923f0560479ecd92bdb5b7181c22c21dc41165f9448aeb6d83dac4da78aed76a77eaa65b6afae9f045c032958db9ea55638ce41b5188870231cdb0
7
- data.tar.gz: c9b002cbd79894f25c4edf397d645190734e3352bf95477334ef973cb6d5420b8afb779f53cb929c29033aa31430db33b18259db4a069b56591a1d46ed3da08d
6
+ metadata.gz: e70e2318f24f4a6c6beccdd8c6db99f8674ab92b7763a398ffc3b2617b6a44b2ef2b431fa039d5cabe58719d7660c96f2bde96c3dc8ecfc9fd904de7ac025cc9
7
+ data.tar.gz: 61f20ab2448dfaf836a698b1596ec0685f3d90380bcf2829e08ebda2f7b39dffddb9b0913609ccb682df77a66d2ada3f69e90071556a422a973eda5784942732
@@ -1,3 +1,3 @@
1
1
  module Lutaml
2
- VERSION = "0.9.24".freeze
2
+ VERSION = "0.9.26".freeze
3
3
  end
@@ -18,6 +18,14 @@ module Lutaml
18
18
  def definition
19
19
  @model[:definition]
20
20
  end
21
+
22
+ def package_id
23
+ @model[:package_id]
24
+ end
25
+
26
+ def package_name
27
+ @model[:package_name]
28
+ end
21
29
  end
22
30
  end
23
31
  end
@@ -154,7 +154,7 @@ module Lutaml
154
154
  absolute_path = "#{absolute_path}::#{model.name}"
155
155
  end
156
156
 
157
- packages.map do |package|
157
+ packages.map do |package| # rubocop:disable Metrics/BlockLength
158
158
  h = {
159
159
  xmi_id: package.id,
160
160
  name: get_package_name(package),
@@ -166,7 +166,10 @@ module Lutaml
166
166
  ),
167
167
  enums: serialize_model_enums(package),
168
168
  data_types: serialize_model_data_types(package),
169
- diagrams: serialize_model_diagrams(package.id),
169
+ diagrams: serialize_model_diagrams(
170
+ package.id,
171
+ with_package: with_gen,
172
+ ),
170
173
  packages: serialize_model_packages(
171
174
  package,
172
175
  with_gen: with_gen,
@@ -508,17 +511,25 @@ module Lutaml
508
511
  # @param node_id [String]
509
512
  # @return [Array<Hash>]
510
513
  # @note xpath %(//diagrams/diagram/model[@package="#{node['xmi:id']}"])
511
- def serialize_model_diagrams(node_id)
514
+ def serialize_model_diagrams(node_id, with_package: false) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
512
515
  diagrams = @xmi_root_model.extension.diagrams.diagram.select do |d|
513
516
  d.model.package == node_id
514
517
  end
515
518
 
516
519
  diagrams.map do |diagram|
517
- {
520
+ h = {
518
521
  xmi_id: diagram.id,
519
522
  name: diagram.properties.name,
520
523
  definition: diagram.properties.documentation,
521
524
  }
525
+
526
+ if with_package
527
+ package_id = diagram.model.package
528
+ h[:package_id] = package_id
529
+ h[:package_name] = find_packaged_element_by_id(package_id)&.name
530
+ end
531
+
532
+ h
522
533
  end
523
534
  end
524
535
 
@@ -806,7 +817,7 @@ module Lutaml
806
817
  if with_assoc && oa.association
807
818
  attrs[:association] = oa.association
808
819
  attrs[:definition] = loopup_assoc_def(oa.association)
809
- attrs[:type_ns] = get_ns_by_type(attrs[:type])
820
+ attrs[:type_ns] = get_ns_by_xmi_id(attrs[:xmi_id])
810
821
  end
811
822
 
812
823
  attrs
@@ -868,6 +879,17 @@ module Lutaml
868
879
  find_upper_level_packaged_element(p.id)
869
880
  end
870
881
 
882
+ # @param xmi_id [String]
883
+ # @return [String]
884
+ def get_ns_by_xmi_id(xmi_id)
885
+ return unless xmi_id
886
+
887
+ p = find_packaged_element_by_id(xmi_id)
888
+ return unless p
889
+
890
+ find_upper_level_packaged_element(p.id)
891
+ end
892
+
871
893
  # @param klass_id [String]
872
894
  # @return [Array<Hash>]
873
895
  def build_class_attributes(owned_attr) # rubocop:disable Metrics/MethodLength
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.24
4
+ version: 0.9.26
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-11-20 00:00:00.000000000 Z
11
+ date: 2025-01-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: expressir
@@ -411,7 +411,7 @@ metadata:
411
411
  source_code_uri: https://github.com/lutaml/lutaml
412
412
  changelog_uri: https://github.com/lutaml/lutaml/releases
413
413
  rubygems_mfa_required: 'true'
414
- post_install_message:
414
+ post_install_message:
415
415
  rdoc_options: []
416
416
  require_paths:
417
417
  - lib
@@ -427,7 +427,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
427
427
  version: '0'
428
428
  requirements: []
429
429
  rubygems_version: 3.3.27
430
- signing_key:
430
+ signing_key:
431
431
  specification_version: 4
432
432
  summary: 'LutaML: data models in textual form'
433
433
  test_files: []