expressir 2.4.43 → 2.4.44

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: c4c68267f62015b506607a5ddf4bb7e15910b5c4a4943bca53e11bdd62e12a79
4
- data.tar.gz: 39be2cd387f7042b5d0b079189d334f2f8bdde00eab2bc779c741212dd2ed13d
3
+ metadata.gz: 1eb19f12779500cf95395e7422a425bbb59e6e4e3f10cc1c62f5946f79cc4644
4
+ data.tar.gz: 227a77557ce585cb6313944dbc7cd6e5104f5e5594214c48a9c59955dce4a4b7
5
5
  SHA512:
6
- metadata.gz: '08bb3e423e574b3a482d77ce36cd15703a2d9dcf4e9f5127cb42683ab2533057fff251cd3cb71a59904e508c4b32edc1346ba38509f71abd3554eb2dad031861'
7
- data.tar.gz: 4d0a2171abd297c860e7e8b7e126223515746b5dc27fb373d814c5d434f28430ea11764eec54bcfd7898d3513fae28515eab5654d7560c56ce1e42153984e43d
6
+ metadata.gz: 80e48ee59df97ce558cd507a89eccae20c9063c3031f51dc77803b8ca5f148ac0cb5344dc969c3e0c639fd706f95d3db80788b0de1d56a411ccf10ea75f8e580
7
+ data.tar.gz: 043ec4835ace4e4922f166ceef3c216c2a8b6f2b06c591aca93a954172b31ec50d2cddc97c54e517ce84004a305a8f39249c95f3abd7c3a3311c831c9e63898e
@@ -442,10 +442,29 @@ fn value_to_ruby(ruby: &Ruby, cache: &mut ClassCache, wire: &Wire) -> Result<mag
442
442
  })?;
443
443
  let klass = cache.resolve(ruby, class_name)?;
444
444
  let attrs = RHash::new();
445
+ let mut null_members: Vec<String> = Vec::new();
445
446
  for (key, item) in map {
447
+ if matches!(item, Wire::Null) {
448
+ // instantiate coerces nil collections to []; a null
449
+ // wire member means the source had no value (e.g. no
450
+ // parameter parentheses, expressir#558), so it goes
451
+ // through the setter afterwards, which keeps nil
452
+ null_members.push(key.clone());
453
+ continue;
454
+ }
446
455
  attrs.aset(ruby.sym_new(key.as_str()), value_to_ruby(ruby, cache, item)?)?;
447
456
  }
448
- klass.funcall::<_, _, magnus::Value>("instantiate", (attrs,))
457
+ let object = klass.funcall::<_, _, magnus::Value>("instantiate", (attrs,))?;
458
+ for key in &null_members {
459
+ // the compiled writers coerce nil collections to [];
460
+ // the raw ivar keeps the null (no parentheses in the
461
+ // source, expressir#558)
462
+ let ivar = format!("@{key}");
463
+ let nil = ruby.qnil().as_value();
464
+ let _: magnus::Value =
465
+ object.funcall("instance_variable_set", (ivar.as_str(), nil))?;
466
+ }
467
+ Ok(object)
449
468
  }
450
469
  }
451
470
  }
@@ -245,7 +245,9 @@ module Expressir
245
245
  "FUNCTION",
246
246
  " ",
247
247
  node.id,
248
- *if node.parameters&.length&.positive?
248
+ # nil parameters = the source had no parentheses;
249
+ # [] = an explicit `f()` — the parens are written back
250
+ *if node.parameters
249
251
  parameter_indent = indent_char * "FUNCTION #{node.id}(".length
250
252
  [
251
253
  "(",
@@ -371,7 +373,9 @@ module Expressir
371
373
  "PROCEDURE",
372
374
  " ",
373
375
  node.id,
374
- *if node.parameters&.length&.positive?
376
+ # see format_declarations_function: nil = no parens,
377
+ # [] = explicit `p()`
378
+ *if node.parameters
375
379
  parameter_indent = indent_char * "PROCEDURE #{node.id}(".length
376
380
  [
377
381
  "(",
@@ -889,6 +889,20 @@ module Expressir
889
889
  end
890
890
  end
891
891
 
892
+ # A prefixed intermediate segment (wr:WR1.ip:IP2.__note) splits
893
+ # wrong under the generic prefix-normalized walk below, so the
894
+ # segment-aware resolution handles that class: resolve the
895
+ # longest owned prefix (honoring the wr:/ip:/ur: prefixes
896
+ # find() strips) and attach the first unresolved segment as the
897
+ # remark item id on that node — `<rule>.wr:WR1.__note` lands a
898
+ # `__note` item on WR1 (#562), not a `wr` item on the rule.
899
+ segments = path.split(".")
900
+ if segments.length > 2 &&
901
+ segments[0..-2].any? { |segment| segment.include?(":") } && (owned = resolve_longest_owned_prefix(model, path, schema_ids))
902
+ parent, item_id = owned
903
+ return create_item_at_parent(parent, item_id)
904
+ end
905
+
892
906
  clean_path = normalize_path(path)
893
907
  parts = clean_path.split(".")
894
908
  return nil if parts.length < 2
@@ -921,6 +935,41 @@ module Expressir
921
935
  "#{path_part}.#{item_suffix}"
922
936
  end
923
937
 
938
+ # Walks the tag's segments from a schema root, honoring the
939
+ # prefix forms find() strips (wr:WR1, ip:IP1, ur:UR1), and
940
+ # returns [node, first_unresolved_segment] for the deepest node
941
+ # the model owns. Nil when nothing resolves.
942
+ def resolve_longest_owned_prefix(model, path, schema_ids)
943
+ candidate_paths = [path]
944
+ schema_ids.each do |schema_id|
945
+ candidate_paths << "#{schema_id}.#{path}"
946
+ end
947
+
948
+ candidate_paths.each do |candidate|
949
+ segments = candidate.split(".")
950
+ next if segments.empty?
951
+
952
+ owned_path = segments.first
953
+ node = safe_find(model, owned_path)
954
+ next unless node
955
+
956
+ segments[1..].each_with_index do |segment, index|
957
+ stepped = safe_find(model, "#{owned_path}.#{segment}")
958
+ # a lazily created remark item is never a path owner
959
+ stepped = nil if stepped.is_a?(Model::Declarations::RemarkItem)
960
+ if stepped.nil?
961
+ return [node, segment] if index.positive?
962
+
963
+ break
964
+ end
965
+ owned_path = "#{owned_path}.#{segment}"
966
+ node = stepped
967
+ end
968
+ end
969
+
970
+ nil
971
+ end
972
+
924
973
  def create_item_at_parent(parent, item_id)
925
974
  # Strip "wr:" prefix convention (e.g. "wr:IP1" → "IP1")
926
975
  ip_id = extract_ip_id(item_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.43".freeze
6
+ VERSION = "2.4.44".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.43
4
+ version: 2.4.44
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-10-25 00:00:00.000000000 Z
11
+ date: 2026-10-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rb_sys