suma 0.2.5 → 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 (63) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rake.yml +3 -0
  3. data/.github/workflows/release.yml +5 -1
  4. data/.gitignore +10 -1
  5. data/.rubocop_todo.yml +237 -28
  6. data/CLAUDE.md +102 -0
  7. data/Gemfile +3 -1
  8. data/README.adoc +188 -1
  9. data/exe/suma +1 -1
  10. data/lib/suma/cli/build.rb +2 -8
  11. data/lib/suma/cli/check_svg_quality.rb +172 -0
  12. data/lib/suma/cli/compare.rb +6 -158
  13. data/lib/suma/cli/convert_jsdai.rb +0 -2
  14. data/lib/suma/cli/core.rb +119 -0
  15. data/lib/suma/cli/export.rb +1 -10
  16. data/lib/suma/cli/extract_terms.rb +10 -654
  17. data/lib/suma/cli/generate_register.rb +34 -0
  18. data/lib/suma/cli/generate_schemas.rb +8 -124
  19. data/lib/suma/cli/reformat.rb +0 -1
  20. data/lib/suma/cli/validate.rb +0 -2
  21. data/lib/suma/cli/validate_links.rb +14 -291
  22. data/lib/suma/cli.rb +12 -102
  23. data/lib/suma/collection_config.rb +0 -2
  24. data/lib/suma/collection_manifest.rb +7 -111
  25. data/lib/suma/eengine/wrapper.rb +0 -1
  26. data/lib/suma/eengine.rb +8 -0
  27. data/lib/suma/express_schema.rb +43 -31
  28. data/lib/suma/jsdai/figure.rb +0 -3
  29. data/lib/suma/jsdai/figure_xml.rb +12 -9
  30. data/lib/suma/jsdai.rb +5 -8
  31. data/lib/suma/link_validator.rb +211 -0
  32. data/lib/suma/manifest_traverser.rb +92 -0
  33. data/lib/suma/processor.rb +76 -105
  34. data/lib/suma/register_manifest_generator.rb +163 -0
  35. data/lib/suma/schema_category.rb +83 -0
  36. data/lib/suma/schema_collection.rb +28 -63
  37. data/lib/suma/schema_comparer.rb +117 -0
  38. data/lib/suma/schema_compiler.rb +86 -0
  39. data/lib/suma/schema_discovery.rb +75 -0
  40. data/lib/suma/schema_exporter.rb +7 -35
  41. data/lib/suma/schema_index.rb +53 -0
  42. data/lib/suma/schema_manifest_generator.rb +113 -0
  43. data/lib/suma/schema_naming.rb +111 -0
  44. data/lib/suma/schema_template/document.rb +141 -0
  45. data/lib/suma/schema_template/plain.rb +46 -0
  46. data/lib/suma/schema_template.rb +19 -0
  47. data/lib/suma/svg_quality/batch_report.rb +78 -0
  48. data/lib/suma/svg_quality/formatters/json_formatter.rb +30 -0
  49. data/lib/suma/svg_quality/formatters/terminal_formatter.rb +168 -0
  50. data/lib/suma/svg_quality/formatters/yaml_formatter.rb +32 -0
  51. data/lib/suma/svg_quality/formatters.rb +12 -0
  52. data/lib/suma/svg_quality/report.rb +52 -0
  53. data/lib/suma/svg_quality.rb +30 -0
  54. data/lib/suma/term_extractor.rb +466 -0
  55. data/lib/suma/urn.rb +61 -0
  56. data/lib/suma/utils.rb +10 -2
  57. data/lib/suma/version.rb +1 -1
  58. data/lib/suma.rb +34 -5
  59. data/suma.gemspec +3 -2
  60. metadata +53 -9
  61. data/lib/suma/export_standalone_schema.rb +0 -14
  62. data/lib/suma/schema_attachment.rb +0 -130
  63. data/lib/suma/schema_document.rb +0 -132
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.5
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-04-13 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,28 +36,34 @@ dependencies:
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: 2.4.0
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.0
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
50
56
  requirements:
51
57
  - - "~>"
52
58
  - !ruby/object:Gem::Version
53
- version: '0.7'
59
+ version: 0.8.0
54
60
  type: :runtime
55
61
  prerelease: false
56
62
  version_requirements: !ruby/object:Gem::Requirement
57
63
  requirements:
58
64
  - - "~>"
59
65
  - !ruby/object:Gem::Version
60
- version: '0.7'
66
+ version: 0.8.0
61
67
  - !ruby/object:Gem::Dependency
62
68
  name: metanorma
63
69
  requirement: !ruby/object:Gem::Requirement
@@ -114,6 +120,20 @@ dependencies:
114
120
  - - "~>"
115
121
  - !ruby/object:Gem::Version
116
122
  version: '2.3'
123
+ - !ruby/object:Gem::Dependency
124
+ name: svg_conform
125
+ requirement: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - "~>"
128
+ - !ruby/object:Gem::Version
129
+ version: 0.1.0
130
+ type: :runtime
131
+ prerelease: false
132
+ version_requirements: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - "~>"
135
+ - !ruby/object:Gem::Version
136
+ version: 0.1.0
117
137
  - !ruby/object:Gem::Dependency
118
138
  name: table_tennis
119
139
  requirement: !ruby/object:Gem::Requirement
@@ -158,6 +178,7 @@ files:
158
178
  - ".rspec"
159
179
  - ".rubocop.yml"
160
180
  - ".rubocop_todo.yml"
181
+ - CLAUDE.md
161
182
  - CODE_OF_CONDUCT.md
162
183
  - Gemfile
163
184
  - README.adoc
@@ -168,32 +189,55 @@ files:
168
189
  - lib/suma.rb
169
190
  - lib/suma/cli.rb
170
191
  - lib/suma/cli/build.rb
192
+ - lib/suma/cli/check_svg_quality.rb
171
193
  - lib/suma/cli/compare.rb
172
194
  - lib/suma/cli/convert_jsdai.rb
195
+ - lib/suma/cli/core.rb
173
196
  - lib/suma/cli/export.rb
174
197
  - lib/suma/cli/extract_terms.rb
198
+ - lib/suma/cli/generate_register.rb
175
199
  - lib/suma/cli/generate_schemas.rb
176
200
  - lib/suma/cli/reformat.rb
177
201
  - lib/suma/cli/validate.rb
178
202
  - lib/suma/cli/validate_links.rb
179
203
  - lib/suma/collection_config.rb
180
204
  - lib/suma/collection_manifest.rb
205
+ - lib/suma/eengine.rb
181
206
  - lib/suma/eengine/errors.rb
182
207
  - lib/suma/eengine/wrapper.rb
183
208
  - lib/suma/eengine_converter.rb
184
- - lib/suma/export_standalone_schema.rb
185
209
  - lib/suma/express_schema.rb
186
210
  - lib/suma/jsdai.rb
187
211
  - lib/suma/jsdai/figure.rb
188
212
  - lib/suma/jsdai/figure_image.rb
189
213
  - lib/suma/jsdai/figure_xml.rb
214
+ - lib/suma/link_validator.rb
215
+ - lib/suma/manifest_traverser.rb
190
216
  - lib/suma/processor.rb
191
- - lib/suma/schema_attachment.rb
217
+ - lib/suma/register_manifest_generator.rb
218
+ - lib/suma/schema_category.rb
192
219
  - lib/suma/schema_collection.rb
193
- - lib/suma/schema_document.rb
220
+ - lib/suma/schema_comparer.rb
221
+ - lib/suma/schema_compiler.rb
222
+ - lib/suma/schema_discovery.rb
194
223
  - lib/suma/schema_exporter.rb
224
+ - lib/suma/schema_index.rb
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
195
230
  - lib/suma/site_config.rb
231
+ - lib/suma/svg_quality.rb
232
+ - lib/suma/svg_quality/batch_report.rb
233
+ - lib/suma/svg_quality/formatters.rb
234
+ - lib/suma/svg_quality/formatters/json_formatter.rb
235
+ - lib/suma/svg_quality/formatters/terminal_formatter.rb
236
+ - lib/suma/svg_quality/formatters/yaml_formatter.rb
237
+ - lib/suma/svg_quality/report.rb
238
+ - lib/suma/term_extractor.rb
196
239
  - lib/suma/thor_ext.rb
240
+ - lib/suma/urn.rb
197
241
  - lib/suma/utils.rb
198
242
  - lib/suma/version.rb
199
243
  - sig/suma.rbs
@@ -1,14 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Suma
4
- # Simple schema class for standalone EXPRESS files
5
- # Used when exporting individual .exp files that are not part of a manifest
6
- class ExportStandaloneSchema
7
- attr_accessor :id, :path
8
-
9
- def initialize(id:, path:)
10
- @id = id
11
- @path = path
12
- end
13
- end
14
- end
@@ -1,130 +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
- # return if File.exist?(filename_adoc)
54
- FileUtils.mkdir_p(File.dirname(filename_adoc))
55
-
56
- relative_path = Pathname.new(filename_config)
57
- .relative_path_from(Pathname.new(File.dirname(filename_adoc)))
58
-
59
- # Utils.log "relative_path #{relative_path}"
60
-
61
- File.write(filename_adoc, to_adoc(relative_path))
62
- end
63
-
64
- def filename_config
65
- File.join(@output_path, "schema_#{@schema.id}.yaml")
66
- end
67
-
68
- def to_config(path: nil)
69
- # return @config unless @config
70
- @config = Expressir::SchemaManifest.new
71
- @config.schemas << Expressir::SchemaManifestEntry.new(
72
- id: @schema.id,
73
- path: @schema.path,
74
- )
75
- path and @config.path = path
76
-
77
- @config
78
- end
79
-
80
- def save_config
81
- relative_path = Pathname.new(filename_config).relative_path_from(Dir.pwd)
82
- Utils.log "Save schema config: #{relative_path}"
83
-
84
- # Still overwrite even if the file exists
85
- # return if File.exist?(filename_config)
86
- FileUtils.mkdir_p(File.dirname(filename_config))
87
-
88
- to_config.save_to_path(filename_config)
89
- end
90
-
91
- # Compile Metanorma adoc per EXPRESS schema
92
- def compile
93
- # TODO: Clean artifacts after compiling
94
- # I am commenting out because I'm playing with the schemas-only status
95
- # return self if File.exist?(output_xml_path)
96
-
97
- save_config
98
- save_adoc
99
-
100
- relative_path = Pathname.new(filename_adoc).relative_path_from(Dir.pwd)
101
- Utils.log "Compiling schema (id: #{id}, type: #{self.class}) => #{relative_path}"
102
- Metanorma::Compile.new.compile(filename_adoc, agree_to_terms: true,
103
- install_fonts: false)
104
- Utils.log "Compiling schema (id: #{id}, type: #{self.class}) => #{relative_path}... done!"
105
-
106
- # clean_artifacts
107
-
108
- # filename_adoc('xml')
109
- self
110
- end
111
-
112
- def output_xml_path
113
- filename_adoc("xml")
114
- end
115
-
116
- def clean_artifacts
117
- [
118
- filename_config,
119
- filename_adoc,
120
- filename_adoc("presentation.xml"),
121
- filename_adoc("adoc.lutaml.log.txt"),
122
- filename_adoc("err.html"),
123
- ].each do |filename|
124
- FileUtils.rm_rf(filename)
125
- end
126
- end
127
-
128
- def output_folder; end
129
- end
130
- end
@@ -1,132 +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
- # ////
89
- # TODO:
90
- # % render "templates/entities", schema: schema, schema_id: schema.id, things: schema.entities, thing_prefix: root_thing_prefix, depth: 2 %
91
- #
92
- # % render "templates/subtype_constraints", schema_id: schema.id, things: schema.subtype_constraints, thing_prefix: root_thing_prefix, depth: 2 %
93
- #
94
- # % render "templates/functions", schema_id: schema.id, things: schema.functions, thing_prefix: root_thing_prefix, depth: 2 %
95
- #
96
- # % render "templates/procedures", schema_id: schema.id, things: schema.procedures, thing_prefix: root_thing_prefix, depth: 2 %
97
- #
98
- # % render "templates/rules", schema_id: schema.id, things: schema.rules, thing_prefix: root_thing_prefix, depth: 2 %
99
- # ////
100
-
101
- def output_extensions
102
- "xml"
103
- end
104
-
105
- # #.gsub(/[\n\r]{2,}/, '')
106
- def to_adoc(path_to_schema_yaml)
107
- <<~HEREDOC
108
- = #{@schema.id}
109
- :lutaml-express-index: schemas; #{path_to_schema_yaml};
110
- :bare: true
111
- :mn-document-class: iso
112
- :mn-output-extensions: xml,html
113
-
114
- [lutaml_express_liquid,schemas,context]
115
- ----
116
- {% for schema in context.schemas %}
117
-
118
- [[#{@id}]]
119
- [%unnumbered,type=express]
120
- == #{@id} #{schema_anchors.gsub(%r{//[^\r\n]+}, '').gsub(/[\n\r]+/, '').gsub(/^[\n\r]/, '')}
121
-
122
- [source%unnumbered]
123
- --
124
- {{ schema.formatted }}
125
- --
126
- {% endfor %}
127
- ----
128
-
129
- HEREDOC
130
- end
131
- end
132
- end