mbt-gen 0.0.14.2 → 0.0.14.4

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/mbt-gen.rb +46 -23
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3176e95c2bc110640523d69ff0c4cfea0f8e9bb88b4548589c63538c880d6780
4
- data.tar.gz: bc0ebcde2d51db9ab014af418f7d802fc0cba82b94a4bc8b4d416210f793fd43
3
+ metadata.gz: 4caff5f0cdde9dd37c43c82f2476248c4ac09f35588653cb81d664eafb1d49bd
4
+ data.tar.gz: 3bf76fa6792a1c46ed8042c4264421c4f3156c190399c329928fbcd1fc436369
5
5
  SHA512:
6
- metadata.gz: 27b59f856e37fcb50ceee1cf3c75868c15ca337325ce4900a078aa26bc06dac2376f0a683575bb86b5da21f6c57a2dbb59652c8967f664ea0d78a1bf215d69cc
7
- data.tar.gz: 074aadce686f0d9af3fd6b6bf281e821dc3d8634f53d5ddba1545919453612440beb31e054f725c3562ce3cd46c70ed13e589aeb54d6bda64a6107f243f5c6a3
6
+ metadata.gz: a3aa357233ece8bea791ee379592f0c2e47f410192c1d6ddd1ba4986986e1cda38842438b215bd16ccf67431e82a061a3751160818e1e6bfda7b17b19c560bf5
7
+ data.tar.gz: d104b7b264994a0f4d205d58d7ad156c51807ca612a73ce4114e682a62443a989435dc67afaa7ff397de1edba83b6d44d53946df7a050d252965eea35a097abd
data/lib/mbt-gen.rb CHANGED
@@ -382,7 +382,7 @@ def translate_substructure_to_SMTLIB(progress, solver, struct, hash = {})
382
382
  if field == :additional_smtlib then
383
383
  solver.to_solver(progress, "; additional SMTLIB of structure #{prefix}")
384
384
  solver.to_solver(progress, translate_validation_rule_to_SMTLIB(definition, struct, prefix, config, options, "<additional SMTLIB of structure #{prefix}>"))
385
- elsif field == :validation_rules || field == :predicates || field == :parent_link || field == :struct_xpath_prefix
385
+ elsif field == :validation_rules || field == :predicates || field == :parent_links || field == :struct_xpath_prefix
386
386
  next
387
387
  else
388
388
  solver.to_solver(progress, "; #{field.to_s}")
@@ -539,15 +539,25 @@ def resolve_struct_path(path, relative_to_struct, prefix)
539
539
  raise RuntimeError.new("could not resolve field path: #{path.inspect} relative to struct #{relative_to_struct.inspect}")
540
540
  end
541
541
  if segment == "." then
542
- result = current[:struct_xpath_prefix]
542
+ result = prefix
543
543
  elsif segment == ".." then
544
- current = current[:parent_link]
545
544
  if prefix then
546
- prefix_segs = prefix.split("/")
547
- prefix = prefix_segs[0,prefix_segs.size()-1].join("/")
545
+ next_current = current[:parent_links].find{ |link| prefix.start_with?(link[:struct_xpath_prefix]) }
546
+ if next_current then
547
+ current = next_current
548
+ prefix = current[:struct_xpath_prefix]
549
+ else
550
+ raise RuntimeError.new("failure to resolve segment '..' of path #{path.inspect}: none of the parent-links (#{current[:parent_links].map{|p| p[:struct_xpath_prefix]}.join(', ')}) of struct #{current[:struct_xpath_prefix]} matched the prefix #{prefix.inspect}")
551
+ end
548
552
  else
549
- prefix = current[:struct_xpath_prefix]
553
+ if current[:parent_links].size > 1 then
554
+ raise RuntimeError.new("could not resolve segment '..' in path #{path.inspect} as it is ambiguous: structure #{current[:struct_xpath_prefix]} has multiple parent-links (#{current[:parent_links].map{|p| p[:struct_xpath_prefix]}.join(', ')})")
555
+ else
556
+ current = current[:parent_links].first
557
+ prefix = current[:struct_xpath_prefix]
558
+ end
550
559
  end
560
+ result = prefix
551
561
  else
552
562
  field_def = current[segment.to_sym]
553
563
  unless field_def then
@@ -577,7 +587,17 @@ def resolve_struct_def(path, relative_to_struct, prefix, context_desc = "")
577
587
  if segment == "." then
578
588
  result = current
579
589
  elsif segment == ".." then
580
- current = current[:parent_link]
590
+ if prefix then
591
+ current = current[:parent_links].find{|link| prefix.start_with?(link[:struct_xpath_prefix]) }
592
+ prefix = current[:struct_xpath_prefix]
593
+ else
594
+ if current[:parent_links].size > 1 then
595
+ raise RuntimeError.new("could not resolve segment '..' in path #{path.inspect} as it is ambiguous: structure #{current[:struct_xpath_prefix]} has multiple parent-links (#{current[:parent_links].map{|p| p[:struct_xpath_prefix]}.join(', ')})")
596
+ else
597
+ current = current[:parent_links].first
598
+ prefix = current[:struct_xpath_prefix]
599
+ end
600
+ end
581
601
  if prefix then
582
602
  prefix_segs = prefix.split("/")
583
603
  prefix = prefix_segs[0,prefix_segs.size()-1].join("/")
@@ -606,8 +626,8 @@ end
606
626
  def translate_validation_rules_to_SMTLIB(progress, solver, struct, prefix, config, options)
607
627
  solver.to_solver(progress, "; --- Validation Rules ---")
608
628
  translate_validation_rules_for_structure_to_SMTLIB(progress, solver, struct, prefix, config, options)
609
- struct.each_pair do |key, value|
610
- next if key == :validation_rules || key == :predicates || key == :parent_link || key == :struct_xpath_prefix || key == :additional_smtlib
629
+ struct.each_pair do |key, value|
630
+ next if key == :validation_rules || key == :predicates || key == :parent_links || key == :struct_xpath_prefix || key == :additional_smtlib
611
631
  if value[:type] == :structure then
612
632
  if prefix then
613
633
  new_prefix = "#{prefix.to_s}/#{key}"
@@ -818,7 +838,6 @@ def parse_field_value(fielddef, value)
818
838
  when :enum
819
839
  return solver_value_to_string(value)
820
840
  when :date
821
- puts "DEBUG: parsing date #{value.inspect}"
822
841
  return Date.parse(value)
823
842
  when :timestamp
824
843
  return Time.new(value)
@@ -885,7 +904,7 @@ end
885
904
 
886
905
  def add_max_struct_to_doc(progress, struct, doc, prefix = nil)
887
906
  struct.each do |key, value|
888
- next if key == :validation_rules || key == :predicates || key == :parent_link || key == :struct_xpath_prefix || key == :additional_smtlib
907
+ next if key == :validation_rules || key == :predicates || key == :parent_links || key == :struct_xpath_prefix || key == :additional_smtlib
889
908
  if prefix then
890
909
  xpath = "#{prefix}/#{key}"
891
910
  else
@@ -953,7 +972,7 @@ end
953
972
 
954
973
  def add_model_struct_to_doc(progress, struct, doc, model, prefix = nil)
955
974
  struct.each do |key, value|
956
- next if key == :validation_rules || key == :predicates || key == :parent_link || key == :struct_xpath_prefix || key == :additional_smtlib
975
+ next if key == :validation_rules || key == :predicates || key == :parent_links || key == :struct_xpath_prefix || key == :additional_smtlib
957
976
  if prefix then
958
977
  xpath = "#{prefix}/#{key}"
959
978
  else
@@ -1016,7 +1035,7 @@ end
1016
1035
  def collect_validation_rule_names(struct)
1017
1036
  result = []
1018
1037
  struct.each do |key, value|
1019
- next if key == :predicates || key == :parent_link || key == :struct_xpath_prefix || key == :additional_smtlib
1038
+ next if key == :predicates || key == :parent_links || key == :struct_xpath_prefix || key == :additional_smtlib
1020
1039
  if key == :validation_rules
1021
1040
  value.each do |key, value|
1022
1041
  result << key
@@ -1038,7 +1057,7 @@ end
1038
1057
 
1039
1058
  def each_structure_and_field_in(struct, prefix = nil, &block)
1040
1059
  struct.each do |key, value|
1041
- next if key == :validation_rules || key == :predicates || key == :parent_link || key == :struct_xpath_prefix || key == :additional_smtlib
1060
+ next if key == :validation_rules || key == :predicates || key == :parent_links || key == :struct_xpath_prefix || key == :additional_smtlib
1042
1061
 
1043
1062
  if prefix then
1044
1063
  xpath = "#{prefix}/#{key}"
@@ -1519,7 +1538,7 @@ end
1519
1538
  def collect_key_fields(fkey, struct, prefix = nil)
1520
1539
  result = {}
1521
1540
  struct.each do |key, value|
1522
- next if key == :validation_rules || key == :predicates || key == :parent_link || key == :struct_xpath_prefix || key == :additional_smtlib
1541
+ next if key == :validation_rules || key == :predicates || key == :parent_links || key == :struct_xpath_prefix || key == :additional_smtlib
1523
1542
  if value[:type] == :structure
1524
1543
  if value.has_key?(:keys) and value[:keys].include?(fkey) then
1525
1544
  xpath = key.to_s
@@ -1545,7 +1564,7 @@ def collect_key_fields_and_strctures(fkey, struct, prefix = nil)
1545
1564
  fields = []
1546
1565
  structures = []
1547
1566
  struct.each do |key, value|
1548
- next if key == :validation_rules || key == :predicates || key == :parent_link || key == :struct_xpath_prefix || key == :additional_smtlib
1567
+ next if key == :validation_rules || key == :predicates || key == :parent_links || key == :struct_xpath_prefix || key == :additional_smtlib
1549
1568
  if value[:type] == :structure
1550
1569
  if value.has_key?(:keys) and value[:keys].include?(fkey) then
1551
1570
  xpath = key.to_s
@@ -1572,7 +1591,7 @@ end
1572
1591
  def collect_keys(struct)
1573
1592
  result = []
1574
1593
  struct.each do |key, value|
1575
- next if key == :validation_rules || key == :predicates || key == :parent_link || key == :struct_xpath_prefix || key == :additional_smtlib
1594
+ next if key == :validation_rules || key == :predicates || key == :parent_links || key == :struct_xpath_prefix || key == :additional_smtlib
1576
1595
  if value[:type] == :structure
1577
1596
  if value.has_key?(:keys) then
1578
1597
  result += value[:keys]
@@ -1592,7 +1611,7 @@ end
1592
1611
  def collect_validation_rules(struct)
1593
1612
  result = []
1594
1613
  struct.each do |key, value|
1595
- next if key == :predicates || key == :parent_link || key == :struct_xpath_prefix || key == :additional_smtlib
1614
+ next if key == :predicates || key == :parent_links || key == :struct_xpath_prefix || key == :additional_smtlib
1596
1615
  if key == :validation_rules then
1597
1616
  result += value.keys
1598
1617
  else
@@ -2141,13 +2160,17 @@ end
2141
2160
 
2142
2161
  def introduce_parent_links(message, parent = nil, prefix = nil)
2143
2162
  if parent != nil then
2144
- message[:parent_link] = parent
2163
+ if message.has_key?(:parent_links) then
2164
+ message[:parent_links] << parent
2165
+ else
2166
+ message[:parent_links] = [parent]
2167
+ end
2145
2168
  end
2146
2169
  if prefix != nil then
2147
2170
  message[:struct_xpath_prefix] = prefix
2148
2171
  end
2149
2172
  message.each_pair do |key, value|
2150
- next if key == :validation_rules || key == :predicates || key == :parent_link || key == :struct_xpath_prefix || key == :additional_smtlib
2173
+ next if key == :validation_rules || key == :predicates || key == :parent_links || key == :struct_xpath_prefix || key == :additional_smtlib
2151
2174
  if value[:type] == :structure then
2152
2175
  if prefix then
2153
2176
  new_prefix = "#{prefix}/#{key}"
@@ -2181,7 +2204,7 @@ def validate_model(message, prefix=nil)
2181
2204
  puts "WARN: Model Problem: structure #{prefix}'s predicate #{mkey} does not have an SMTLIB representation. It will be regarded as always true."
2182
2205
  end
2183
2206
  end
2184
- elsif key == :parent_link || key == :struct_xpath_prefix || key == :additional_smtlib
2207
+ elsif key == :parent_links || key == :struct_xpath_prefix || key == :additional_smtlib
2185
2208
  next
2186
2209
  else
2187
2210
  if value[:type] == :structure then
@@ -2294,7 +2317,7 @@ end
2294
2317
 
2295
2318
  def validate_schema_against_doc_struct(struct, doc, prefix = nil)
2296
2319
  struct.each do |key, value|
2297
- next if key == :additional_smtlib || key == :validation_rules || key == :predicates || key == :parent_link || key == :struct_xpath_prefix
2320
+ next if key == :additional_smtlib || key == :validation_rules || key == :predicates || key == :parent_links || key == :struct_xpath_prefix
2298
2321
  if prefix then
2299
2322
  xpath = "#{prefix}/#{key}"
2300
2323
  else
@@ -2369,7 +2392,7 @@ def translate_struct_in_doc_to_SMTLIB(progress, solver, struct, doc, prefix, var
2369
2392
  config = hash[:config]
2370
2393
 
2371
2394
  struct.each do |key, value|
2372
- next if key == :additional_smtlib || key == :validation_rules || key == :predicates || key == :parent_link || key == :struct_xpath_prefix
2395
+ next if key == :additional_smtlib || key == :validation_rules || key == :predicates || key == :parent_links || key == :struct_xpath_prefix
2373
2396
  if prefix then
2374
2397
  xpath = "#{prefix}/#{key.to_s}"
2375
2398
  else
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mbt-gen
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.14.2
4
+ version: 0.0.14.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - FM-enthusiast
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-11-05 00:00:00.000000000 Z
11
+ date: 2026-11-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri