lutaml-xmi 0.2.1 → 0.2.2

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: 00fbd8ecac2e908005b2e8721296f5ad95c49bd164b32bc9954e8bf94d82ad18
4
- data.tar.gz: 14e0bffadfb34e0980fba6d535576b3fff50b663c2f26f3174b1ab908a1883d2
3
+ metadata.gz: 63fbe7f09179853abdedd141e18e2f66fbcb8f6018a8bed99a3128170d7a25bb
4
+ data.tar.gz: 874323dcf8ad23d86f83037382b2190b372aa747c768807f3b9f29999365b76c
5
5
  SHA512:
6
- metadata.gz: 432706c232ea18b66169dad9ce3a5f25612824563cde18484b3e83bab07804a503b7c145e62c67d0516e0b3ea83f38e6ed7fda461ee88b5d4a0a9a153142a300
7
- data.tar.gz: 40d9499f0866b91bd5b04a8d2e47b0b894c82f6a129893f8b0d1f57e15ac37981d9a12c87b14f5f2acb0bbd6e4dd797ed910d28379f159bafed63e187947857d
6
+ metadata.gz: 9a5844111850226727b714da4cde2ec8ca51ff50d0abdbf5980a78b280888b88492ba00a839d369a8f8df2c2549b40b6456a01243fe08142a1d6da5d366e3a1e
7
+ data.tar.gz: 1d348e32bf2b2ac4f3b6642e52e698b3f43cf4e4edebd9bd92b65b0a94f77cbb65dae9c9861eb2de916407f7ebae763735f3f29d4283290acd17a912e03ed700
@@ -1,4 +1,5 @@
1
1
  require "nokogiri"
2
+ require "htmlentities"
2
3
  require "lutaml/uml/has_attributes"
3
4
  require "lutaml/uml/document"
4
5
 
@@ -7,7 +8,7 @@ module Lutaml
7
8
  module Parsers
8
9
  # Class for parsing .xmi schema files into ::Lutaml::Uml::Document
9
10
  class XML
10
- LOVER_VALUE_MAPPINGS = {
11
+ LOWER_VALUE_MAPPINGS = {
11
12
  "0" => "C",
12
13
  "1" => "M",
13
14
  }.freeze
@@ -55,7 +56,7 @@ module Lutaml
55
56
  end
56
57
 
57
58
  def serialize_model_classes(model)
58
- model.xpath('./packagedElement[@xmi:type="uml:Class"]').map do |klass|
59
+ model.xpath('./packagedElement[@xmi:type="uml:Class" or @xmi:type="uml:AssociationClass"]').map do |klass|
59
60
  {
60
61
  xmi_id: klass["xmi:id"],
61
62
  xmi_uuid: klass["xmi:uuid"],
@@ -145,7 +146,7 @@ module Lutaml
145
146
  definition: definition
146
147
  }
147
148
  end
148
- end
149
+ end.uniq
149
150
  end
150
151
 
151
152
  def serialize_class_operations(klass)
@@ -167,6 +168,7 @@ module Lutaml
167
168
  {
168
169
  xmi_id: constraint["xmi:id"],
169
170
  body: constraint["name"],
171
+ definition: HTMLEntities.new.decode(constraint["description"])
170
172
  }
171
173
  end
172
174
  end
@@ -191,7 +193,7 @@ module Lutaml
191
193
  if connector_role
192
194
  owned_attribute_name = connector_role.attributes["name"]&.value
193
195
  end
194
- owned_cardinality = { "min" => LOVER_VALUE_MAPPINGS[min], "max" => max }
196
+ owned_cardinality = { "min" => LOWER_VALUE_MAPPINGS[min], "max" => max }
195
197
  end
196
198
  else
197
199
  owned_node = main_model.xpath(%(//ownedAttribute[@association]/type[@xmi:idref="#{xmi_id}"])).first
@@ -210,7 +212,13 @@ module Lutaml
210
212
  return generalization_association(owner_xmi_id, link) if link.name == "Generalization"
211
213
 
212
214
  xmi_id = link.attributes[link_member_name].value
213
- member_end = lookup_entity_name(xmi_id) || connector_source_name(xmi_id)
215
+ if link.attributes["start"].value == owner_xmi_id
216
+ xmi_id = link.attributes["end"].value
217
+ member_end = lookup_entity_name(xmi_id) || connector_target_name(xmi_id)
218
+ else
219
+ xmi_id = link.attributes["start"].value
220
+ member_end = lookup_entity_name(xmi_id) || connector_source_name(xmi_id)
221
+ end
214
222
 
215
223
  if link.name == "Association"
216
224
  connector_type = link_member_name == "start" ? "source" : "target"
@@ -226,7 +234,7 @@ module Lutaml
226
234
  if connector_role
227
235
  member_end_attribute_name = connector_role.attributes["name"]&.value
228
236
  end
229
- member_end_cardinality = { "min" => LOVER_VALUE_MAPPINGS[min], "max" => max }
237
+ member_end_cardinality = { "min" => LOWER_VALUE_MAPPINGS[min], "max" => max }
230
238
  end
231
239
  else
232
240
  member_end_node = main_model.xpath(%(//ownedAttribute[@association]/type[@xmi:idref="#{xmi_id}"])).first
@@ -286,7 +294,7 @@ module Lutaml
286
294
  return unless lower_value_node
287
295
 
288
296
  lower_value = lower_value_node.attributes["value"]&.value
289
- LOVER_VALUE_MAPPINGS[lower_value]
297
+ LOWER_VALUE_MAPPINGS[lower_value]
290
298
  end
291
299
 
292
300
  def cardinality_max_value(node)
@@ -1,5 +1,5 @@
1
1
  module Lutaml
2
2
  module XMI
3
- VERSION = "0.2.1"
3
+ VERSION = "0.2.2"
4
4
  end
5
5
  end
data/lutaml-xmi.gemspec CHANGED
@@ -27,6 +27,7 @@ Gem::Specification.new do |spec|
27
27
  spec.add_runtime_dependency "thor", "~> 1.0"
28
28
  spec.add_runtime_dependency "lutaml-uml"
29
29
  spec.add_runtime_dependency "nokogiri", "~> 1.10"
30
+ spec.add_runtime_dependency "htmlentities"
30
31
 
31
32
  spec.add_development_dependency "bundler", "~> 2.0"
32
33
  spec.add_development_dependency "byebug"
@@ -109,7 +109,7 @@ RSpec.describe Lutaml::XMI::Parsers::XML do
109
109
  .to(eq(["Temporal and Zonal Geometry", "Temporal and Zonal RS using Identifiers"]))
110
110
  end
111
111
 
112
- it "correctly parses package` classes" do
112
+ it "correctly parses package classes" do
113
113
  expect(first_nested_package.classes.map(&:name)).to(eq(expected_class_names))
114
114
  expect(first_nested_package.classes.map(&:xmi_id)).to(eq(expected_class_xmi_ids))
115
115
  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.2.1
4
+ version: 0.2.2
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-06-22 00:00:00.000000000 Z
11
+ date: 2021-09-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hashie
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '1.10'
69
+ - !ruby/object:Gem::Dependency
70
+ name: htmlentities
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: bundler
71
85
  requirement: !ruby/object:Gem::Requirement