suma 0.2.6 → 0.3.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 (53) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +10 -1
  3. data/.rubocop_todo.yml +170 -13
  4. data/CLAUDE.md +37 -11
  5. data/Gemfile +3 -3
  6. data/README.adoc +57 -1
  7. data/exe/suma +1 -1
  8. data/lib/suma/cli/build.rb +0 -5
  9. data/lib/suma/cli/check_svg_quality.rb +0 -6
  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 +0 -3
  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 +0 -1
  18. data/lib/suma/cli/validate.rb +0 -2
  19. data/lib/suma/cli/validate_links.rb +0 -2
  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_schema.rb +0 -1
  26. data/lib/suma/jsdai/figure.rb +0 -3
  27. data/lib/suma/jsdai.rb +5 -2
  28. data/lib/suma/link_validator.rb +15 -7
  29. data/lib/suma/manifest_traverser.rb +92 -0
  30. data/lib/suma/processor.rb +5 -8
  31. data/lib/suma/register_manifest_generator.rb +163 -0
  32. data/lib/suma/schema_category.rb +83 -0
  33. data/lib/suma/schema_collection.rb +29 -33
  34. data/lib/suma/schema_comparer.rb +4 -3
  35. data/lib/suma/schema_compiler.rb +86 -0
  36. data/lib/suma/schema_discovery.rb +75 -0
  37. data/lib/suma/schema_exporter.rb +2 -18
  38. data/lib/suma/schema_manifest_generator.rb +14 -6
  39. data/lib/suma/schema_naming.rb +111 -0
  40. data/lib/suma/schema_template/document.rb +141 -0
  41. data/lib/suma/schema_template/plain.rb +46 -0
  42. data/lib/suma/schema_template.rb +19 -0
  43. data/lib/suma/svg_quality/batch_report.rb +0 -2
  44. data/lib/suma/svg_quality/formatters.rb +12 -0
  45. data/lib/suma/svg_quality.rb +3 -1
  46. data/lib/suma/term_extractor.rb +119 -46
  47. data/lib/suma/urn.rb +61 -0
  48. data/lib/suma/version.rb +1 -1
  49. data/lib/suma.rb +31 -3
  50. data/suma.gemspec +1 -1
  51. metadata +24 -6
  52. data/lib/suma/schema_attachment.rb +0 -103
  53. data/lib/suma/schema_document.rb +0 -118
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.3.0"
5
5
  end
data/lib/suma.rb CHANGED
@@ -3,10 +3,38 @@
3
3
  require "expressir"
4
4
  require "lutaml/model"
5
5
 
6
- require_relative "suma/version"
7
- require_relative "suma/processor"
8
-
9
6
  module Suma
7
+ autoload :VERSION, "suma/version"
8
+
9
+ autoload :Processor, "suma/processor"
10
+ autoload :CollectionConfig, "suma/collection_config"
11
+ autoload :CollectionManifest, "suma/collection_manifest"
12
+ autoload :EengineConverter, "suma/eengine_converter"
13
+ autoload :ExpressSchema, "suma/express_schema"
14
+ autoload :LinkValidator, "suma/link_validator"
15
+ autoload :ManifestTraverser, "suma/manifest_traverser"
16
+ autoload :RegisterManifestGenerator, "suma/register_manifest_generator"
17
+ autoload :SchemaCategory, "suma/schema_category"
18
+ autoload :SchemaCollection, "suma/schema_collection"
19
+ autoload :SchemaComparer, "suma/schema_comparer"
20
+ autoload :SchemaCompiler, "suma/schema_compiler"
21
+ autoload :SchemaDiscovery, "suma/schema_discovery"
22
+ autoload :SchemaExporter, "suma/schema_exporter"
23
+ autoload :SchemaIndex, "suma/schema_index"
24
+ autoload :SchemaManifestGenerator, "suma/schema_manifest_generator"
25
+ autoload :SchemaNaming, "suma/schema_naming"
26
+ autoload :SchemaTemplate, "suma/schema_template"
27
+ autoload :SiteConfig, "suma/site_config"
28
+ autoload :SvgQuality, "suma/svg_quality"
29
+ autoload :TermExtractor, "suma/term_extractor"
30
+ autoload :ThorExt, "suma/thor_ext"
31
+ autoload :Urn, "suma/urn"
32
+ autoload :Utils, "suma/utils"
33
+
34
+ autoload :Cli, "suma/cli"
35
+ autoload :Eengine, "suma/eengine"
36
+ autoload :Jsdai, "suma/jsdai"
37
+
10
38
  class Error < StandardError; end
11
39
  class SchemaNotFoundError < Error; end
12
40
  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.3.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-03 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,14 +192,17 @@ 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
@@ -203,23 +212,32 @@ files:
203
212
  - lib/suma/jsdai/figure_image.rb
204
213
  - lib/suma/jsdai/figure_xml.rb
205
214
  - lib/suma/link_validator.rb
215
+ - lib/suma/manifest_traverser.rb
206
216
  - lib/suma/processor.rb
207
- - lib/suma/schema_attachment.rb
217
+ - lib/suma/register_manifest_generator.rb
218
+ - lib/suma/schema_category.rb
208
219
  - lib/suma/schema_collection.rb
209
220
  - lib/suma/schema_comparer.rb
210
- - lib/suma/schema_document.rb
221
+ - lib/suma/schema_compiler.rb
222
+ - lib/suma/schema_discovery.rb
211
223
  - lib/suma/schema_exporter.rb
212
224
  - lib/suma/schema_index.rb
213
225
  - lib/suma/schema_manifest_generator.rb
226
+ - lib/suma/schema_naming.rb
227
+ - lib/suma/schema_template.rb
228
+ - lib/suma/schema_template/document.rb
229
+ - lib/suma/schema_template/plain.rb
214
230
  - lib/suma/site_config.rb
215
231
  - lib/suma/svg_quality.rb
216
232
  - lib/suma/svg_quality/batch_report.rb
233
+ - lib/suma/svg_quality/formatters.rb
217
234
  - lib/suma/svg_quality/formatters/json_formatter.rb
218
235
  - lib/suma/svg_quality/formatters/terminal_formatter.rb
219
236
  - lib/suma/svg_quality/formatters/yaml_formatter.rb
220
237
  - lib/suma/svg_quality/report.rb
221
238
  - lib/suma/term_extractor.rb
222
239
  - lib/suma/thor_ext.rb
240
+ - lib/suma/urn.rb
223
241
  - lib/suma/utils.rb
224
242
  - lib/suma/version.rb
225
243
  - 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
@@ -1,118 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "schema_attachment"
4
-
5
- module Suma
6
- class SchemaDocument < SchemaAttachment
7
- def bookmark(anchor)
8
- a = anchor.gsub("}}", ' | replace: "\", "-"}}')
9
- "[[#{@id}.#{a}]]"
10
- end
11
-
12
- def schema_anchors
13
- <<~HEREDOC
14
- // _fund_cons.liquid
15
- [[#{@id}_funds]]
16
-
17
- // _constants.liquid
18
- {% if schema.constants.size > 0 %}
19
- #{bookmark('constants')}
20
- {% for thing in schema.constants %}
21
- #{bookmark('{{thing.id}}')}
22
- {% endfor %}
23
- {% endif %}
24
-
25
- // _types.liquid
26
- {% if schema.types.size > 0 %}
27
- #{bookmark('types')}
28
- // _type.liquid
29
- {% for thing in schema.types %}
30
- #{bookmark('{{thing.id}}')}
31
- {% if thing.items.size > 0 %}
32
- // _type_items.liquid
33
- #{bookmark('{{thing.id}}.items')}
34
- {% for item in thing.items %}
35
- #{bookmark('{{thing.id}}.items.{{item.id}}')}
36
- {% endfor %}
37
- {% endif %}
38
- {% endfor %}
39
- {% endif %}
40
-
41
- // _entities.liquid
42
- {% if schema.entities.size > 0 %}
43
- #{bookmark('entities')}
44
- {% for thing in schema.entities %}
45
- // _entity.liquid
46
- #{bookmark('{{thing.id}}')}
47
- {% endfor %}
48
- {% endif %}
49
-
50
- // _subtype_constraints.liquid
51
- {% if schema.subtype_constraints.size > 0 %}
52
- #{bookmark('subtype_constraints')}
53
- // _subtype_constraint.liquid
54
- {% for thing in schema.subtype_constraints %}
55
- #{bookmark('{{thing.id}}')}
56
- {% endfor %}
57
- {% endif %}
58
-
59
- // _functions.liquid
60
- {% if schema.functions.size > 0 %}
61
- #{bookmark('functions')}
62
- // _function.liquid
63
- {% for thing in schema.functions %}
64
- #{bookmark('{{thing.id}}')}
65
- {% endfor %}
66
- {% endif %}
67
-
68
- // _procedures.liquid
69
- {% if schema.procedures.size > 0 %}
70
- #{bookmark('procedures')}
71
- // _procedure.liquid
72
- {% for thing in schema.procedures %}
73
- #{bookmark('{{thing.id}}')}
74
- {% endfor %}
75
- {% endif %}
76
-
77
- // _rules.liquid
78
- {% if schema.rules.size > 0 %}
79
- #{bookmark('rules')}
80
- // _rule.liquid
81
- {% for thing in schema.rules %}
82
- #{bookmark('{{thing.id}}')}
83
- {% endfor %}
84
- {% endif %}
85
- HEREDOC
86
- end
87
-
88
- def output_extensions
89
- "xml"
90
- end
91
-
92
- def to_adoc(path_to_schema_yaml)
93
- <<~HEREDOC
94
- = #{@schema.id}
95
- :lutaml-express-index: schemas; #{path_to_schema_yaml};
96
- :bare: true
97
- :mn-document-class: iso
98
- :mn-output-extensions: xml,html
99
-
100
- [lutaml_express_liquid,schemas,context]
101
- ----
102
- {% for schema in context.schemas %}
103
-
104
- [[#{@id}]]
105
- [%unnumbered,type=express]
106
- == #{@id} #{schema_anchors.gsub(%r{//[^\r\n]+}, '').gsub(/[\n\r]+/, '').gsub(/^[\n\r]/, '')}
107
-
108
- [source%unnumbered]
109
- --
110
- {{ schema.formatted }}
111
- --
112
- {% endfor %}
113
- ----
114
-
115
- HEREDOC
116
- end
117
- end
118
- end