suma 0.5.38 → 0.5.39

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: afd727de6d181c16bca36f90e25d84cce00b70b3d1ff5b30190812c5dccbc4ec
4
- data.tar.gz: b75f867c8e9f2a47cf380cb076938924aaaef297546244c6c29c1e09cf23b16b
3
+ metadata.gz: 22f28100458fea39621ee5b70b16745f37efe2eb6cac086570da5ced507a6e16
4
+ data.tar.gz: 47f7b5512cc818e306db23835c21150bccc8d92a8ee50701326eaf847a8a952d
5
5
  SHA512:
6
- metadata.gz: 07bb788123a2cd052a2ccffd4deb2b1468f0cc6dc83cd4964c4af185ded66d037fb5fd2be2486c900759c8a3ac4e850ca138fcd23ecd57e7e4c2e69165751cbf
7
- data.tar.gz: 3b0cc365321032218dd12f98752bb38d4e87569fe1487228f77d46c754e60b22a65e1066086e112943fc832a10eec7804f6f868295807e6e52e0e2b5cf4d81bb
6
+ metadata.gz: '0484557c5ce603b7826f4134897122b61bc0f0940947637767376e312abb31144965ca3e3187b6124b2750e3c7b0860a007fad3ae832339c59fc67116f2b3168'
7
+ data.tar.gz: 94d0c922d2bd70ba7d6ce67f78ec135b4bb276d5a0119f57a28acdd69e877fdf300dafa4d753075efea0a80840a29300b0fb9f362e1a058d9d68e5f293cbd6a6
@@ -11,7 +11,7 @@ module Suma
11
11
  class CheckSvgQuality
12
12
  DATA_PATH = "schemas"
13
13
  DEFAULT_PATTERN = "**/*.svg"
14
- DEFAULT_PROFILE = :metanorma
14
+ DEFAULT_PROFILE = Suma::SvgQuality::Scanner.default_profile
15
15
 
16
16
  def initialize(pattern: DEFAULT_PATTERN, profile: DEFAULT_PROFILE,
17
17
  format: "terminal", output: nil, min_errors: nil,
@@ -40,15 +40,19 @@ module Suma
40
40
  # Without an expectations manifest the contract is zero broken
41
41
  # links. With one, broken_links_max IS the broken-link contract:
42
42
  # the unconditional raise would fire first and make the cap
43
- # unreachable (TRThurman, iso-10303#835).
44
- def verify_failures(result, failures)
45
- if options[:expectations]
46
- raise "expectations violated: #{failures.join('; ')}" unless
47
- failures.empty?
48
- elsif result.broken_count.zero?
49
- nil
50
- else
51
- raise "broken links found (#{result.broken_count})"
43
+ # unreachable (TRThurman, iso-10303#835). Defined inside
44
+ # no_commands so Thor does not register a command for a helper
45
+ # and warn about the missing usage/description on every run.
46
+ no_commands do
47
+ def verify_failures(result, failures)
48
+ if options[:expectations]
49
+ raise "expectations violated: #{failures.join('; ')}" unless
50
+ failures.empty?
51
+ elsif result.broken_count.zero?
52
+ nil
53
+ else
54
+ raise "broken links found (#{result.broken_count})"
55
+ end
52
56
  end
53
57
  end
54
58
 
@@ -13,13 +13,24 @@ module Suma
13
13
  # +#call(index, total, report)+. +NullProgress+ is the default
14
14
  # no-op; the CLI passes a lambda that writes to +$stderr+.
15
15
  class Scanner
16
- DEFAULT_PROFILE = :metanorma
16
+ # The operative metanorma profile ships from metanorma-standoc by
17
+ # path: svg_conform's bundled copy is a sample only, and the
18
+ # "metanorma" engine name fails loudly by design (svg_conform#132).
19
+ STANDOC_PROFILE_PATH =
20
+ "lib/metanorma/standoc/svg_conform_profile/metanorma.yml"
21
+
22
+ def self.default_profile
23
+ File.join(
24
+ Gem::Specification.find_by_name("metanorma-standoc").gem_dir,
25
+ STANDOC_PROFILE_PATH,
26
+ )
27
+ end
17
28
 
18
29
  attr_reader :profile, :progress
19
30
 
20
- def initialize(profile: DEFAULT_PROFILE,
31
+ def initialize(profile: nil,
21
32
  progress: NullProgress.new)
22
- @profile = profile
33
+ @profile = profile || self.class.default_profile
23
34
  @progress = progress
24
35
  end
25
36
 
@@ -288,7 +288,7 @@ module Suma
288
288
  "#{entity_name_to_text(entity.id)} #{entity_ref}"
289
289
  else
290
290
  entity_subtypes = subtypes.map do |e|
291
- owner = declaring_schema_id(schema, e.id) || schema.id
291
+ owner = declaring_owner(schema, e.id)
292
292
  urn_mention(express_entity_urn("#{owner}.#{e.id}"), e.id)
293
293
  end
294
294
 
@@ -299,6 +299,13 @@ module Suma
299
299
  end
300
300
  end
301
301
 
302
+ # The owner a supertype citation qualifies with: the closure declarer,
303
+ # else the sibling-schema declarer, else the citing schema.
304
+ def declaring_owner(schema, entity_id)
305
+ declaring_schema_id(schema, entity_id) ||
306
+ sibling_declaring_schema_id(entity_id) || schema.id
307
+ end
308
+
302
309
  # The schema an imported declaration is declared in, resolved through
303
310
  # +schema+'s USE-FROM closure — the same resolution the source remark
304
311
  # xrefs carry: a local declaration wins; otherwise the USE FROM edges
@@ -321,6 +328,39 @@ module Suma
321
328
  end
322
329
  end
323
330
 
331
+ # When the closure walk finds no declarer, the declaration may sit
332
+ # in a sibling schema with no interface edge to the citing one: the
333
+ # _arm/_mim pairs cite across without USE FROM/REFERENCE FROM, so
334
+ # `X_arm.Y` lands on a concept declared under `X_mim` (TRThurman's
335
+ # 148 distinct wrong-qualifier targets, iso-10303#835 /
336
+ # metanorma/suma#197). Scan the manifest's schemas for the entity
337
+ # name; exactly one declarer resolves, several stay nil.
338
+ def sibling_declaring_schema_id(entity_id)
339
+ @sibling_cache ||= {}
340
+ @sibling_cache.fetch(entity_id) do
341
+ declarers = declarers_in_manifest(entity_id)
342
+ unique_declarer(declarers)
343
+ end
344
+ end
345
+
346
+ # The manifest schemas whose entity collection declares +entity_id+.
347
+ def declarers_in_manifest(entity_id)
348
+ schema_manifest_paths.keys.filter_map do |id|
349
+ loaded = loaded_schema(id)
350
+ declares_entity?(loaded, entity_id) ? id : nil
351
+ end
352
+ end
353
+
354
+ def declares_entity?(schema, entity_id)
355
+ schema&.entities&.any? { |e| e.id == entity_id } ? true : false
356
+ end
357
+
358
+ # The single distinct declarer, or nil when none or several — an
359
+ # ambiguous name never resolves to a guess.
360
+ def unique_declarer(declarers)
361
+ declarers.uniq.one? ? declarers.first : nil
362
+ end
363
+
324
364
  # Distinct schema ids within +schema+'s USE-FROM closure declaring
325
365
  # +entity_id+. An interface whose item list names the declaration
326
366
  # claims it outright (that is what the item list means in EXPRESS) —
data/lib/suma/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Suma
4
- VERSION = "0.5.38"
4
+ VERSION = "0.5.39"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: suma
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.38
4
+ version: 0.5.39
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-11-13 00:00:00.000000000 Z
11
+ date: 2026-11-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: base64