expressir 2.4.7 → 2.4.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/expressir/express/smrl_xml.rb +47 -31
- data/lib/expressir/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ebd25bbedb1fd18428c86909c39a4aacce617d6d359368e175ee8887ecb8c078
|
|
4
|
+
data.tar.gz: 426c5afe759f7387c32cc10f060bfade8438e1133b525122f9948683661f2190
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 075a8aa23bc5ffee8d4ef04acbe84dce9da9413c4faaf31e3ec610d929f563a47476e4e09c755201f54ee9ac9191fcee28201772547411d9039433ed31a8fd07
|
|
7
|
+
data.tar.gz: c700a17fe91a024ede2e50857ec7e48698c189fd38ca47d15b196bc676a6c2cd1c337276adc947e49ed2ebf52501cc95009857524e5361d9d3f52f8c6a89f27e
|
|
@@ -3,60 +3,77 @@
|
|
|
3
3
|
module Expressir
|
|
4
4
|
module Express
|
|
5
5
|
# SMRL index XML writer — the shape eengine's wo-smrl-xml.lisp
|
|
6
|
-
#
|
|
7
|
-
# document set, expressir #276 / TODO.parity-ee 15)
|
|
6
|
+
# produces (the data layer of the STEP Module Resource Library
|
|
7
|
+
# document set, expressir #276 / TODO.parity-ee 15), built with
|
|
8
|
+
# moxml's node API — no hand-serialized XML strings.
|
|
8
9
|
#
|
|
9
|
-
# Per schema
|
|
10
|
-
#
|
|
11
|
-
#
|
|
12
|
-
#
|
|
13
|
-
#
|
|
14
|
-
#
|
|
15
|
-
#
|
|
16
|
-
#
|
|
17
|
-
#
|
|
18
|
-
#
|
|
19
|
-
#
|
|
10
|
+
# Per schema: downcased <schema> id, <schema_version> when
|
|
11
|
+
# present, per-kind count comments, <use_from> per interface
|
|
12
|
+
# (item-list marker), sorted <constant> names, then declarations
|
|
13
|
+
# in eeng's kind order (types, entities, subtype_constraints,
|
|
14
|
+
# functions, rules, procedures), alphabetical inside each kind,
|
|
15
|
+
# schema-qualified names; ARM mode upcases entity names.
|
|
16
|
+
#
|
|
17
|
+
# format — one document with an <smrl> root, one <schema>
|
|
18
|
+
# element per repository schema.
|
|
19
|
+
# format_schema — a standalone document whose root is the schema
|
|
20
|
+
# element (the per-file fragment eeng emits).
|
|
20
21
|
module SmrlXml
|
|
21
22
|
module_function
|
|
22
23
|
|
|
23
|
-
# @param repository [Model::Repository, #schemas]
|
|
24
|
-
# @param mode [Symbol] :resource (default), :arm, :mim — the
|
|
25
|
-
# eeng -mode whose case conventions apply to entity names
|
|
26
|
-
# @return [String] the concatenated schema blocks
|
|
27
24
|
def format(repository, mode: :resource)
|
|
28
25
|
schemas = repository.respond_to?(:schemas) ? repository.schemas : Array(repository)
|
|
29
|
-
|
|
26
|
+
ctx = Moxml::Context.new
|
|
27
|
+
doc = ctx.create_document
|
|
28
|
+
root = doc.create_element("smrl")
|
|
29
|
+
doc.add_child(root)
|
|
30
|
+
schemas.each { |schema| root.add_child(schema_element(doc, schema, mode)) }
|
|
31
|
+
doc.to_xml
|
|
30
32
|
end
|
|
31
33
|
|
|
32
34
|
def format_schema(schema, mode: :resource)
|
|
33
|
-
|
|
34
|
-
|
|
35
|
+
ctx = Moxml::Context.new
|
|
36
|
+
doc = ctx.create_document
|
|
37
|
+
doc.add_child(schema_element(doc, schema, mode))
|
|
38
|
+
doc.to_xml
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def schema_element(doc, schema, mode)
|
|
42
|
+
element = doc.create_element("schema")
|
|
43
|
+
element.add_child(doc.create_text(schema.id.downcase))
|
|
35
44
|
if schema.version&.value
|
|
36
|
-
|
|
45
|
+
version = doc.create_element("schema_version")
|
|
46
|
+
version.add_child(doc.create_text(schema.version.value))
|
|
47
|
+
element.add_child(version)
|
|
37
48
|
end
|
|
38
49
|
counts = declaration_counts(schema)
|
|
39
50
|
%i[type entity function procedure rule subtype_constraint].each do |kind|
|
|
40
51
|
label = kind.to_s.split("_").map(&:upcase).join("_")
|
|
41
|
-
|
|
52
|
+
element.add_child(doc.create_comment(Kernel.format("%-19s %4d",
|
|
53
|
+
label, counts[kind])))
|
|
42
54
|
end
|
|
43
|
-
|
|
44
55
|
interfaces(schema).each do |iface|
|
|
45
|
-
|
|
46
|
-
|
|
56
|
+
items = iface.items.to_a.empty? ? "" : "(...)"
|
|
57
|
+
add_text_element(doc, element, "use-from",
|
|
58
|
+
"#{iface.schema.id.downcase}#{items}")
|
|
47
59
|
end
|
|
48
|
-
|
|
49
60
|
constants(schema).each do |decl|
|
|
50
|
-
|
|
61
|
+
add_text_element(doc, element, "constant", decl.id.downcase)
|
|
51
62
|
end
|
|
52
|
-
|
|
53
63
|
declarations(schema).each do |kind, decls|
|
|
54
64
|
tag = kind.to_s.tr("_", "-")
|
|
55
65
|
decls.each do |decl|
|
|
56
|
-
|
|
66
|
+
add_text_element(doc, element, tag,
|
|
67
|
+
"#{schema.id}.#{name_for(kind, decl.id, mode)}")
|
|
57
68
|
end
|
|
58
69
|
end
|
|
59
|
-
|
|
70
|
+
element
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def add_text_element(doc, parent, tag, text)
|
|
74
|
+
node = doc.create_element(tag)
|
|
75
|
+
node.add_child(doc.create_text(text))
|
|
76
|
+
parent.add_child(node)
|
|
60
77
|
end
|
|
61
78
|
|
|
62
79
|
# eeng's entity casing: ARM mode upcases entity names; every
|
|
@@ -94,7 +111,6 @@ module Expressir
|
|
|
94
111
|
rules: :rule,
|
|
95
112
|
procedures: :procedure,
|
|
96
113
|
}.freeze
|
|
97
|
-
private_constant :COLL_BY_KIND
|
|
98
114
|
|
|
99
115
|
def declarations(schema)
|
|
100
116
|
COLL_BY_KIND.filter_map do |coll, kind|
|
data/lib/expressir/version.rb
CHANGED