expressir 2.5.1-arm-linux → 2.5.3-arm-linux
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/ENGINE-COMPAT.json +3 -3
- data/lib/expressir/3.2/expressir_core.so +0 -0
- data/lib/expressir/3.3/expressir_core.so +0 -0
- data/lib/expressir/3.4/expressir_core.so +0 -0
- data/lib/expressir/4.0/expressir_core.so +0 -0
- data/lib/expressir/cli.rb +27 -0
- data/lib/expressir/commands/cleanup_parens.rb +25 -0
- data/lib/expressir/commands/compare/report_building.rb +131 -0
- data/lib/expressir/commands/compare.rb +62 -124
- data/lib/expressir/commands/compare_arm_mim.rb +52 -0
- data/lib/expressir/commands/flatten.rb +2 -1
- data/lib/expressir/commands/patch.rb +33 -0
- data/lib/expressir/commands.rb +3 -0
- data/lib/expressir/express/cleanup_parens.rb +144 -0
- data/lib/expressir/express/core.rb +12 -0
- data/lib/expressir/express/dot/data_dot.rb +135 -0
- data/lib/expressir/express/dot/names.rb +56 -0
- data/lib/expressir/express/dot/path_dot.rb +291 -0
- data/lib/expressir/express/dot/schema_dot.rb +102 -0
- data/lib/expressir/express/dot/supertype_dot.rb +79 -0
- data/lib/expressir/express/parser.rb +7 -2
- data/lib/expressir/express/patch_schema.rb +298 -0
- data/lib/expressir/express/shtolo.rb +83 -6
- data/lib/expressir/express.rb +7 -0
- data/lib/expressir/version.rb +1 -1
- metadata +13 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bb922a24915f00adb6ee6c719591c069384fe2216ddd4ab96830b793f0ede0f5
|
|
4
|
+
data.tar.gz: 3f48e0ac74b1f7438bdf112f98a0f3a79d26d22a5cb04e8cb4a65ae513fe4722
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bb88835059e061090d55828fd43b3ef9fd2270d21fcdf35143f14bbc30c9c8caf4ea716128d15ee9a05e367bf28411c4e74fcccebacce470d66139abcaf32ffc
|
|
7
|
+
data.tar.gz: b9f05e45f7b8e327674de43ecb490b949ca00368807f62c6661226b463296fccfbd684f9ceba2b3e6b429107071ae9214b16ea2382092e2e3b4fe5cc5b83d13b
|
data/ENGINE-COMPAT.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
|
-
"engine_commit": "
|
|
2
|
+
"engine_commit": "fc875c03a8a4310e162a9ec2ad6734384c9d2ca5",
|
|
3
3
|
"rubygems": "2.5.0",
|
|
4
|
-
"ext": "v0.1.
|
|
4
|
+
"ext": "v0.1.68",
|
|
5
5
|
"crates": "1.5.1",
|
|
6
6
|
"npm": null,
|
|
7
7
|
"pypi": null,
|
|
8
|
-
"released_at": "2026-11-
|
|
8
|
+
"released_at": "2026-11-30T10:49:52Z",
|
|
9
9
|
"_comment": "expressir#618 \u2014 the engine-compat manifest, mirroring parsanol-rs#423. Maps the expressir gem train to the expressir-rs ext tag and its engine commit; the null fields fill as the crates/npm/pypi tiers land (expressir#619/#622/#621). tools/check_engine_compat.rb verifies the pairings in CI; every release train updates this file."
|
|
10
10
|
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
data/lib/expressir/cli.rb
CHANGED
|
@@ -70,6 +70,9 @@ module Expressir
|
|
|
70
70
|
method_option :stepmod, type: :string,
|
|
71
71
|
desc: "STEPmod checkout root — explicit opt-in to directory-" \
|
|
72
72
|
"convention resolution as the fallback"
|
|
73
|
+
method_option :typeof, type: :boolean, default: false,
|
|
74
|
+
desc: "Prepend a TYPEOF comment to every entity (the " \
|
|
75
|
+
"supertype chain plus admitting SELECT types)"
|
|
73
76
|
def flatten(path, _thor_options = nil)
|
|
74
77
|
Expressir::Commands::Flatten.new(options).run(path)
|
|
75
78
|
end
|
|
@@ -129,13 +132,37 @@ module Expressir
|
|
|
129
132
|
Expressir::Commands::ExportOwl.new(options).run(path)
|
|
130
133
|
end
|
|
131
134
|
|
|
135
|
+
desc "cleanup-parens PATH", "Minimize redundant parentheses in where rules; write the paren-clean EXPRESS"
|
|
136
|
+
option :output, type: :string, aliases: "-o",
|
|
137
|
+
desc: "Output path (defaults to <path>-paren-clean.exp beside PATH)"
|
|
138
|
+
def cleanup_parens(path)
|
|
139
|
+
Expressir::Commands::CleanupParens.new(options).run(path)
|
|
140
|
+
end
|
|
141
|
+
|
|
132
142
|
desc "compare BASE REVISED", "Compare two EXPRESS files; write the schema.changes interchange report"
|
|
133
143
|
option :output, type: :string, aliases: "-o",
|
|
134
144
|
desc: "Report path (defaults to stdout)"
|
|
145
|
+
option :patch, type: :string,
|
|
146
|
+
desc: "Also write a PATCH_SCHEMA derived from the diff to PATH"
|
|
135
147
|
def compare(base_path, revised_path)
|
|
136
148
|
Expressir::Commands::Compare.new(options).run(base_path, revised_path)
|
|
137
149
|
end
|
|
138
150
|
|
|
151
|
+
desc "patch BASE PATCH", "Apply an eengine-style patch schema to BASE; write the patched EXPRESS"
|
|
152
|
+
option :output, type: :string, aliases: "-o",
|
|
153
|
+
desc: "Output path (defaults to <base>-patched.exp beside BASE)"
|
|
154
|
+
def patch(base_path, patch_path)
|
|
155
|
+
Expressir::Commands::Patch.new(options).run(base_path, patch_path)
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
desc "compare-arm-mim BASE_ARM REV_ARM BASE_MIM REV_MIM", "Compare the arm/mim pairs; write the module.xml-shaped changes document"
|
|
159
|
+
option :output, type: :string, aliases: "-o",
|
|
160
|
+
desc: "Document path (defaults to stdout)"
|
|
161
|
+
def compare_arm_mim(base_arm, revised_arm, base_mim, revised_mim)
|
|
162
|
+
Expressir::Commands::CompareArmMim.new(options)
|
|
163
|
+
.run(base_arm, revised_arm, base_mim, revised_mim)
|
|
164
|
+
end
|
|
165
|
+
|
|
139
166
|
desc "doctor DIR", "Assess a workspace for expressir readiness"
|
|
140
167
|
option :emit_manifest, type: :string, desc: "Write a starter schema manifest listing the ready schemas"
|
|
141
168
|
def doctor(path)
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Expressir
|
|
4
|
+
module Commands
|
|
5
|
+
# `expressir cleanup-parens` (eengine `--cleanup_parens` parity):
|
|
6
|
+
# minimize redundant parentheses in the entity where rules and
|
|
7
|
+
# write the schema back out (`<name>-paren-clean.exp`).
|
|
8
|
+
class CleanupParens < Base
|
|
9
|
+
def run(path)
|
|
10
|
+
repository = Expressir::Express::Parser.from_file(path,
|
|
11
|
+
skip_references: true)
|
|
12
|
+
repository.schemas.each { |schema| Expressir::Express::CleanupParens.call(schema) }
|
|
13
|
+
|
|
14
|
+
formatter = Expressir::Express::PrettyFormatter.new
|
|
15
|
+
output = +"-- -*- Mode: EXPRESS; Base: 10 -*-\n\n"
|
|
16
|
+
output << "(* Paren-cleaned by Expressir #{Expressir::VERSION} *)\n\n"
|
|
17
|
+
output << formatter.format(repository)
|
|
18
|
+
|
|
19
|
+
destination = options[:output] || path.sub(/\.exp\z/i, "-paren-clean.exp")
|
|
20
|
+
File.write(destination, output)
|
|
21
|
+
say "paren-clean schema written to #{destination}"
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Expressir
|
|
4
|
+
module Commands
|
|
5
|
+
class Compare
|
|
6
|
+
# The schema.delta collection both compare commands share:
|
|
7
|
+
# the schema-changes report (additions/modifications/deletions)
|
|
8
|
+
# over one base/revised pair.
|
|
9
|
+
module ReportBuilding
|
|
10
|
+
KINDS = {
|
|
11
|
+
constants: "CONSTANT",
|
|
12
|
+
types: "TYPE",
|
|
13
|
+
entities: "ENTITY",
|
|
14
|
+
subtype_constraints: "SUBTYPE_CONSTRAINT",
|
|
15
|
+
functions: "FUNCTION",
|
|
16
|
+
rules: "RULE",
|
|
17
|
+
procedures: "PROCEDURE",
|
|
18
|
+
}.freeze
|
|
19
|
+
|
|
20
|
+
def build_report(base_repo, revised_repo)
|
|
21
|
+
sections = { additions: [], deletions: [], modifications: [] }
|
|
22
|
+
base = index_schemas(base_repo)
|
|
23
|
+
revised = index_schemas(revised_repo)
|
|
24
|
+
|
|
25
|
+
(base.keys | revised.keys).each do |schema_id|
|
|
26
|
+
base_schema = base[schema_id]
|
|
27
|
+
revised_schema = revised[schema_id]
|
|
28
|
+
if base_schema.nil?
|
|
29
|
+
collect_whole_schema(revised_schema, :added, sections)
|
|
30
|
+
elsif revised_schema.nil?
|
|
31
|
+
collect_whole_schema(base_schema, :removed, sections)
|
|
32
|
+
else
|
|
33
|
+
collect_deltas(base_schema, revised_schema, sections)
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
Expressir::Eengine::CompareReport.new(
|
|
38
|
+
additions: Expressir::Eengine::ChangesSection
|
|
39
|
+
.new(modified_objects: sections[:additions]),
|
|
40
|
+
deletions: Expressir::Eengine::ChangesSection
|
|
41
|
+
.new(modified_objects: sections[:deletions]),
|
|
42
|
+
modifications: Expressir::Eengine::ChangesSection
|
|
43
|
+
.new(modified_objects: sections[:modifications]),
|
|
44
|
+
)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def report_pair(base_path, revised_path)
|
|
48
|
+
base_repo = Expressir::Express::Parser.from_file(base_path)
|
|
49
|
+
revised_repo = Expressir::Express::Parser.from_file(revised_path)
|
|
50
|
+
build_report(base_repo, revised_repo)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def object_node(doc, obj)
|
|
54
|
+
node = doc.create_element("modified.object")
|
|
55
|
+
attrs = { "type" => obj.type, "name" => obj.name }
|
|
56
|
+
attrs["interfaced.items"] = obj.interfaced_items if obj.interfaced_items
|
|
57
|
+
attrs["classif"] = obj.classif if obj.classif
|
|
58
|
+
node.set_attributes(attrs)
|
|
59
|
+
if obj.description
|
|
60
|
+
desc = doc.create_element("description")
|
|
61
|
+
desc.content = obj.description
|
|
62
|
+
node.add_child(desc)
|
|
63
|
+
end
|
|
64
|
+
node
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
private
|
|
68
|
+
|
|
69
|
+
def index_schemas(repo)
|
|
70
|
+
Array(repo.schemas).to_h { |schema| [schema.id&.safe_downcase, schema] }
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def collect_whole_schema(schema, operation, sections)
|
|
74
|
+
section = section_for(operation)
|
|
75
|
+
Expressir::Express::SchemaCompare::COLLECTIONS.each do |collection|
|
|
76
|
+
Array(schema.send(collection)).each do |decl|
|
|
77
|
+
next unless decl.respond_to?(:id) && decl.id
|
|
78
|
+
|
|
79
|
+
sections[section] << Expressir::Eengine::ModifiedObject.new(
|
|
80
|
+
type: KINDS[collection], name: decl.id,
|
|
81
|
+
)
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
def collect_deltas(base_schema, revised_schema, sections)
|
|
87
|
+
Expressir::Express::SchemaCompare::COLLECTIONS.each do |collection|
|
|
88
|
+
deltas = Expressir::Express::SchemaCompare
|
|
89
|
+
.collection_deltas(base_schema, revised_schema, collection)
|
|
90
|
+
Expressir::Express::ChangeClassification.apply(deltas, base_schema)
|
|
91
|
+
deltas.each do |delta|
|
|
92
|
+
# an attribute-level delta modifies its entity: it lands
|
|
93
|
+
# in modifications whatever the op
|
|
94
|
+
section = if delta.path.split(".").size > 2
|
|
95
|
+
:modifications
|
|
96
|
+
else
|
|
97
|
+
section_for(delta.op)
|
|
98
|
+
end
|
|
99
|
+
sections[section] << object_for(delta, collection)
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
def object_for(delta, collection)
|
|
105
|
+
kind = KINDS[collection]
|
|
106
|
+
segments = delta.path.split(".")
|
|
107
|
+
name = segments[1]
|
|
108
|
+
object = if segments.size > 2
|
|
109
|
+
# attribute-level delta: the qualified path is the name
|
|
110
|
+
Expressir::Eengine::ModifiedObject.new(
|
|
111
|
+
type: kind, name: delta.path,
|
|
112
|
+
description: "attribute #{delta.op}"
|
|
113
|
+
)
|
|
114
|
+
else
|
|
115
|
+
Expressir::Eengine::ModifiedObject.new(type: kind, name: name)
|
|
116
|
+
end
|
|
117
|
+
object.classif = delta.classification&.value
|
|
118
|
+
object
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
def section_for(operation)
|
|
122
|
+
case operation
|
|
123
|
+
when :added then :additions
|
|
124
|
+
when :removed then :deletions
|
|
125
|
+
else :modifications
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
end
|
|
@@ -7,15 +7,8 @@ module Expressir
|
|
|
7
7
|
# the `changes` importer reads, so comparison data flows both ways
|
|
8
8
|
# across toolchains.
|
|
9
9
|
class Compare < Base
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
types: "TYPE",
|
|
13
|
-
entities: "ENTITY",
|
|
14
|
-
subtype_constraints: "SUBTYPE_CONSTRAINT",
|
|
15
|
-
functions: "FUNCTION",
|
|
16
|
-
rules: "RULE",
|
|
17
|
-
procedures: "PROCEDURE",
|
|
18
|
-
}.freeze
|
|
10
|
+
autoload :ReportBuilding, "#{__dir__}/compare/report_building"
|
|
11
|
+
include ReportBuilding
|
|
19
12
|
|
|
20
13
|
def run(base_path, revised_path)
|
|
21
14
|
base_repo = Expressir::Express::Parser.from_file(base_path)
|
|
@@ -28,149 +21,94 @@ module Expressir
|
|
|
28
21
|
else
|
|
29
22
|
$stdout.write(xml)
|
|
30
23
|
end
|
|
31
|
-
|
|
24
|
+
return unless options[:patch]
|
|
32
25
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
# (same upstream family as lutaml-model#997). The model layer
|
|
37
|
-
# stays lutaml-model; the XML face is Moxml.
|
|
38
|
-
def serialize(report)
|
|
39
|
-
ctx = Moxml::Context.new
|
|
40
|
-
doc = ctx.create_document
|
|
41
|
-
root = doc.create_element("schema.changes")
|
|
42
|
-
doc.add_child(root)
|
|
43
|
-
{
|
|
44
|
-
"schema.additions" => report.additions,
|
|
45
|
-
"schema.deletions" => report.deletions,
|
|
46
|
-
"schema.modifications" => report.modifications,
|
|
47
|
-
}.each do |name, section|
|
|
48
|
-
root.add_child(section_node(doc, name, section))
|
|
49
|
-
end
|
|
50
|
-
doc.to_xml
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
def section_node(doc, name, section)
|
|
54
|
-
node = doc.create_element(name)
|
|
55
|
-
Array(section&.modified_objects).each do |obj|
|
|
56
|
-
node.add_child(object_node(doc, obj))
|
|
57
|
-
end
|
|
58
|
-
node
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
def object_node(doc, obj)
|
|
62
|
-
node = doc.create_element("modified.object")
|
|
63
|
-
attrs = { "type" => obj.type, "name" => obj.name }
|
|
64
|
-
attrs["interfaced.items"] = obj.interfaced_items if obj.interfaced_items
|
|
65
|
-
attrs["classif"] = obj.classif if obj.classif
|
|
66
|
-
node.set_attributes(attrs)
|
|
67
|
-
if obj.description
|
|
68
|
-
desc = doc.create_element("description")
|
|
69
|
-
desc.content = obj.description
|
|
70
|
-
node.add_child(desc)
|
|
71
|
-
end
|
|
72
|
-
node
|
|
26
|
+
patch_text = generate_patch(base_repo, revised_repo)
|
|
27
|
+
File.write(options[:patch], patch_text)
|
|
28
|
+
say "patch written to #{options[:patch]}"
|
|
73
29
|
end
|
|
74
30
|
|
|
75
|
-
|
|
76
|
-
|
|
31
|
+
# The PATCH_SCHEMA derived from the diff (the compare→patch
|
|
32
|
+
# loop): deletions become DELETE commands; modified and added
|
|
33
|
+
# declarations re-emit the revised declaration, which the patch
|
|
34
|
+
# applier treats as replace-or-add. One PATCH_SCHEMA per
|
|
35
|
+
# touched schema (each patch targets one schema, like eengine).
|
|
36
|
+
def generate_patch(base_repo, revised_repo)
|
|
77
37
|
base = index_schemas(base_repo)
|
|
78
38
|
revised = index_schemas(revised_repo)
|
|
79
|
-
|
|
39
|
+
out = "(* Patch generated by Expressir #{Expressir::VERSION} *)\n\n"
|
|
80
40
|
(base.keys | revised.keys).each do |schema_id|
|
|
81
41
|
base_schema = base[schema_id]
|
|
82
42
|
revised_schema = revised[schema_id]
|
|
83
43
|
if base_schema.nil?
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
collect_whole_schema(base_schema, :removed, sections)
|
|
87
|
-
else
|
|
88
|
-
collect_deltas(base_schema, revised_schema, sections)
|
|
44
|
+
out << "(* schema #{schema_id} added wholesale; no patch target *)\n\n"
|
|
45
|
+
next
|
|
89
46
|
end
|
|
90
|
-
|
|
47
|
+
next out << "(* schema #{schema_id} removed wholesale *)\n\n" if revised_schema.nil?
|
|
91
48
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
.new(modified_objects: sections[:additions]),
|
|
95
|
-
deletions: Expressir::Eengine::ChangesSection
|
|
96
|
-
.new(modified_objects: sections[:deletions]),
|
|
97
|
-
modifications: Expressir::Eengine::ChangesSection
|
|
98
|
-
.new(modified_objects: sections[:modifications]),
|
|
99
|
-
)
|
|
100
|
-
end
|
|
101
|
-
|
|
102
|
-
def index_schemas(repo)
|
|
103
|
-
Array(repo.schemas).to_h do |schema|
|
|
104
|
-
[schema.id&.safe_downcase, schema]
|
|
105
|
-
end
|
|
106
|
-
end
|
|
49
|
+
items = patch_items(base_schema, revised_schema)
|
|
50
|
+
next if items.empty?
|
|
107
51
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
Array(schema.send(collection)).each do |decl|
|
|
112
|
-
next unless decl.respond_to?(:id) && decl.id
|
|
113
|
-
|
|
114
|
-
sections[section] << Expressir::Eengine::ModifiedObject.new(
|
|
115
|
-
type: KINDS[collection], name: decl.id,
|
|
116
|
-
)
|
|
117
|
-
end
|
|
52
|
+
out << "PATCH_SCHEMA #{schema_id}_patch TARGET #{schema_id};\n"
|
|
53
|
+
items.each { |item| out << item }
|
|
54
|
+
out << "END_PATCH_SCHEMA;\n\n"
|
|
118
55
|
end
|
|
56
|
+
out
|
|
119
57
|
end
|
|
120
58
|
|
|
121
|
-
def
|
|
59
|
+
def patch_items(base_schema, revised_schema)
|
|
60
|
+
items = []
|
|
61
|
+
replaced = {}
|
|
122
62
|
Expressir::Express::SchemaCompare::COLLECTIONS.each do |collection|
|
|
63
|
+
kind = KINDS[collection]
|
|
123
64
|
deltas = Expressir::Express::SchemaCompare
|
|
124
65
|
.collection_deltas(base_schema, revised_schema, collection)
|
|
125
66
|
Expressir::Express::ChangeClassification.apply(deltas, base_schema)
|
|
126
67
|
deltas.each do |delta|
|
|
127
|
-
|
|
128
|
-
#
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
68
|
+
segments = delta.path.split(".")
|
|
69
|
+
# attribute-level deltas ride the owning entity's replace
|
|
70
|
+
name = segments[1]
|
|
71
|
+
if delta.op == :removed && segments.size == 2
|
|
72
|
+
items << " DELETE #{kind} #{segments.last};\n"
|
|
73
|
+
next
|
|
74
|
+
end
|
|
75
|
+
next if segments.size > 2 && replaced[[kind, name]]
|
|
76
|
+
|
|
77
|
+
replaced[[kind, name]] = true
|
|
78
|
+
revised_decl = Array(revised_schema.send(collection))
|
|
79
|
+
.find { |d| d.respond_to?(:id) && d.id&.casecmp(name)&.zero? }
|
|
80
|
+
items << " #{revised_decl.format}\n" if revised_decl
|
|
135
81
|
end
|
|
136
82
|
end
|
|
83
|
+
items
|
|
137
84
|
end
|
|
138
85
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
def section_for(operation)
|
|
156
|
-
case operation
|
|
157
|
-
when :added then :additions
|
|
158
|
-
when :removed then :deletions
|
|
159
|
-
else :modifications
|
|
86
|
+
# Emitted through Moxml directly: lutaml-model's leptris-backed
|
|
87
|
+
# serializer mis-parses the interchange's dotted element names
|
|
88
|
+
# ("schema.changes") as namespace prefixes and fails the build
|
|
89
|
+
# (same upstream family as lutaml-model#997). The model layer
|
|
90
|
+
# stays lutaml-model; the XML face is Moxml.
|
|
91
|
+
def serialize(report)
|
|
92
|
+
ctx = Moxml::Context.new
|
|
93
|
+
doc = ctx.create_document
|
|
94
|
+
root = doc.create_element("schema.changes")
|
|
95
|
+
doc.add_child(root)
|
|
96
|
+
{
|
|
97
|
+
"schema.additions" => report.additions,
|
|
98
|
+
"schema.deletions" => report.deletions,
|
|
99
|
+
"schema.modifications" => report.modifications,
|
|
100
|
+
}.each do |name, section|
|
|
101
|
+
root.add_child(section_node(doc, name, section))
|
|
160
102
|
end
|
|
103
|
+
doc.to_xml
|
|
161
104
|
end
|
|
162
105
|
|
|
163
|
-
def
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
when Model::Declarations::Function then "FUNCTION"
|
|
168
|
-
when Model::Declarations::Rule then "RULE"
|
|
169
|
-
when Model::Declarations::SubtypeConstraint then "SUBTYPE_CONSTRAINT"
|
|
170
|
-
when Model::Declarations::Constant then "CONSTANT"
|
|
171
|
-
when Model::Declarations::Procedure then "PROCEDURE"
|
|
172
|
-
else declaration.class.name.split("::").last.upcase
|
|
106
|
+
def section_node(doc, name, section)
|
|
107
|
+
node = doc.create_element(name)
|
|
108
|
+
Array(section&.modified_objects).each do |obj|
|
|
109
|
+
node.add_child(object_node(doc, obj))
|
|
173
110
|
end
|
|
111
|
+
node
|
|
174
112
|
end
|
|
175
113
|
end
|
|
176
114
|
end
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Expressir
|
|
4
|
+
module Commands
|
|
5
|
+
# `expressir compare-arm-mim` (eengine module-compare parity): the
|
|
6
|
+
# arm.exp and mim.exp pairs compare independently and land in one
|
|
7
|
+
# module.xml-shaped `<changes>` document — `<arm.changes>` /
|
|
8
|
+
# `<mim.changes>` with additions/modifications/deletions sections
|
|
9
|
+
# holding the eengine fragment vocabulary (`<modified.object>` and
|
|
10
|
+
# `<description>`).
|
|
11
|
+
class CompareArmMim < Base
|
|
12
|
+
include Compare::ReportBuilding
|
|
13
|
+
|
|
14
|
+
PREFIXES = %w[arm mim].freeze
|
|
15
|
+
SECTIONS = %w[additions modifications deletions].freeze
|
|
16
|
+
|
|
17
|
+
def run(base_arm_path, revised_arm_path, base_mim_path, revised_mim_path)
|
|
18
|
+
arm = report_pair(base_arm_path, revised_arm_path)
|
|
19
|
+
mim = report_pair(base_mim_path, revised_mim_path)
|
|
20
|
+
xml = serialize(arm, mim)
|
|
21
|
+
if options[:output]
|
|
22
|
+
File.write(options[:output], xml)
|
|
23
|
+
say "changes document written to #{options[:output]}"
|
|
24
|
+
else
|
|
25
|
+
$stdout.write(xml)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# Emitted through Moxml directly — same reason as
|
|
30
|
+
# Compare#serialize (lutaml-model's leptris serializer
|
|
31
|
+
# mis-parses dotted element names).
|
|
32
|
+
def serialize(arm, mim)
|
|
33
|
+
ctx = Moxml::Context.new
|
|
34
|
+
doc = ctx.create_document
|
|
35
|
+
root = doc.create_element("changes")
|
|
36
|
+
doc.add_child(root)
|
|
37
|
+
PREFIXES.each do |prefix|
|
|
38
|
+
report = prefix == "arm" ? arm : mim
|
|
39
|
+
SECTIONS.each do |section|
|
|
40
|
+
changes = report.public_send(section)
|
|
41
|
+
node = doc.create_element("#{prefix}.#{section}")
|
|
42
|
+
Array(changes&.modified_objects).each do |obj|
|
|
43
|
+
node.add_child(object_node(doc, obj))
|
|
44
|
+
end
|
|
45
|
+
root.add_child(node)
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
doc.to_xml
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
@@ -14,7 +14,8 @@ module Expressir
|
|
|
14
14
|
extenders = options[:extenders] == "none" ? :none : :all
|
|
15
15
|
flat = Expressir::Express::Shtolo.new(root, repository,
|
|
16
16
|
longform_name: longform_name,
|
|
17
|
-
extenders: extenders
|
|
17
|
+
extenders: extenders,
|
|
18
|
+
typeof: options[:typeof]).flatten.schema
|
|
18
19
|
text = Expressir::Express::Formatter.format(flat)
|
|
19
20
|
|
|
20
21
|
if options[:output]
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Expressir
|
|
4
|
+
module Commands
|
|
5
|
+
# `expressir patch` (eengine `--patch` parity): apply a patch
|
|
6
|
+
# schema (DELETE / RENAME / replace-or-add declarations) to a
|
|
7
|
+
# base EXPRESS file and write the patched schema pretty-printed
|
|
8
|
+
# with the Expressir patch banner.
|
|
9
|
+
class Patch < Base
|
|
10
|
+
def run(base_path, patch_path)
|
|
11
|
+
# Name matching only — the applier never dereferences, and
|
|
12
|
+
# eengine's own renames leave reference targets untouched.
|
|
13
|
+
repository = Expressir::Express::Parser.from_file(base_path,
|
|
14
|
+
skip_references: true)
|
|
15
|
+
patch_text = File.read(patch_path)
|
|
16
|
+
schema = Expressir::Express::PatchSchema.apply(repository, patch_text)
|
|
17
|
+
|
|
18
|
+
formatter = Expressir::Express::PrettyFormatter.new
|
|
19
|
+
output = +"-- -*- Mode: Express; Base: 10 -*-\n\n"
|
|
20
|
+
output << "(* Schema Patched by Expressir #{Expressir::VERSION}\n"
|
|
21
|
+
output << " patch: #{patch_path}\n"
|
|
22
|
+
output << "*)\n\n"
|
|
23
|
+
output << "(* File: #{base_path} *)\n"
|
|
24
|
+
output << "(* Schema: #{schema.id} *)\n"
|
|
25
|
+
output << formatter.format(repository)
|
|
26
|
+
|
|
27
|
+
destination = options[:output] || base_path.sub(/\.exp\z/i, "-patched.exp")
|
|
28
|
+
File.write(destination, output)
|
|
29
|
+
say "patched schema written to #{destination}"
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
data/lib/expressir/commands.rb
CHANGED
|
@@ -5,6 +5,7 @@ module Expressir
|
|
|
5
5
|
autoload :Benchmark, "#{__dir__}/commands/benchmark"
|
|
6
6
|
autoload :BenchmarkCache, "#{__dir__}/commands/benchmark_cache"
|
|
7
7
|
autoload :Check, "#{__dir__}/commands/check"
|
|
8
|
+
autoload :CleanupParens, "#{__dir__}/commands/cleanup_parens"
|
|
8
9
|
autoload :Clean, "#{__dir__}/commands/clean"
|
|
9
10
|
autoload :Coverage, "#{__dir__}/commands/coverage"
|
|
10
11
|
autoload :Expand, "#{__dir__}/commands/expand"
|
|
@@ -25,7 +26,9 @@ module Expressir
|
|
|
25
26
|
autoload :Version, "#{__dir__}/commands/version_command"
|
|
26
27
|
autoload :Package, "#{__dir__}/commands/package"
|
|
27
28
|
autoload :Compare, "#{__dir__}/commands/compare"
|
|
29
|
+
autoload :CompareArmMim, "#{__dir__}/commands/compare_arm_mim"
|
|
28
30
|
autoload :Doctor, "#{__dir__}/commands/doctor"
|
|
31
|
+
autoload :Patch, "#{__dir__}/commands/patch"
|
|
29
32
|
autoload :Population, "#{__dir__}/commands/population"
|
|
30
33
|
autoload :Receipt, "#{__dir__}/commands/receipt"
|
|
31
34
|
autoload :Manifest, "#{__dir__}/commands/manifest"
|