lutaml-xmi 0.1.4 → 0.1.5

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: a00a23b9d7e93a56e34c86e1aebb2c4e4917ace9fed7ed50926d2bb9242931b1
4
- data.tar.gz: cfde230682ae5f9c6fc6b5092443ac738a53442d6b9955902904cc5fb290a843
3
+ metadata.gz: 7aa59d686f5cec8d4bc3f145fdb89e7f56cc144ad573e2cf6743201a319b8414
4
+ data.tar.gz: 347bb418b224b5e7f565b2cdabb10edf63a13ffeef61017c324fbaaec1163066
5
5
  SHA512:
6
- metadata.gz: d92ce6ba9d8e008912d9647be32c1f784621cd3a292b37918b84e8cca28adc1e1bd6e1ddaa721c7b6209de1095f6f656c9dc5fe39d1b3bb0341306376236ae57
7
- data.tar.gz: d18f47d8da98bcf892ee5aa9de530b02c6222de41afa8770d026cbc5a98f84f966025f31a87488d12af07a76f27b0deb2109a6eb6effd53c76a0d7369203b871
6
+ metadata.gz: 66197ddf677dccaf10859e3ce997dc91c96c5135306db310030d802c63637b4a21adc3978c23d73c4fc2a19b6502d6dc314f1b99a2379b4b82dcf863fd8f21a0
7
+ data.tar.gz: acbd3a66c75abc3ebe8ef6c14019db023984b94f060202a49f27c811d6b00f1cd5edc3b6bde80df7873587cfd2e00b1c2588f7db9031c1827644aba5a5d42097
@@ -117,18 +117,30 @@ module Lutaml
117
117
  return generalization_association(owned_xmi_id, link) if link.name == "Generalization"
118
118
 
119
119
  xmi_id = link.attributes["start"].value
120
- member_end = lookup_entity_name(xmi_id)
121
-
122
- member_end_node = if link.name == "Association"
123
- link_xmk_id = link["xmi:id"]
124
- main_model.xpath(%(//packagedElement[@xmi:id="#{link_xmk_id}"]//type[@xmi:idref="#{xmi_id}"])).first
125
- else
126
- main_model.xpath(%(//ownedAttribute[@association]/type[@xmi:idref="#{xmi_id}"])).first
127
- end
128
- if member_end_node
129
- assoc = member_end_node.parent
130
- member_end_cardinality = { "min" => cardinality_min_value(assoc), "max" => cardinality_max_value(assoc) }
131
- member_end_attribute_name = assoc.attributes["name"]&.value
120
+ member_end = lookup_entity_name(xmi_id) || connector_source_name(xmi_id)
121
+
122
+ if link.name == "Association"
123
+ assoc_connector = main_model.xpath(%(//connector[@xmi:idref="#{link['xmi:id']}"]/source)).first
124
+ if assoc_connector
125
+ connector_type = assoc_connector.children.find { |node| node.name == 'type' }
126
+ if connector_type && connector_type.attributes['multiplicity']
127
+ cardinality = connector_type.attributes['multiplicity']&.value&.split('..')
128
+ cardinality.unshift('1') if cardinality.length == 1
129
+ min, max = cardinality
130
+ end
131
+ connector_role = assoc_connector.children.find { |node| node.name == 'role' }
132
+ if connector_role
133
+ member_end_attribute_name = connector_role.attributes["name"]&.value
134
+ end
135
+ member_end_cardinality = { "min" => LOVER_VALUE_MAPPINGS[min], "max" => max }
136
+ end
137
+ else
138
+ member_end_node = main_model.xpath(%(//ownedAttribute[@association]/type[@xmi:idref="#{xmi_id}"])).first
139
+ if member_end_node
140
+ assoc = member_end_node.parent
141
+ member_end_cardinality = { "min" => cardinality_min_value(assoc), "max" => cardinality_max_value(assoc) }
142
+ member_end_attribute_name = assoc.attributes["name"]&.value
143
+ end
132
144
  end
133
145
 
134
146
  [member_end, "aggregation", member_end_cardinality, member_end_attribute_name]
@@ -1,5 +1,5 @@
1
1
  module Lutaml
2
2
  module XMI
3
- VERSION = "0.1.4"
3
+ VERSION = "0.1.5"
4
4
  end
5
5
  end
data/lutaml-xmi.gemspec CHANGED
@@ -26,10 +26,10 @@ Gem::Specification.new do |spec|
26
26
  spec.add_runtime_dependency "hashie", "~> 4.1.0"
27
27
  spec.add_runtime_dependency "thor", "~> 1.0"
28
28
  spec.add_runtime_dependency "lutaml-uml"
29
+ spec.add_runtime_dependency "nokogiri", "~> 1.10"
29
30
 
30
31
  spec.add_development_dependency "bundler", "~> 2.0"
31
32
  spec.add_development_dependency "byebug"
32
- spec.add_development_dependency "nokogiri", "~> 1.10"
33
33
  spec.add_development_dependency "pry", "~> 0.12.2"
34
34
  spec.add_development_dependency "rake", "~> 10.0"
35
35
  spec.add_development_dependency "rspec", "~> 3.0"
@@ -89,8 +89,8 @@ RSpec.describe Lutaml::XMI::Parsers::XML do
89
89
  let(:expected_association_names) do
90
90
  %w[
91
91
  TemporalGeometricPrimitive
92
+ Primitive
92
93
  TemporalGeometry
93
- TemporalTopologicalPrimitive
94
94
  Interval
95
95
  Instant
96
96
  ]
@@ -134,8 +134,8 @@ RSpec.describe Lutaml::XMI::Parsers::XML do
134
134
  expect(inheritance.member_end_type).to eq('inheritance')
135
135
  expect(inheritance.member_end_cardinality).to eq({"min"=>"C", "max"=>"*"})
136
136
 
137
- aggregation = klass.associations.find { |entity| entity.member_end == 'TemporalTopologicalPrimitive' }
138
- expect(aggregation.member_end_attribute_name).to eq('topology')
137
+ aggregation = klass.associations.find { |entity| entity.member_end == 'TemporalGeometricPrimitive' }
138
+ expect(aggregation.member_end_attribute_name).to eq('element')
139
139
  expect(aggregation.member_end_type).to eq('aggregation')
140
140
  expect(aggregation.member_end_cardinality).to eq({"min"=>"C", "max"=>"*"})
141
141
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lutaml-xmi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-04-19 00:00:00.000000000 Z
11
+ date: 2021-05-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hashie
@@ -53,47 +53,47 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: bundler
56
+ name: nokogiri
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '2.0'
62
- type: :development
61
+ version: '1.10'
62
+ type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '2.0'
68
+ version: '1.10'
69
69
  - !ruby/object:Gem::Dependency
70
- name: byebug
70
+ name: bundler
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ">="
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '0'
75
+ version: '2.0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ">="
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '0'
82
+ version: '2.0'
83
83
  - !ruby/object:Gem::Dependency
84
- name: nokogiri
84
+ name: byebug
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - "~>"
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
- version: '1.10'
89
+ version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - "~>"
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
- version: '1.10'
96
+ version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: pry
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -202,7 +202,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
202
202
  - !ruby/object:Gem::Version
203
203
  version: '0'
204
204
  requirements: []
205
- rubygems_version: 3.0.3
205
+ rubygems_version: 3.1.6
206
206
  signing_key:
207
207
  specification_version: 4
208
208
  summary: XML Metadata Interchange (XMI) Specification parser in Ruby, tools for accessing