expressir 2.4.54 → 2.4.55

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: 67855d853e2de439be7e5b5dfc4eec2c2c8aa3b409c885d277a10aa6593af0ba
4
- data.tar.gz: 3e59c60890378f1559e1472ccf26b8cf01f0d977183c9d31ef7506163edeb1ae
3
+ metadata.gz: b3d75ba4d678e222bdca54971e9351c3b28ccd183624643ea23ecbdbdcc6bc59
4
+ data.tar.gz: 119ca50607135311f5b59ce7dde96af55b808856bd670c23a6afeee9c1bd17b8
5
5
  SHA512:
6
- metadata.gz: 52b2d2e1fdeb443492de6c52a9ae3a94dfb1a859539c52f1a463d0204577a1efb1cb624d056d9d5b35513062104ab67fce74492b0d2e2433c5d82b546fcad5e7
7
- data.tar.gz: 482c1ea8c08a331dac07c98ab122a86c9a5a64af702cc2d0551058fe73ed495807c65ec29816ac67d6c821a8209c317509f54c229550b910178380fc8aea6a9e
6
+ metadata.gz: '09eefedf81abfb902639ceaea4d22c4cf2d6407f20fae519a2228529813b3e38261d50cd99199d6393894f5e88fa64724da5214e89f39aae985aa3303529ecbb'
7
+ data.tar.gz: 983abe96e120404dd0c519f59fd133e7d3952d884b9d9806c421bd4ddbd810ed1ba27863fd3c82cd9aeed5c7dc4824a6dc1a83d9b9089a663fedae3e7a2f3d03
@@ -13,7 +13,7 @@ magnus = { version = "0.9" }
13
13
  # Pinned core release (M1, TODO.parity-ee/19): the ext never floats
14
14
  # main — bump the tag per expressir release, alongside the validation
15
15
  # run that pins it.
16
- expressir-rs = { git = "https://github.com/lutaml/expressir-rs", tag = "v0.1.19" }
16
+ expressir-rs = { git = "https://github.com/lutaml/expressir-rs", tag = "v0.1.24" }
17
17
  serde_json = "1.0"
18
18
 
19
19
 
@@ -581,10 +581,34 @@ fn model_object_attached(ruby: &Ruby, source: String, path: String) -> Result<ma
581
581
  value_to_ruby(ruby, &mut cache, &wire)
582
582
  }
583
583
 
584
+ /// `check_model_hash(wire_json, dialect)`: the semantic checks over a
585
+ /// wire (issue #21). `wire_json` is the model-hash JSON of one file;
586
+ /// findings come back as hashes with id/severity/schema/message in the
587
+ /// checker's canonical order.
588
+ fn check_model_hash(ruby: &Ruby, wire_json: String, dialect: Option<String>) -> Result<magnus::Value, Error> {
589
+ let mut wire: Wire = serde_json::from_str(&wire_json)
590
+ .map_err(|e| Error::new(ruby.exception_arg_error(), format!("wire: {e}")))?;
591
+ let notes = expressir_rs::checker::check(&mut wire, dialect.as_deref());
592
+ let array = ruby.ary_new_capa(notes.len());
593
+ for note in &notes {
594
+ let hash = ruby.hash_new();
595
+ hash.aset(ruby.sym_new("id"), ruby_str(ruby, &note.id))?;
596
+ hash.aset(ruby.sym_new("severity"), ruby_str(ruby, note.severity))?;
597
+ match &note.schema {
598
+ Some(schema) => hash.aset(ruby.sym_new("schema"), ruby_str(ruby, schema))?,
599
+ None => hash.aset(ruby.sym_new("schema"), ruby.qnil().as_value())?,
600
+ }
601
+ hash.aset(ruby.sym_new("message"), ruby_str(ruby, &note.message))?;
602
+ array.push(hash)?;
603
+ }
604
+ Ok(array.as_value())
605
+ }
606
+
584
607
  #[magnus::init]
585
608
  fn init(ruby: &Ruby) -> Result<(), Error> {
586
609
  let module = ruby.define_module("Expressir")?.define_module("Core")?;
587
610
  module.define_singleton_method("parse_to_model_hash", function!(model_json, 2))?;
611
+ module.define_singleton_method("check_model_hash", function!(check_model_hash, 2))?;
588
612
  module.define_singleton_method("parse_to_model", function!(model_object, 2))?;
589
613
  module.define_singleton_method("parse_to_model_attached", function!(model_object_attached, 2))?;
590
614
  module.define_singleton_method("scan_remarks", function!(scan_remarks, 1))?;
@@ -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
@@ -55,6 +55,23 @@ module Expressir
55
55
  ::Expressir::Core.scan_remarks(source)
56
56
  end
57
57
 
58
+ # Semantic checks (issue #21): the Checker's findings over one
59
+ # file's model-hash wire, as an Array of Hashes with
60
+ # id/severity/schema/message in the checker's canonical order.
61
+ # `dialect` is nil or a Dialect value; the 1994 edition is
62
+ # translated to the short form the core expects.
63
+ def self.check_model_hash(wire, dialect = nil)
64
+ raise NotImplementedError, "the native extension is unavailable" unless NATIVE_AVAILABLE
65
+
66
+ wire_json = JSON.generate(wire)
67
+ core_dialect = case dialect
68
+ when nil then nil
69
+ when Dialect::EDITION_1994, "10303-11:1994" then "1994"
70
+ else dialect.to_s
71
+ end
72
+ ::Expressir::Core.check_model_hash(wire_json, core_dialect)
73
+ end
74
+
58
75
  # Parse EXPRESS source into the hydrated model directly: the
59
76
  # extension walks the wire definition once and constructs every
60
77
  # node through Serializable.instantiate (lutaml-model's fast
@@ -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.55".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.54
4
+ version: 2.4.55
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.