suma 0.2.6 → 0.4.0

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 (57) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +7 -1
  3. data/.rubocop_todo.yml +170 -13
  4. data/CLAUDE.md +37 -11
  5. data/Gemfile +3 -3
  6. data/README.adoc +127 -13
  7. data/exe/suma +1 -1
  8. data/lib/suma/cli/build.rb +0 -5
  9. data/lib/suma/cli/check_svg_quality.rb +82 -97
  10. data/lib/suma/cli/compare.rb +0 -1
  11. data/lib/suma/cli/convert_jsdai.rb +0 -2
  12. data/lib/suma/cli/core.rb +119 -0
  13. data/lib/suma/cli/export.rb +37 -22
  14. data/lib/suma/cli/extract_terms.rb +5 -8
  15. data/lib/suma/cli/generate_register.rb +34 -0
  16. data/lib/suma/cli/generate_schemas.rb +0 -2
  17. data/lib/suma/cli/reformat.rb +39 -64
  18. data/lib/suma/cli/validate.rb +14 -7
  19. data/lib/suma/cli/validate_links.rb +11 -157
  20. data/lib/suma/cli.rb +12 -141
  21. data/lib/suma/collection_config.rb +0 -2
  22. data/lib/suma/collection_manifest.rb +7 -110
  23. data/lib/suma/eengine/wrapper.rb +0 -1
  24. data/lib/suma/eengine.rb +8 -0
  25. data/lib/suma/express_reformatter.rb +94 -0
  26. data/lib/suma/express_schema.rb +0 -1
  27. data/lib/suma/jsdai/figure.rb +0 -3
  28. data/lib/suma/jsdai.rb +5 -2
  29. data/lib/suma/link_validation.rb +144 -0
  30. data/lib/suma/link_validator.rb +17 -8
  31. data/lib/suma/manifest_traverser.rb +92 -0
  32. data/lib/suma/processor.rb +5 -8
  33. data/lib/suma/register_manifest_generator.rb +163 -0
  34. data/lib/suma/schema_category.rb +83 -0
  35. data/lib/suma/schema_collection.rb +30 -34
  36. data/lib/suma/schema_comparer.rb +4 -3
  37. data/lib/suma/schema_compiler.rb +86 -0
  38. data/lib/suma/schema_discovery.rb +75 -0
  39. data/lib/suma/schema_exporter.rb +14 -42
  40. data/lib/suma/schema_manifest_generator.rb +14 -6
  41. data/lib/suma/schema_naming.rb +111 -0
  42. data/lib/suma/schema_template/document.rb +141 -0
  43. data/lib/suma/schema_template/plain.rb +46 -0
  44. data/lib/suma/schema_template.rb +19 -0
  45. data/lib/suma/svg_quality/batch_report.rb +0 -2
  46. data/lib/suma/svg_quality/formatters.rb +12 -0
  47. data/lib/suma/svg_quality/scanner.rb +61 -0
  48. data/lib/suma/svg_quality.rb +4 -1
  49. data/lib/suma/term_classification.rb +78 -0
  50. data/lib/suma/term_extractor.rb +125 -81
  51. data/lib/suma/urn.rb +61 -0
  52. data/lib/suma/version.rb +1 -1
  53. data/lib/suma.rb +35 -3
  54. data/suma.gemspec +1 -1
  55. metadata +28 -6
  56. data/lib/suma/schema_attachment.rb +0 -103
  57. data/lib/suma/schema_document.rb +0 -118
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "fileutils"
4
- require_relative "utils"
5
4
  require "expressir"
6
5
  require "glossarist"
7
6
 
@@ -16,13 +15,16 @@ module Suma
16
15
  \s*?\.?$ # Optional whitespace and period at the end
17
16
  }x
18
17
 
19
- def initialize(schema_manifest_file, output_path, language_code: "eng")
18
+ def initialize(schema_manifest_file, output_path, urn:,
19
+ language_code: "eng")
20
20
  @schema_manifest_file = File.expand_path(schema_manifest_file)
21
21
  @output_path = output_path
22
22
  @language_code = language_code
23
+ @urn = Suma::Urn.new(urn)
23
24
  end
24
25
 
25
26
  def call
27
+ validate_inputs
26
28
  get_exp_files.map do |exp_file|
27
29
  extract(exp_file)
28
30
  end
@@ -30,12 +32,24 @@ module Suma
30
32
 
31
33
  private
32
34
 
35
+ def validate_inputs
36
+ unless File.exist?(@schema_manifest_file)
37
+ raise Errno::ENOENT, "Specified SCHEMA_MANIFEST_FILE " \
38
+ "`#{@schema_manifest_file}` not found."
39
+ end
40
+ unless File.file?(@schema_manifest_file)
41
+ raise Errno::ENOENT, "Specified SCHEMA_MANIFEST_FILE " \
42
+ "`#{@schema_manifest_file}` is not a file."
43
+ end
44
+ end
45
+
33
46
  def get_exp_files
34
47
  config = Expressir::SchemaManifest.from_file(@schema_manifest_file)
35
48
  paths = config.schemas.map(&:path)
36
49
 
37
50
  if paths.empty?
38
- raise Errno::ENOENT, "No EXPRESS files found in `#{@schema_manifest_file}`."
51
+ raise Errno::ENOENT,
52
+ "No EXPRESS files found in `#{@schema_manifest_file}`."
39
53
  end
40
54
 
41
55
  paths
@@ -50,39 +64,64 @@ module Suma
50
64
 
51
65
  raise Error, "Schema must have an associated file" unless schema.file
52
66
 
53
- collection = build_managed_concept_collection(schema)
67
+ classification = TermClassification.for_schema(id: schema.id,
68
+ path: schema.file)
69
+ collection = build_managed_concept_collection(schema, classification)
54
70
  output_data(collection)
55
71
  collection
56
72
  end
57
73
 
58
74
  def output_data(collection)
59
- FileUtils.mkdir_p(File.expand_path(@output_path)) unless File.exist?(@output_path)
75
+ output_dir = File.expand_path(@output_path)
76
+ FileUtils.mkdir_p(output_dir)
60
77
  Utils.log "Saving collection to files in: #{@output_path}"
61
- collection.save_to_files(File.expand_path(@output_path))
78
+
79
+ collection.each do |concept|
80
+ doc = Glossarist::V3::ConceptDocument.from_managed_concept(concept)
81
+ doc.localizations = concept.data.localizations.keys.map do |lang|
82
+ concept.localization(lang)
83
+ end
84
+
85
+ filename = "#{concept.uuid.gsub(/[^\w.-]/, '_')}.yaml"
86
+ File.write(File.join(output_dir, filename), doc.to_yamls,
87
+ encoding: "utf-8")
88
+ end
62
89
  end
63
90
 
64
- def build_managed_concept_collection(schema)
91
+ def build_managed_concept_collection(schema, classification)
65
92
  source_ref = get_source_ref(schema)
93
+ section_ref = get_section_ref(schema)
66
94
 
67
95
  Glossarist::ManagedConceptCollection.new.tap do |collection|
68
96
  schema.entities.each do |entity|
97
+ localized_concept_id = Glossarist::Utilities::UUID.uuid_v5(
98
+ Glossarist::Utilities::UUID::OID_NAMESPACE,
99
+ "#{schema.id}.#{entity.id}-#{@language_code}",
100
+ )
101
+
69
102
  localized_concept = build_localized_concept(
70
103
  schema: schema,
71
104
  entity: entity,
72
105
  source_ref: source_ref,
106
+ uuid: localized_concept_id,
107
+ classification: classification,
73
108
  )
74
- localized_concept_id = get_localized_concept_identifier(schema, entity)
75
109
 
76
- managed_data = Glossarist::ManagedConceptData.new.tap do |data|
77
- data.id = get_entity_identifier(schema, entity)
78
- data.localizations[@language_code] = localized_concept
110
+ managed_data = Glossarist::V3::ManagedConceptData.new.tap do |data|
111
+ data.id = "#{schema.id}.#{entity.id}"
112
+ data.localizations.store(@language_code, localized_concept)
79
113
  data.localized_concepts = { @language_code => localized_concept_id }
114
+ data.domains = [section_ref] if section_ref
80
115
  end
81
116
 
82
- managed_concept = Glossarist::ManagedConcept.new.tap do |concept|
83
- concept.id = get_entity_identifier(schema, entity)
84
- concept.uuid = concept.id
117
+ managed_concept = Glossarist::V3::ManagedConcept.new.tap do |concept|
118
+ concept.id = managed_data.id
119
+ concept.uuid = Glossarist::Utilities::UUID.uuid_v5(
120
+ Glossarist::Utilities::UUID::OID_NAMESPACE,
121
+ managed_data.id,
122
+ )
85
123
  concept.data = managed_data
124
+ concept.schema_version = "v3"
86
125
  end
87
126
 
88
127
  collection.store(managed_concept)
@@ -90,12 +129,13 @@ module Suma
90
129
  end
91
130
  end
92
131
 
93
- def build_localized_concept(schema:, entity:, source_ref:)
94
- schema_domain = get_domain(schema)
132
+ def build_localized_concept(schema:, entity:, source_ref:, uuid:,
133
+ classification:)
134
+ schema_domain = classification.domain_for(schema.id)
95
135
 
96
- localized_concept_data = Glossarist::ConceptData.new.tap do |data|
136
+ localized_concept_data = Glossarist::V3::ConceptData.new.tap do |data|
97
137
  data.terms = get_entity_terms(entity)
98
- data.definition = get_entity_definitions(entity, schema)
138
+ data.definition = get_entity_definitions(entity, schema, classification)
99
139
  data.language_code = @language_code
100
140
  data.domain = schema_domain
101
141
  data.sources = [source_ref] if source_ref
@@ -105,49 +145,65 @@ module Suma
105
145
  data.examples = []
106
146
  end
107
147
 
108
- Glossarist::LocalizedConcept.new.tap { |c| c.data = localized_concept_data }
148
+ Glossarist::V3::LocalizedConcept.new(
149
+ data: localized_concept_data, uuid: uuid,
150
+ )
151
+ end
152
+
153
+ def schema_urn(schema)
154
+ @urn.for_schema(schema.id)
155
+ end
156
+
157
+ def term_urn(concept_identifier)
158
+ @urn.for_term(concept_identifier)
109
159
  end
110
160
 
111
- def get_entity_identifier(schema, entity)
112
- "#{schema.id}.#{entity.id}"
161
+ def express_entity_urn(full_ref)
162
+ @urn.for_entity(full_ref)
113
163
  end
114
164
 
115
- def get_localized_concept_identifier(schema, entity)
116
- "#{schema.id}.#{entity.id}-#{@language_code}"
165
+ def urn_mention(urn, display)
166
+ "{{#{urn},#{display}}}"
167
+ end
168
+
169
+ def get_section_ref(schema)
170
+ return nil unless @urn
171
+
172
+ Glossarist::ConceptReference.new(
173
+ concept_id: "section-#{schema.id}",
174
+ source: schema_urn(schema),
175
+ ref_type: "section",
176
+ )
117
177
  end
118
178
 
119
179
  def get_source_ref(schema)
120
- origin = Glossarist::Citation.new.tap do |citation|
121
- citation.ref = "ISO 10303"
122
- custom_locality = build_custom_locality(schema)
123
- citation.custom_locality = custom_locality unless custom_locality.empty?
180
+ ref = Glossarist::Citation::Ref.new
181
+ ref.source = schema_urn(schema)
182
+
183
+ build_custom_locality(schema).each do |cl|
184
+ case cl.name
185
+ when "version" then ref.version = cl.value
186
+ end
124
187
  end
125
188
 
126
- Glossarist::ConceptSource.new(type: "authoritative", origin: origin)
189
+ origin = Glossarist::V3::Citation.new
190
+ origin.ref = ref
191
+ Glossarist::V3::ConceptSource.new(id: schema.id, type: "authoritative",
192
+ origin: origin)
127
193
  end
128
194
 
129
195
  def build_custom_locality(schema)
130
196
  localities = []
131
- localities << Glossarist::CustomLocality.new(name: "schema", value: schema.id)
132
197
 
133
198
  version_item = schema.version.items.detect { |i| i.name == "version" }
134
199
  if version_item
135
- localities << Glossarist::CustomLocality.new(name: "version", value: version_item.value)
200
+ localities << Glossarist::CustomLocality.new(name: "version",
201
+ value: version_item.value)
136
202
  end
137
203
 
138
204
  localities
139
205
  end
140
206
 
141
- def get_domain(schema)
142
- prefix = if schema.id.end_with?("_arm", "_mim")
143
- "application module"
144
- else
145
- "resource"
146
- end
147
-
148
- "#{prefix}: #{schema.id}"
149
- end
150
-
151
207
  def get_entity_terms(entity)
152
208
  [
153
209
  Glossarist::Designation::Base.new(
@@ -158,12 +214,9 @@ module Suma
158
214
  ]
159
215
  end
160
216
 
161
- def get_entity_definitions(entity, schema)
162
- schema_type = extract_file_type(schema.file)
163
- schema_domain = get_domain(schema)
164
-
165
- definition = generate_entity_definition(entity, schema_domain, schema_type)
166
- [Glossarist::DetailedDefinition.new(content: definition)]
217
+ def get_entity_definitions(entity, schema, classification)
218
+ definition = generate_entity_definition(entity, schema, classification)
219
+ [Glossarist::V3::DetailedDefinition.new(content: definition)]
167
220
  end
168
221
 
169
222
  def get_entity_notes(entity, schema_domain, definitions)
@@ -172,7 +225,7 @@ module Suma
172
225
  if entity.remarks && !entity.remarks.empty?
173
226
  trimmed_def = trim_definition(entity.remarks)
174
227
  if trimmed_def && !trimmed_def.empty?
175
- notes << Glossarist::DetailedDefinition.new(
228
+ notes << Glossarist::V3::DetailedDefinition.new(
176
229
  content: convert_express_xref(trimmed_def, schema_domain),
177
230
  )
178
231
  end
@@ -246,17 +299,6 @@ module Suma
246
299
  end
247
300
  end
248
301
 
249
- def extract_file_type(filename)
250
- match = filename.match(/(arm|mim|bom)_annotated\.exp$/)
251
- return "resource" unless match
252
-
253
- {
254
- "arm" => "module_arm",
255
- "mim" => "module_mim",
256
- "bom" => "business_object_model",
257
- }[match.captures[0]] || "resource"
258
- end
259
-
260
302
  def starts_with_list?(content)
261
303
  return false if content.nil? || content.empty?
262
304
 
@@ -343,11 +385,14 @@ module Suma
343
385
 
344
386
  def express_reference_to_mention(description)
345
387
  description
346
- .gsub(/<<express:([^,]+)>>/) do |_match|
347
- "{{#{Regexp.last_match[1].split('.').last}}}"
348
- end.gsub(/<<express:([^,]+),([^>]+)>>/) do |_match|
349
- "{{#{Regexp.last_match[1].split('.').last}," \
350
- "#{Regexp.last_match[2]}}}"
388
+ .gsub(/<<express:([\w.]+)>>/) do |_match|
389
+ full_ref = Regexp.last_match[1]
390
+ entity_id = full_ref.split(".").last
391
+ urn_mention(express_entity_urn(full_ref), entity_id)
392
+ end.gsub(/<<express:([\w.]+),([\w. ][\w. ]*)>>/) do |_match|
393
+ full_ref = Regexp.last_match[1]
394
+ display = Regexp.last_match(2)
395
+ urn_mention(express_entity_urn(full_ref), display)
351
396
  end
352
397
  end
353
398
 
@@ -355,38 +400,37 @@ module Suma
355
400
  entity_id.downcase.gsub("_", " ")
356
401
  end
357
402
 
358
- def generate_entity_definition(entity, _domain, schema_type)
403
+ def generate_entity_definition(entity, schema, classification)
359
404
  return "" if entity.nil?
360
405
 
361
- entity_type = case schema_type
362
- when "module_arm"
363
- "{{application object}}"
364
- when "module_mim"
365
- "{{entity data type}}"
366
- when "resource", "business_object_model"
367
- "{{entity data type}}"
368
- else
369
- raise Error, "[suma] encountered unsupported schema_type"
370
- end
406
+ entity_type = urn_mention(
407
+ term_urn(classification.entity_term),
408
+ classification.entity_display,
409
+ )
410
+
411
+ entity_ref = urn_mention(term_urn("express-language.entity"), "entity")
371
412
 
372
413
  if entity.subtype_of.empty?
373
414
  "#{entity_type} " \
374
415
  "that represents the " \
375
- "#{entity_name_to_text(entity.id)} {{entity}}"
416
+ "#{entity_name_to_text(entity.id)} #{entity_ref}"
376
417
  else
377
- entity_subtypes = entity.subtype_of.map { |e| "{{#{e.id}}}" }
418
+ entity_subtypes = entity.subtype_of.map do |e|
419
+ urn_mention(express_entity_urn("#{schema.id}.#{e.id}"), e.id)
420
+ end
378
421
 
379
422
  "#{entity_type} that is a type of " \
380
423
  "#{entity_subtypes.join(' and ')} " \
381
424
  "that represents the " \
382
- "#{entity_name_to_text(entity.id)} {{entity}}"
425
+ "#{entity_name_to_text(entity.id)} #{entity_ref}"
383
426
  end
384
427
  end
385
428
 
386
- def convert_express_xref(content, schema_domain)
387
- content.gsub(/<<express:(.*),(.*)>>/) do
388
- "{{<#{schema_domain}>" \
389
- "#{Regexp.last_match(1).split('.').last},#{Regexp.last_match(2)}}}"
429
+ def convert_express_xref(content, _schema_domain)
430
+ content.gsub(/<<express:([\w.]+),([\w. ][\w. ]*)>>/) do
431
+ full_ref = Regexp.last_match(1)
432
+ display = Regexp.last_match(2)
433
+ urn_mention(express_entity_urn(full_ref), display)
390
434
  end
391
435
  end
392
436
  end
data/lib/suma/urn.rb ADDED
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Suma
4
+ # Value object encapsulating URN semantics for ISO 10303 datasets.
5
+ #
6
+ # Normalises a URN prefix (stripping any trailing wildcard `:*`) and
7
+ # provides factory methods for composing leaf URNs:
8
+ #
9
+ # - `#for_schema(id)` → `<base>:tech:<id>`
10
+ # - `#for_term(id)` → `<base>:term:<id>`
11
+ # - `#for_entity(ref)` → `<base>:tech:<ref>`
12
+ #
13
+ # The wildcard form is preserved via `#wildcard` and `#aliases` so callers
14
+ # can populate `urnAliases` in register.yaml without re-implementing the
15
+ # normalisation logic.
16
+ class Urn
17
+ WILDCARD_SUFFIX = ":*"
18
+ TECH_COMPONENT = "tech"
19
+ TERM_COMPONENT = "term"
20
+
21
+ attr_reader :base
22
+
23
+ def initialize(raw)
24
+ @base = strip_wildcard(raw.to_s)
25
+ end
26
+
27
+ def to_s
28
+ base
29
+ end
30
+
31
+ def wildcard
32
+ "#{base}#{WILDCARD_SUFFIX}"
33
+ end
34
+
35
+ def aliases
36
+ [wildcard]
37
+ end
38
+
39
+ def for_schema(schema_id)
40
+ compose(TECH_COMPONENT, schema_id)
41
+ end
42
+
43
+ def for_term(concept_identifier)
44
+ compose(TERM_COMPONENT, concept_identifier)
45
+ end
46
+
47
+ def for_entity(full_ref)
48
+ compose(TECH_COMPONENT, full_ref)
49
+ end
50
+
51
+ private
52
+
53
+ def strip_wildcard(value)
54
+ value.sub(/#{Regexp.escape(WILDCARD_SUFFIX)}\z/o, "")
55
+ end
56
+
57
+ def compose(component, identifier)
58
+ "#{base}:#{component}:#{identifier}"
59
+ end
60
+ end
61
+ end
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.2.6"
4
+ VERSION = "0.4.0"
5
5
  end
data/lib/suma.rb CHANGED
@@ -2,11 +2,43 @@
2
2
 
3
3
  require "expressir"
4
4
  require "lutaml/model"
5
-
6
- require_relative "suma/version"
7
- require_relative "suma/processor"
5
+ require "fileutils"
8
6
 
9
7
  module Suma
8
+ autoload :VERSION, "suma/version"
9
+
10
+ autoload :Processor, "suma/processor"
11
+ autoload :CollectionConfig, "suma/collection_config"
12
+ autoload :CollectionManifest, "suma/collection_manifest"
13
+ autoload :EengineConverter, "suma/eengine_converter"
14
+ autoload :ExpressReformatter, "suma/express_reformatter"
15
+ autoload :ExpressSchema, "suma/express_schema"
16
+ autoload :LinkValidation, "suma/link_validation"
17
+ autoload :LinkValidator, "suma/link_validator"
18
+ autoload :ManifestTraverser, "suma/manifest_traverser"
19
+ autoload :RegisterManifestGenerator, "suma/register_manifest_generator"
20
+ autoload :SchemaCategory, "suma/schema_category"
21
+ autoload :SchemaCollection, "suma/schema_collection"
22
+ autoload :SchemaComparer, "suma/schema_comparer"
23
+ autoload :SchemaCompiler, "suma/schema_compiler"
24
+ autoload :SchemaDiscovery, "suma/schema_discovery"
25
+ autoload :SchemaExporter, "suma/schema_exporter"
26
+ autoload :SchemaIndex, "suma/schema_index"
27
+ autoload :SchemaManifestGenerator, "suma/schema_manifest_generator"
28
+ autoload :SchemaNaming, "suma/schema_naming"
29
+ autoload :SchemaTemplate, "suma/schema_template"
30
+ autoload :SiteConfig, "suma/site_config"
31
+ autoload :SvgQuality, "suma/svg_quality"
32
+ autoload :TermClassification, "suma/term_classification"
33
+ autoload :TermExtractor, "suma/term_extractor"
34
+ autoload :ThorExt, "suma/thor_ext"
35
+ autoload :Urn, "suma/urn"
36
+ autoload :Utils, "suma/utils"
37
+
38
+ autoload :Cli, "suma/cli"
39
+ autoload :Eengine, "suma/eengine"
40
+ autoload :Jsdai, "suma/jsdai"
41
+
10
42
  class Error < StandardError; end
11
43
  class SchemaNotFoundError < Error; end
12
44
  class CompilationError < Error; end
data/suma.gemspec CHANGED
@@ -34,7 +34,7 @@ Gem::Specification.new do |spec| # rubocop:disable Metrics/BlockLength
34
34
  spec.require_paths = ["lib"]
35
35
 
36
36
  spec.add_dependency "expressir", ">= 2.1.29", "~> 2.1"
37
- spec.add_dependency "glossarist", "~> 2.4"
37
+ spec.add_dependency "glossarist", "~> 2.8", ">= 2.8.7"
38
38
  spec.add_dependency "lutaml-model", "~> 0.8.0"
39
39
  spec.add_dependency "metanorma", "~> 2.3"
40
40
  spec.add_dependency "plurimath"
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.2.6
4
+ version: 0.4.0
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-05-12 00:00:00.000000000 Z
11
+ date: 2026-07-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: expressir
@@ -36,14 +36,20 @@ dependencies:
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: '2.4'
39
+ version: '2.8'
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: 2.8.7
40
43
  type: :runtime
41
44
  prerelease: false
42
45
  version_requirements: !ruby/object:Gem::Requirement
43
46
  requirements:
44
47
  - - "~>"
45
48
  - !ruby/object:Gem::Version
46
- version: '2.4'
49
+ version: '2.8'
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: 2.8.7
47
53
  - !ruby/object:Gem::Dependency
48
54
  name: lutaml-model
49
55
  requirement: !ruby/object:Gem::Requirement
@@ -186,40 +192,56 @@ files:
186
192
  - lib/suma/cli/check_svg_quality.rb
187
193
  - lib/suma/cli/compare.rb
188
194
  - lib/suma/cli/convert_jsdai.rb
195
+ - lib/suma/cli/core.rb
189
196
  - lib/suma/cli/export.rb
190
197
  - lib/suma/cli/extract_terms.rb
198
+ - lib/suma/cli/generate_register.rb
191
199
  - lib/suma/cli/generate_schemas.rb
192
200
  - lib/suma/cli/reformat.rb
193
201
  - lib/suma/cli/validate.rb
194
202
  - lib/suma/cli/validate_links.rb
195
203
  - lib/suma/collection_config.rb
196
204
  - lib/suma/collection_manifest.rb
205
+ - lib/suma/eengine.rb
197
206
  - lib/suma/eengine/errors.rb
198
207
  - lib/suma/eengine/wrapper.rb
199
208
  - lib/suma/eengine_converter.rb
209
+ - lib/suma/express_reformatter.rb
200
210
  - lib/suma/express_schema.rb
201
211
  - lib/suma/jsdai.rb
202
212
  - lib/suma/jsdai/figure.rb
203
213
  - lib/suma/jsdai/figure_image.rb
204
214
  - lib/suma/jsdai/figure_xml.rb
215
+ - lib/suma/link_validation.rb
205
216
  - lib/suma/link_validator.rb
217
+ - lib/suma/manifest_traverser.rb
206
218
  - lib/suma/processor.rb
207
- - lib/suma/schema_attachment.rb
219
+ - lib/suma/register_manifest_generator.rb
220
+ - lib/suma/schema_category.rb
208
221
  - lib/suma/schema_collection.rb
209
222
  - lib/suma/schema_comparer.rb
210
- - lib/suma/schema_document.rb
223
+ - lib/suma/schema_compiler.rb
224
+ - lib/suma/schema_discovery.rb
211
225
  - lib/suma/schema_exporter.rb
212
226
  - lib/suma/schema_index.rb
213
227
  - lib/suma/schema_manifest_generator.rb
228
+ - lib/suma/schema_naming.rb
229
+ - lib/suma/schema_template.rb
230
+ - lib/suma/schema_template/document.rb
231
+ - lib/suma/schema_template/plain.rb
214
232
  - lib/suma/site_config.rb
215
233
  - lib/suma/svg_quality.rb
216
234
  - lib/suma/svg_quality/batch_report.rb
235
+ - lib/suma/svg_quality/formatters.rb
217
236
  - lib/suma/svg_quality/formatters/json_formatter.rb
218
237
  - lib/suma/svg_quality/formatters/terminal_formatter.rb
219
238
  - lib/suma/svg_quality/formatters/yaml_formatter.rb
220
239
  - lib/suma/svg_quality/report.rb
240
+ - lib/suma/svg_quality/scanner.rb
241
+ - lib/suma/term_classification.rb
221
242
  - lib/suma/term_extractor.rb
222
243
  - lib/suma/thor_ext.rb
244
+ - lib/suma/urn.rb
223
245
  - lib/suma/utils.rb
224
246
  - lib/suma/version.rb
225
247
  - sig/suma.rbs
@@ -1,103 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "fileutils"
4
- require "expressir"
5
-
6
- module Suma
7
- class SchemaAttachment
8
- attr_accessor :schema, :output_path, :config, :id
9
-
10
- def initialize(schema:, output_path:)
11
- @schema = schema
12
- @id = schema.id
13
- @output_path = output_path
14
- end
15
-
16
- def output_extensions
17
- "xml,html"
18
- end
19
-
20
- def to_adoc(path_to_schema_yaml)
21
- <<~HEREDOC
22
- = #{@id}
23
- :lutaml-express-index: schemas; #{path_to_schema_yaml};
24
- :bare: true
25
- :mn-document-class: iso
26
- :mn-output-extensions: #{output_extensions}
27
-
28
- [lutaml_express_liquid,schemas,context]
29
- ----
30
- {% for schema in context.schemas %}
31
-
32
- [%unnumbered]
33
- == #{@id}
34
-
35
- [source%unnumbered]
36
- --
37
- {{ schema.formatted }}
38
- --
39
- {% endfor %}
40
- ----
41
-
42
- HEREDOC
43
- end
44
-
45
- def filename_adoc(ext = "adoc")
46
- File.join(@output_path, "doc_#{@schema.id}.#{ext}")
47
- end
48
-
49
- def save_adoc
50
- relative_path = Pathname.new(filename_adoc).relative_path_from(Dir.pwd)
51
- Utils.log "Save EXPRESS adoc: #{relative_path}"
52
-
53
- FileUtils.mkdir_p(File.dirname(filename_adoc))
54
-
55
- config_relative = Pathname.new(filename_config)
56
- .relative_path_from(Pathname.new(File.dirname(filename_adoc)))
57
-
58
- File.write(filename_adoc, to_adoc(config_relative))
59
- end
60
-
61
- def filename_config
62
- File.join(@output_path, "schema_#{@schema.id}.yaml")
63
- end
64
-
65
- def to_config(path: nil)
66
- @config = Expressir::SchemaManifest.new
67
- @config.schemas << Expressir::SchemaManifestEntry.new(
68
- id: @schema.id,
69
- path: @schema.path,
70
- )
71
- path and @config.path = path
72
-
73
- @config
74
- end
75
-
76
- def save_config
77
- relative_path = Pathname.new(filename_config).relative_path_from(Dir.pwd)
78
- Utils.log "Save schema config: #{relative_path}"
79
-
80
- FileUtils.mkdir_p(File.dirname(filename_config))
81
-
82
- to_config.save_to_path(filename_config)
83
- end
84
-
85
- # Compile Metanorma adoc per EXPRESS schema
86
- def compile
87
- save_config
88
- save_adoc
89
-
90
- relative_path = Pathname.new(filename_adoc).relative_path_from(Dir.pwd)
91
- Utils.log "Compiling schema (id: #{id}, type: #{self.class}) => #{relative_path}"
92
- Metanorma::Compile.new.compile(filename_adoc, agree_to_terms: true,
93
- install_fonts: false)
94
- Utils.log "Compiling schema (id: #{id}, type: #{self.class}) => #{relative_path}... done!"
95
-
96
- self
97
- end
98
-
99
- def output_xml_path
100
- filename_adoc("xml")
101
- end
102
- end
103
- end