expressir 2.4.54-x86_64-linux → 2.4.56-x86_64-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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: df13a2ff73701682eeca655e798104386342e59dbbdc64a6e1e03b2000823302
4
- data.tar.gz: '072283e993dfa65025f0fe305aebfabda2b512e99b5ae5889634133e3424dc5a'
3
+ metadata.gz: 17335d011267c118c48a715a55b2d30b7acb1c8c5c9d612a02b1eec612ae1839
4
+ data.tar.gz: 41d8f8361187a3d998b36a8b334e12d8eefd7884b0b05fa68610d711b9a8c38c
5
5
  SHA512:
6
- metadata.gz: 3d99ffc6a0f1c11405049873be99045f509fd9d40067f6b73577f622488894e75ec84d95bc082ef33443a5d04a017bf6acd63e76b61a4e0ccfd856da57f8d366
7
- data.tar.gz: bbb0ae3d2ecb3378e8b6028ba1432c89e8a715d4dae5b34da6b90285589be23f8492e2da012102c4586b88a2d88b3e33e56939d6025450a7acdbfd9834fd898c
6
+ metadata.gz: 5c4a9baf8be06e8ac83a07be9f271c12b7917781fe2fd724de15af4d367d78b5f8a8e2f180946b812e837aea37ce27229b5c38ccb8806e23453e8075181b5263
7
+ data.tar.gz: fee8a14c9f2554d2f9780cdfae12428cc6006501e6a8486a05d1232b88c63c4511cebcff94652ddf20845807a7fcfe145940745e647c1fde325cac88775d66bb
Binary file
Binary file
Binary file
Binary file
@@ -47,12 +47,47 @@ module Expressir
47
47
  end
48
48
  end
49
49
 
50
+ # Runs the checks. When the native extension exposes the core
51
+ # checker (issue #21), each file's model wire is checked in Rust;
52
+ # the findings are identical to this class's Ruby walk (gated by
53
+ # the checker parity suites). The Ruby walk stays as the
54
+ # fallback for non-native environments.
50
55
  def check
56
+ return check_via_core if core_check_available?
57
+
51
58
  @notes = []
52
59
  @repository.schemas.compact.each { |schema| check_schema(schema) }
53
60
  self
54
61
  end
55
62
 
63
+ def core_check_available?
64
+ Expressir::Express::Core::NATIVE_AVAILABLE &&
65
+ Expressir::Express::Core.respond_to?(:check_model_hash)
66
+ end
67
+
68
+ def check_via_core
69
+ # The Ruby Checker sees the whole repository (cross-file
70
+ # interfaces, self-schema defining schemas), so the wire keeps
71
+ # the repository shape when the model has one.
72
+ wire =
73
+ if @repository.respond_to?(:files)
74
+ {
75
+ "_class" => "Expressir::Model::Repository",
76
+ "files" => @repository.files.compact.map(&:to_hash),
77
+ }
78
+ else
79
+ @repository.to_hash
80
+ end
81
+ @notes = Expressir::Express::Core.check_model_hash(wire, @dialect)
82
+ .map do |note|
83
+ Note.new(
84
+ id: note[:id].to_sym, severity: note[:severity].to_sym,
85
+ schema: note[:schema], message: note[:message]
86
+ )
87
+ end
88
+ self
89
+ end
90
+
56
91
  def errors
57
92
  notes.select { |n| n.severity == :error }
58
93
  end
@@ -48,6 +48,21 @@ module Expressir
48
48
  ::Expressir::Core.parse_to_model_attached(source, path)
49
49
  end
50
50
 
51
+ # Like parse_to_model_attached, but also returns the attached
52
+ # wire JSON string ([model, wire_json]) so the file retains a
53
+ # lossless handle for the Rust formatter (issue #22).
54
+ def self.parse_to_model_attached_with_wire(source, path)
55
+ unless NATIVE_AVAILABLE &&
56
+ ::Expressir::Core.respond_to?(:parse_to_model_attached_with_wire)
57
+ raise NotImplementedError, "core wire retention unavailable"
58
+ end
59
+
60
+ model, wire_json = ::Expressir::Core.parse_to_model_attached_with_wire(source, path)
61
+ model.wire_parents
62
+ model.core_wire = wire_json
63
+ model
64
+ end
65
+
51
66
  # Scan remarks (issue #20): an Array of Hashes mirroring
52
67
  # RemarkScanner::Remark's fields (position, end_position, line,
53
68
  # text, tag, format), straight from the Rust scanner.
@@ -55,6 +70,31 @@ module Expressir
55
70
  ::Expressir::Core.scan_remarks(source)
56
71
  end
57
72
 
73
+ # SourceFormatter (issue #22): the rendered EXPRESS text for one
74
+ # file's model-hash wire, straight from the Rust formatter.
75
+ def self.format_model_hash(wire, no_remarks: false)
76
+ raise NotImplementedError, "the native extension is unavailable" unless NATIVE_AVAILABLE
77
+
78
+ ::Expressir::Core.format_model_hash(JSON.generate(wire), no_remarks)
79
+ end
80
+
81
+ # Semantic checks (issue #21): the Checker's findings over one
82
+ # file's model-hash wire, as an Array of Hashes with
83
+ # id/severity/schema/message in the checker's canonical order.
84
+ # `dialect` is nil or a Dialect value; the 1994 edition is
85
+ # translated to the short form the core expects.
86
+ def self.check_model_hash(wire, dialect = nil)
87
+ raise NotImplementedError, "the native extension is unavailable" unless NATIVE_AVAILABLE
88
+
89
+ wire_json = JSON.generate(wire)
90
+ core_dialect = case dialect
91
+ when nil then nil
92
+ when Dialect::EDITION_1994, "10303-11:1994" then "1994"
93
+ else dialect.to_s
94
+ end
95
+ ::Expressir::Core.check_model_hash(wire_json, core_dialect)
96
+ end
97
+
58
98
  # Parse EXPRESS source into the hydrated model directly: the
59
99
  # extension walks the wire definition once and constructs every
60
100
  # node through Serializable.instantiate (lutaml-model's fast
@@ -73,8 +73,18 @@ module Expressir
73
73
  new.format(node)
74
74
  end
75
75
 
76
+ # When the native extension exposes the core formatter (issue
77
+ # #22), an ExpFile parsed on the core lane renders in Rust over
78
+ # its RETAINED wire — a to_hash round trip would drop empty
79
+ # collections and lose paren-less-function semantics. The base
80
+ # class only: subclasses (PrettyFormatter) keep the Ruby walk,
81
+ # which stays as the fallback everywhere else.
76
82
  def format(node)
77
83
  return "" if node.nil?
84
+ if node.is_a?(Model::ExpFile) && node.core_wire.is_a?(String) &&
85
+ base_formatter? && core_format_available?
86
+ return format_via_core(node)
87
+ end
78
88
 
79
89
  handler = self.class.format_registry[node.class]
80
90
  unless handler
@@ -85,6 +95,21 @@ module Expressir
85
95
  place_remarks(send(handler, node), node)
86
96
  end
87
97
 
98
+ def base_formatter?
99
+ instance_of?(Expressir::Express::Formatter)
100
+ end
101
+
102
+ def core_format_available?
103
+ Expressir::Express::Core::NATIVE_AVAILABLE &&
104
+ Expressir::Express::Core.respond_to?(:format_model_hash)
105
+ end
106
+
107
+ def format_via_core(file)
108
+ Expressir::Express::Core.format_model_hash(
109
+ JSON.parse(file.core_wire), no_remarks: @no_remarks
110
+ )
111
+ end
112
+
88
113
  private
89
114
 
90
115
  # Puts a node's remarks back around its formatted text. Each placement
@@ -211,9 +211,9 @@ module Expressir
211
211
  remarks_attached = false
212
212
  exp_file =
213
213
  begin
214
- if Core.respond_to?(:parse_to_model_attached)
214
+ if Core.respond_to?(:parse_to_model_attached_with_wire)
215
215
  remarks_attached = true
216
- Core.parse_to_model_attached(source, schema_file)
216
+ Core.parse_to_model_attached_with_wire(source, schema_file)
217
217
  .tap(&:wire_parents)
218
218
  else
219
219
  Core.parse_to_model(source, schema_file).tap(&:wire_parents)
@@ -27,6 +27,14 @@ module Expressir
27
27
  map "schemas", to: :schemas
28
28
  end
29
29
 
30
+ # The model-hash wire this file was hydrated from, retained by
31
+ # the core parse lane (issue #22): the Rust formatter renders
32
+ # THIS wire, whose nil-vs-empty collections are exactly as the
33
+ # core emitted them (a `to_hash` round trip would drop empty
34
+ # collections and lose paren-less-function semantics). Not a
35
+ # lutaml attribute — it never serializes.
36
+ attr_accessor :core_wire
37
+
30
38
  # Returns the file path as the identifier
31
39
  # @return [String, nil] The file path or nil
32
40
  def id
@@ -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.54".freeze
6
+ VERSION = "2.4.56".freeze
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: expressir
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.54
4
+ version: 2.4.56
5
5
  platform: x86_64-linux
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-11-05 00:00:00.000000000 Z
11
+ date: 2026-11-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: base64