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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a528340d87e1789ca193347d8da5562b8729d544778d5eda450f4991645244fe
4
- data.tar.gz: 0b708a242f721723ac2dc22fad6077bdb788efbf16e47c70e0ecaa1741fee60a
3
+ metadata.gz: ebd25bbedb1fd18428c86909c39a4aacce617d6d359368e175ee8887ecb8c078
4
+ data.tar.gz: 426c5afe759f7387c32cc10f060bfade8438e1133b525122f9948683661f2190
5
5
  SHA512:
6
- metadata.gz: cb0061aba1f58ebde3e8fe84cf09b4f4579961504dd85e17fe2b8f60993d276553912a906412b5a129a03f5fc320262144d0dd3bdfcbff633d9aba2432b9550e
7
- data.tar.gz: 7ad4621bcbe3534b796cfd9f5286491fc55ab97763e8be9e118ff8731ba3c273181a019bc0d96408a3edcc707f6f200c912ff3029313aeeb98453f93eb735650
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
- # emits (the data layer of the STEP Module Resource Library
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, in eeng's exact layout:
10
- # <schema>downcased_name</schema>
11
- # <schema_version>...</schema_version> (when present)
12
- # <!-- TYPE n --> ... count comments
13
- # <use-from>schema(...)</use-from> (per interface)
14
- # <constant>name</constant> (sorted)
15
- # <type>SCHEMA.name</type> ... declarations in kind order
16
- # (types, entities, subtype_constraints, functions, rules,
17
- # procedures), alphabetical inside each kind. In ARM mode
18
- # entity names keep their declared case upcased, matching
19
- # eeng's ARM rendering.
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
- schemas.map { |schema| format_schema(schema, mode: mode) }.join
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
- out = +""
34
- out << "<schema>#{schema.id.downcase}</schema>\n"
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
- out << " <schema_version>#{schema.version.value}</schema_version>\n"
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
- out << Kernel.format(" <!-- %-19s %4d -->\n", label, counts[kind])
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
- item_list = iface.items.to_a.empty? ? "" : "(...)"
46
- out << " <use-from>#{iface.schema.id.downcase}#{item_list}</use-from>\n"
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
- out << " <constant>#{decl.id.downcase}</constant>\n"
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
- out << " <#{tag}>#{schema.id}.#{name_for(kind, decl.id, mode)}</#{tag}>\n"
66
+ add_text_element(doc, element, tag,
67
+ "#{schema.id}.#{name_for(kind, decl.id, mode)}")
57
68
  end
58
69
  end
59
- out
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|
@@ -3,6 +3,6 @@ module Expressir
3
3
  # autoload it (Ruby autoload only works for module/class constants, not
4
4
  # for string constants like `Expressir::VERSION`).
5
5
  module Version
6
- VERSION = "2.4.7".freeze
6
+ VERSION = "2.4.8".freeze
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: expressir
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.7
4
+ version: 2.4.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.