xmi 0.3.6 → 0.3.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/xmi/ea_root.rb +66 -14
- data/lib/xmi/extensions/gml.rb +72 -0
- data/lib/xmi/sparx.rb +35 -0
- data/lib/xmi/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cc142c4dafa8b6f642915fc177a55d64667b39503164533e4acd2f57dc4a5882
|
4
|
+
data.tar.gz: 8ea7bac17a8ce090cc39c019571ef1d6d91096c3b868c9e1246114f5a49a8d37
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a189f14845f4bd56540e1d6b0373a7cab2ec56c7b12572ccdfb9f01365994d90dfdc45802994433bc398fa417979ea6183c82d131bf9b6dd9b5484f4eb7439d3
|
7
|
+
data.tar.gz: 034a0986c647977cfa682611df764f7f8ff7859b40aa82ca61e8bef20000f24ec96b5af2bfc3de0cc9aeececfc0a23b3d1f62a4fb7e7a9f52268a77878f2fe1f
|
data/lib/xmi/ea_root.rb
CHANGED
@@ -202,7 +202,7 @@ module Xmi
|
|
202
202
|
[apply_types_lines, apply_types_nodes]
|
203
203
|
end
|
204
204
|
|
205
|
-
def gen_generic_klass(node)
|
205
|
+
def gen_generic_klass(node, from_klass = nil) # rubocop:disable Metrics/MethodLength
|
206
206
|
node_name = get_klass_name_from_node(node)
|
207
207
|
attributes_lines, map_attributes_lines = gen_klass_tags(node)
|
208
208
|
apply_types_lines, apply_types_nodes = gen_apply_types(node)
|
@@ -211,18 +211,34 @@ module Xmi
|
|
211
211
|
apply_types_lines, apply_types_nodes
|
212
212
|
)
|
213
213
|
|
214
|
+
map_attributes_lines = node_map_attributes(node_name,
|
215
|
+
from_klass, map_attributes_lines)
|
214
216
|
xml_mapping = replace_xml_mapping(node_name, map_attributes_lines)
|
215
217
|
|
216
|
-
replace_klass_template(node_name, attributes_lines,
|
218
|
+
replace_klass_template(node_name, attributes_lines,
|
219
|
+
xml_mapping, from_klass)
|
217
220
|
end
|
218
221
|
|
219
|
-
def
|
222
|
+
def node_map_attributes(node_name, from_klass, map_attributes_lines)
|
223
|
+
if from_klass && @node_map.key?(from_klass.to_sym)
|
224
|
+
map_attributes_lines += @node_map[from_klass.to_sym].to_s
|
225
|
+
else
|
226
|
+
@node_map ||= {}
|
227
|
+
@node_map[node_name.to_sym] = map_attributes_lines
|
228
|
+
end
|
229
|
+
|
230
|
+
map_attributes_lines
|
231
|
+
end
|
232
|
+
|
233
|
+
def gen_klass_apply_types(attributes_lines, map_attributes_lines, apply_types_lines, apply_types_nodes) # rubocop:disable Metrics/MethodLength
|
220
234
|
unless apply_types_nodes.empty?
|
221
235
|
attributes_lines += apply_types_lines
|
222
236
|
apply_types_nodes.each do |n|
|
223
237
|
apply_types = n.attribute_nodes.map(&:value)
|
224
238
|
apply_types.each do |apply_type|
|
225
|
-
map_attributes_lines += gen_map_attribute_line(
|
239
|
+
map_attributes_lines += gen_map_attribute_line(
|
240
|
+
"base_#{apply_type}", "base_#{apply_type}"
|
241
|
+
)
|
226
242
|
end
|
227
243
|
end
|
228
244
|
end
|
@@ -251,9 +267,11 @@ module Xmi
|
|
251
267
|
.rstrip
|
252
268
|
end
|
253
269
|
|
254
|
-
def replace_klass_template(node_name, attributes_lines, xml_mapping
|
270
|
+
def replace_klass_template(node_name, attributes_lines, xml_mapping,
|
271
|
+
from_klass = nil)
|
255
272
|
abstract_klass_name = get_klass_name_from_node(@abstract_klass_node)
|
256
|
-
|
273
|
+
abstract_klass_name = from_klass if from_klass
|
274
|
+
root_tag_line = "def self.root_tag = \"#{node_name}\""
|
257
275
|
|
258
276
|
KLASS_TEMPLATE
|
259
277
|
.gsub("#KLASS_NAME#", Shale::Utils.classify(node_name))
|
@@ -267,6 +285,16 @@ module Xmi
|
|
267
285
|
nodes = xmi_doc.xpath("//UMLProfiles//Stereotypes//Stereotype[not(contains(@isAbstract, 'true'))]")
|
268
286
|
klasses_lines = ""
|
269
287
|
|
288
|
+
klasses_lines += "#{gen_generic_klasses_wo_base_stereotypes(nodes)}\n"
|
289
|
+
klasses_lines += "#{gen_generic_klasses_w_base_stereotypes(nodes)}\n"
|
290
|
+
|
291
|
+
klasses_lines
|
292
|
+
end
|
293
|
+
|
294
|
+
def gen_generic_klasses_wo_base_stereotypes(nodes)
|
295
|
+
nodes = nodes.select { |n| n.attributes["baseStereotypes"].nil? }
|
296
|
+
klasses_lines = ""
|
297
|
+
|
270
298
|
nodes.each do |node|
|
271
299
|
klasses_lines += "#{gen_generic_klass(node)}\n"
|
272
300
|
end
|
@@ -274,6 +302,18 @@ module Xmi
|
|
274
302
|
klasses_lines
|
275
303
|
end
|
276
304
|
|
305
|
+
def gen_generic_klasses_w_base_stereotypes(nodes)
|
306
|
+
nodes = nodes.reject { |n| n.attributes["baseStereotypes"].nil? }
|
307
|
+
klasses_lines = ""
|
308
|
+
|
309
|
+
nodes.each do |node|
|
310
|
+
base_stereotypes = node.attributes["baseStereotypes"].value
|
311
|
+
klasses_lines += "#{gen_generic_klass(node, base_stereotypes)}\n"
|
312
|
+
end
|
313
|
+
|
314
|
+
klasses_lines
|
315
|
+
end
|
316
|
+
|
277
317
|
def gen_klasses(xmi_doc)
|
278
318
|
@abstract_klass_node = get_abstract_klass_node(xmi_doc)
|
279
319
|
klasses_lines = ""
|
@@ -289,13 +329,8 @@ module Xmi
|
|
289
329
|
end
|
290
330
|
|
291
331
|
def get_namespace_from_definition(xmi_doc)
|
292
|
-
|
293
|
-
|
294
|
-
attr.name == "name"
|
295
|
-
end.value
|
296
|
-
namespace_uri = node.attribute_nodes.find do |attr|
|
297
|
-
attr.name == "URI"
|
298
|
-
end.value
|
332
|
+
namespace_key = get_module_name_from_definition(xmi_doc)
|
333
|
+
namespace_uri = get_module_uri(xmi_doc)
|
299
334
|
|
300
335
|
{ name: namespace_key, uri: namespace_uri }
|
301
336
|
end
|
@@ -308,7 +343,24 @@ module Xmi
|
|
308
343
|
end
|
309
344
|
|
310
345
|
def get_module_name(xmi_doc)
|
311
|
-
xmi_doc
|
346
|
+
get_module_name_from_definition(xmi_doc).capitalize
|
347
|
+
end
|
348
|
+
|
349
|
+
def get_module_name_from_definition(xmi_doc)
|
350
|
+
node = xmi_doc.at_xpath("//UMLProfile/Documentation")
|
351
|
+
node.attribute_nodes.find { |attr| attr.name == "name" }&.value
|
352
|
+
end
|
353
|
+
|
354
|
+
def get_module_uri(xmi_doc)
|
355
|
+
node = xmi_doc.at_xpath("//UMLProfile/Documentation")
|
356
|
+
uri = node.attribute_nodes.find { |attr| attr.name == "URI" }&.value
|
357
|
+
|
358
|
+
return uri if uri
|
359
|
+
|
360
|
+
name = get_module_name_from_definition(xmi_doc)
|
361
|
+
ver = node.attribute_nodes.find { |attr| attr.name == "version" }&.value
|
362
|
+
|
363
|
+
"http://www.sparxsystems.com/profiles/#{name}/#{ver}"
|
312
364
|
end
|
313
365
|
end
|
314
366
|
end
|
data/lib/xmi/extensions/gml.rb
CHANGED
@@ -37,15 +37,87 @@ module Xmi
|
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
|
+
class DataType < Shale::Mapper
|
41
|
+
attribute :is_collection, Shale::Type::String
|
42
|
+
attribute :no_property_type, Shale::Type::String
|
43
|
+
attribute :base_class, Shale::Type::String
|
44
|
+
|
45
|
+
xml do
|
46
|
+
root "DataType"
|
47
|
+
|
48
|
+
map_attribute "isCollection", to: :is_collection
|
49
|
+
map_attribute "noPropertyType", to: :no_property_type
|
50
|
+
map_attribute "base_Class", to: :base_class
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
class Union < Shale::Mapper
|
55
|
+
attribute :is_collection, Shale::Type::String
|
56
|
+
attribute :no_property_type, Shale::Type::String
|
57
|
+
attribute :base_class, Shale::Type::String
|
58
|
+
|
59
|
+
xml do
|
60
|
+
root "Union"
|
61
|
+
|
62
|
+
map_attribute "isCollection", to: :is_collection
|
63
|
+
map_attribute "noPropertyType", to: :no_property_type
|
64
|
+
map_attribute "base_Class", to: :base_class
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
class Enumeration < Shale::Mapper
|
69
|
+
attribute :base_enumeration, Shale::Type::String
|
70
|
+
|
71
|
+
xml do
|
72
|
+
root "Enumeration"
|
73
|
+
|
74
|
+
map_attribute "base_Enumeration", to: :base_enumeration
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
class Type < Shale::Mapper
|
79
|
+
attribute :is_collection, Shale::Type::String
|
80
|
+
attribute :no_property_type, Shale::Type::String
|
81
|
+
attribute :base_class, Shale::Type::String
|
82
|
+
|
83
|
+
xml do
|
84
|
+
root "Type"
|
85
|
+
|
86
|
+
map_attribute "isCollection", to: :is_collection
|
87
|
+
map_attribute "noPropertyType", to: :no_property_type
|
88
|
+
map_attribute "base_Class", to: :base_class
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
class FeatureType < Shale::Mapper
|
93
|
+
attribute :is_collection, Shale::Type::String
|
94
|
+
attribute :no_property_type, Shale::Type::String
|
95
|
+
attribute :base_class, Shale::Type::String
|
96
|
+
attribute :by_value_property_type, Shale::Type::String
|
97
|
+
|
98
|
+
xml do
|
99
|
+
root "FeatureType"
|
100
|
+
|
101
|
+
map_attribute "isCollection", to: :is_collection
|
102
|
+
map_attribute "noPropertyType", to: :no_property_type
|
103
|
+
map_attribute "base_Class", to: :base_class
|
104
|
+
map_attribute "byValuePropertyType", to: :by_value_property_type
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
40
108
|
class Property < Shale::Mapper
|
41
109
|
attribute :sequence_number, Shale::Type::String
|
42
110
|
attribute :base_property, Shale::Type::String
|
111
|
+
attribute :is_metadata, Shale::Type::String
|
112
|
+
attribute :inline_or_by_reference, Shale::Type::String
|
43
113
|
|
44
114
|
xml do
|
45
115
|
root "property"
|
46
116
|
|
47
117
|
map_attribute "sequenceNumber", to: :sequence_number
|
48
118
|
map_attribute "base_Property", to: :base_property
|
119
|
+
map_attribute "isMetadata", to: :is_metadata
|
120
|
+
map_attribute "inlineOrByReference", to: :inline_or_by_reference
|
49
121
|
end
|
50
122
|
end
|
51
123
|
end
|
data/lib/xmi/sparx.rb
CHANGED
@@ -957,6 +957,11 @@ module Xmi
|
|
957
957
|
attribute :eauml_import, EaRoot::Eauml::Import, collection: true
|
958
958
|
attribute :gml_application_schema, EaRoot::Gml::ApplicationSchema, collection: true
|
959
959
|
attribute :gml_code_list, EaRoot::Gml::CodeList, collection: true
|
960
|
+
attribute :gml_data_type, EaRoot::Gml::CodeList, collection: true
|
961
|
+
attribute :gml_union, EaRoot::Gml::CodeList, collection: true
|
962
|
+
attribute :gml_enumeration, EaRoot::Gml::CodeList, collection: true
|
963
|
+
attribute :gml_type, EaRoot::Gml::CodeList, collection: true
|
964
|
+
attribute :gml_feature_type, EaRoot::Gml::CodeList, collection: true
|
960
965
|
attribute :gml_property, EaRoot::Gml::Property, collection: true
|
961
966
|
end
|
962
967
|
end
|
@@ -1002,6 +1007,21 @@ module Xmi
|
|
1002
1007
|
map_element "CodeList", to: :gml_code_list,
|
1003
1008
|
namespace: "http://www.sparxsystems.com/profiles/GML/1.0",
|
1004
1009
|
prefix: "GML"
|
1010
|
+
map_element "DataType", to: :gml_data_type,
|
1011
|
+
namespace: "http://www.sparxsystems.com/profiles/GML/1.0",
|
1012
|
+
prefix: "GML"
|
1013
|
+
map_element "Union", to: :gml_union,
|
1014
|
+
namespace: "http://www.sparxsystems.com/profiles/GML/1.0",
|
1015
|
+
prefix: "GML"
|
1016
|
+
map_element "Enumeration", to: :gml_enumeration,
|
1017
|
+
namespace: "http://www.sparxsystems.com/profiles/GML/1.0",
|
1018
|
+
prefix: "GML"
|
1019
|
+
map_element "Type", to: :gml_type,
|
1020
|
+
namespace: "http://www.sparxsystems.com/profiles/GML/1.0",
|
1021
|
+
prefix: "GML"
|
1022
|
+
map_element "FeatureType", to: :gml_feature_type,
|
1023
|
+
namespace: "http://www.sparxsystems.com/profiles/GML/1.0",
|
1024
|
+
prefix: "GML"
|
1005
1025
|
map_element "property", to: :gml_property,
|
1006
1026
|
namespace: "http://www.sparxsystems.com/profiles/GML/1.0",
|
1007
1027
|
prefix: "GML"
|
@@ -1054,6 +1074,21 @@ module Xmi
|
|
1054
1074
|
map_element "CodeList", to: :gml_code_list,
|
1055
1075
|
namespace: "http://www.sparxsystems.com/profiles/GML/1.0",
|
1056
1076
|
prefix: "GML"
|
1077
|
+
map_element "DataType", to: :gml_data_type,
|
1078
|
+
namespace: "http://www.sparxsystems.com/profiles/GML/1.0",
|
1079
|
+
prefix: "GML"
|
1080
|
+
map_element "Union", to: :gml_union,
|
1081
|
+
namespace: "http://www.sparxsystems.com/profiles/GML/1.0",
|
1082
|
+
prefix: "GML"
|
1083
|
+
map_element "Enumeration", to: :gml_enumeration,
|
1084
|
+
namespace: "http://www.sparxsystems.com/profiles/GML/1.0",
|
1085
|
+
prefix: "GML"
|
1086
|
+
map_element "Type", to: :gml_type,
|
1087
|
+
namespace: "http://www.sparxsystems.com/profiles/GML/1.0",
|
1088
|
+
prefix: "GML"
|
1089
|
+
map_element "FeatureType", to: :gml_feature_type,
|
1090
|
+
namespace: "http://www.sparxsystems.com/profiles/GML/1.0",
|
1091
|
+
prefix: "GML"
|
1057
1092
|
map_element "property", to: :gml_property,
|
1058
1093
|
namespace: "http://www.sparxsystems.com/profiles/GML/1.0",
|
1059
1094
|
prefix: "GML"
|
data/lib/xmi/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xmi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.8
|
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-07-
|
11
|
+
date: 2024-07-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|