metanorma-plugin-lutaml 0.7.81 → 0.7.83

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: 1dfb4b9c90d1ffba66925177643b11f954b9aa0640e3fdc0c3beefec359267f5
4
- data.tar.gz: b211eedd83758587686f9387f8e9875b52d0c9252632fedb7b9aacbd31e405a4
3
+ metadata.gz: e318f340ac0761daab9b6fdb92174d9b3f7419d289d17fd521239ae3905b99a5
4
+ data.tar.gz: bfe539ed1f0b7ae68852371939a3a89c92aeb87b23f3f862d4d2a121505314a4
5
5
  SHA512:
6
- metadata.gz: ed7b5fe9f10850fe9a3066c73996f38eb73445c5265a790685cc4af60b6c95740ab1e0860239ff5ba03156307c0c08715c5be3e671798533faf43ea25b9c88f9
7
- data.tar.gz: ea8a4b896bd48f51fa4214c5e2d81fd24bc3bfe059a457d2cbed544e2d23f7a12c0a02eb47d92667c4e9d407ff72ac5a9e1b1a8e120947a4678c71ecf11df0cf
6
+ metadata.gz: c404b2f4e76687abaab79a7aafd79ac80e009b6078219f51d6f16f45ab4d3537434c94f292f09d3122ed8400d734e04b77941b32faa6643067543bdfd8874935
7
+ data.tar.gz: 6d45922c579f31ae25769182f7f717d3829207b3991f5a5bc27901a1a3b0d54cbe5b968096d6b3350fe4c87fffb7a59de54b117827fe17dd8d823442ea334f00
@@ -13,26 +13,31 @@ on:
13
13
  default: 'skip'
14
14
  repository_dispatch:
15
15
  types: [ do-release ]
16
- # The publish leg: when the release PR (head branch release/v*) merges,
17
- # metanorma/ci tags the merge commit and publishes (metanorma/ci#515).
18
- # Ordinary PR closes are skipped inside the reusable.
16
+ # The publish leg: when the release PR (head branch `release/v*`) merges,
17
+ # the reusable tags the merge commit and publishes (ci#515). Ordinary PR
18
+ # closes are skipped inside the reusable — no noise on regular merges.
19
19
  pull_request:
20
20
  types:
21
21
  - closed
22
22
 
23
+ # Least-privilege ceiling for the called rubygems-release.yml: its release job
24
+ # needs contents:write (git tag push), id-token:write (OIDC Trusted Publishing),
25
+ # and pull-requests:write (the release-PR leg opens and auto-merges the release
26
+ # PR — ci#515; reusable workflows are capped by the caller's permissions).
27
+ permissions:
28
+ contents: write
29
+ id-token: write
30
+ pull-requests: write
31
+
23
32
  jobs:
24
33
  release:
25
34
  uses: metanorma/ci/.github/workflows/rubygems-release.yml@main
26
- permissions:
27
- id-token: write
28
- contents: write
29
- pull-requests: write
30
35
  with:
31
36
  next_version: ${{ github.event.inputs.next_version }}
32
- # release_command removed (metanorma/ci#515): the reusable's generic
33
- # build+push handles the gem on both legs; bundler's git machinery
34
- # cannot run on the publish leg's detached merge-commit checkout.
35
37
  secrets:
36
- rubygems-api-key: ${{ secrets.METANORMA_CI_RUBYGEMS_API_KEY }}
38
+ # Trusted Publishing (OIDC) is the only publish path: the org
39
+ # METANORMA_CI_RUBYGEMS_API_KEY secret was deleted (metanorma/ci#373),
40
+ # and rubygems-release.yml falls through to the OIDC/TP flow when the
41
+ # rubygems-api-key secret is absent (metanorma/ci#416).
37
42
  pat_token: ${{ secrets.METANORMA_CI_PAT_TOKEN }}
38
43
 
data/.rubocop.yml CHANGED
@@ -2,18 +2,30 @@
2
2
  # See https://github.com/metanorma/cimas
3
3
  inherit_from:
4
4
  - https://raw.githubusercontent.com/riboseinc/oss-guides/main/ci/rubocop.yml
5
+ # .rubocop_todo.yml MUST be the last entry. inherit_from is last-wins:
6
+ # if listed before oss-guides, the shared config's stricter Metrics/
7
+ # (MethodLength, BlockLength, etc.) rules override the todo's per-file
8
+ # grandfathering, and the todo becomes inert on those cops. Empirically
9
+ # verified on suma 2026-07-06: with todo listed first, 34 Metrics/* offenses
10
+ # remained; moved last, cleared. Every gem in the metanorma-org fleet
11
+ # already ships a `.rubocop_todo.yml` on its live tree (audited 2026-07-06,
12
+ # 54/54 have it), so this reference is safe to emit unconditionally.
5
13
  - .rubocop_todo.yml
6
14
 
7
- inherit_mode:
8
- merge:
9
- - Exclude
10
-
11
- # local repo-specific modifications
12
- # ...
15
+ # Rubocop plugins enabled centrally so every metanorma-org gem picks them up
16
+ # on cimas sync — best practice belongs at the shared-template layer, not
17
+ # per-repo. Per ronaldtse feedback on metanorma/ci#332.
13
18
  plugins:
14
19
  - rubocop-rspec
15
20
  - rubocop-performance
16
21
  - rubocop-rake
17
22
 
23
+ # local repo-specific modifications
24
+ # ...
25
+
18
26
  AllCops:
19
- TargetRubyVersion: 3.0
27
+ # 3.3 matches the org-wide minimum being pushed via #274 (Raise minimum
28
+ # Ruby version to 3.3 due to EOL of 3.2 on 2026-03-31). Was 3.4 before
29
+ # this commit — 3.4 was above the org's stated minimum and would have
30
+ # applied Rubocop rules that fail-close on gems still targeting 3.3.
31
+ TargetRubyVersion: 3.3
@@ -1,4 +1,6 @@
1
- require "coradoc"
1
+ require "ceradoc"
2
+ require "ceradoc/html"
3
+ require "ceradoc/asciidoc"
2
4
 
3
5
  module Metanorma
4
6
  module Plugin
@@ -6,8 +8,7 @@ module Metanorma
6
8
  module Liquid
7
9
  module CustomFilters
8
10
  def html2adoc(input)
9
- # Coradoc::ReverseAdoc.convert(input)
10
- Coradoc::Input::Html.convert(input)
11
+ Ceradoc.convert(input, from: :html, to: :asciidoc)
11
12
  end
12
13
 
13
14
  def interpolate(input)
@@ -30,8 +30,19 @@ module Metanorma
30
30
  #
31
31
  # (written on one line in a document)
32
32
  #
33
+ # XML Schema definitions with XML instance documents — the schema
34
+ # (XSD) derives the model classes in-memory and the instance document
35
+ # parses against them (needs lutaml-model >= 0.8.176):
36
+ #
37
+ # [lutaml_data,<schema.xsd>,<instance.xml>,<context>]
38
+ # ----
39
+ # {% for ft in context.CTS100FCFeatureCatalogue.s100_fc_feature_types %}
40
+ # {{ ft.name }}
41
+ # {% endfor %}
42
+ # ----
33
43
  class LutamlDataPreprocessor < BasePreprocessor
34
- DATA_FILE_EXTENSIONS = %w[.lml .yaml .yml .json].freeze
44
+ DATA_FILE_EXTENSIONS = %w[.lml .yaml .yml .json .xml].freeze
45
+ SCHEMA_EXTENSIONS = %w[.xsd].freeze
35
46
  DEFAULT_CONTEXT_NAME = "lutaml_data"
36
47
  PROVIDER_SOURCE = /\Aprovider:(?<name>[^.]+)\.(?<query>.+)\z/
37
48
 
@@ -119,16 +130,25 @@ module Metanorma
119
130
  end
120
131
 
121
132
  def data_file?(segment)
122
- DATA_FILE_EXTENSIONS.include?(File.extname(segment))
133
+ DATA_FILE_EXTENSIONS.include?(File.extname(segment).downcase)
123
134
  end
124
135
 
125
- def render_data_template(document:, lines:, # rubocop:disable Metrics/ParameterLists
136
+ def render_data_template(document:, lines:, # rubocop:disable Metrics/ParameterLists,Metrics/MethodLength
126
137
  definition_file:, instance_file:,
127
138
  context_name:, options:)
128
139
  definition_path, instances_path = resolve_data_paths(
129
140
  document, definition_file, instance_file
130
141
  )
131
142
 
143
+ if SCHEMA_EXTENSIONS.include?(File.extname(definition_path).downcase)
144
+ return render_schema_data_template(
145
+ document: document, lines: lines,
146
+ definition_path: definition_path,
147
+ instances_path: instances_path,
148
+ context_name: context_name, options: options,
149
+ )
150
+ end
151
+
132
152
  compiler = ::Lutaml::Lml::ModelCompiler.new
133
153
  compiler.compile(File.new(definition_path, encoding: "UTF-8"))
134
154
  instances = load_instances(instances_path, compiler)
@@ -219,8 +239,79 @@ module Metanorma
219
239
  [definition_path, instances_path || definition_path]
220
240
  end
221
241
 
242
+ # Schema-driven reading: the XSD is the schema of record. Derive
243
+ # the model classes in-memory (no generated files) and parse the
244
+ # XML instance document against them; liquid sees the parsed
245
+ # model keyed by its root class name, matching the LML flow.
246
+ def render_schema_data_template(document:, lines:,
247
+ definition_path:, instances_path:,
248
+ context_name:, options:)
249
+ # The XSD reader ships inside lutaml-model
250
+ # (lib/lutaml/xml/schema/xsd.rb). Do NOT require the lutaml
251
+ # gem's glue here: its released 0.11.x still vendors a
252
+ # lutaml/model copy whose definitions would shadow the
253
+ # canonical gem's (the vendoring is being removed on the
254
+ # lutaml unvendor branch).
255
+ require "lutaml/model"
256
+
257
+ ::Lutaml::Xml::Schema::Xsd # ensure the schema reader is loaded
258
+
259
+ schema_source = File.read(definition_path, encoding: "UTF-8")
260
+ module_namespace = schema_module_namespace(definition_path)
261
+ target_namespace = schema_target_namespace(definition_path,
262
+ schema_source)
263
+
264
+ ::Lutaml::Model::Schema.from_xml(
265
+ schema_source,
266
+ load_classes: true,
267
+ module_namespace: module_namespace,
268
+ namespace: target_namespace,
269
+ register_id: module_namespace,
270
+ location: definition_path,
271
+ )
272
+
273
+ instances = load_xml_instances(instances_path, module_namespace)
274
+ [render_liquid(lines, document, options, context_name, instances)]
275
+ end
276
+
277
+ def schema_module_namespace(definition_path)
278
+ base = File.basename(definition_path, ".*")
279
+ "LutamlXml#{base.gsub(/[^A-Za-z0-9]/, "_").split("_")
280
+ .reject(&:empty?).map(&:capitalize).join}"
281
+ end
282
+
283
+ def schema_target_namespace(definition_path, source)
284
+ schema = ::Lutaml::Xml::Schema::Xsd.parse(
285
+ source, location: definition_path
286
+ )
287
+ schema.target_namespace
288
+ end
289
+
290
+ def load_xml_instances(instances_path, module_namespace)
291
+ require "nokogiri"
292
+
293
+ instance_xml = File.read(instances_path, encoding: "UTF-8")
294
+ root_name = Nokogiri::XML(instance_xml).root.name
295
+
296
+ namespace = Object.const_get(module_namespace)
297
+ root_class = namespace.constants.filter_map do |const|
298
+ klass = namespace.const_get(const)
299
+ next unless klass.is_a?(Class) && klass < ::Lutaml::Model::Serializable
300
+
301
+ klass.mappings_for(:xml)&.root_element == root_name ? klass : nil
302
+ end.first
303
+
304
+ unless root_class
305
+ raise StandardError,
306
+ "No derived model declares root element `#{root_name}` " \
307
+ "for `#{instances_path}`"
308
+ end
309
+
310
+ [[demodulize(root_class.name), root_class.from_xml(instance_xml)]]
311
+ end
312
+
222
313
  def load_instances(path, compiler)
223
- case File.extname(path)
314
+ case File.extname(path).downcase
224
315
  when ".lml" then load_lml_instances(path, compiler)
225
316
  when ".json" then load_structured_instances(path, compiler,
226
317
  :parse_json_data)
@@ -5,6 +5,10 @@ require "asciidoctor"
5
5
  require "asciidoctor/reader"
6
6
  require "lutaml/uml"
7
7
  require "lutaml/lml"
8
+ # lutaml 0.11.x split the Graphviz formatter out into the lutaml-graphviz
9
+ # gem; requiring it registers Lutaml::Formatter::Graphviz back into
10
+ # Lutaml::Formatter.all.
11
+ require "lutaml/graphviz"
8
12
 
9
13
  module Metanorma
10
14
  module Plugin
@@ -1,7 +1,7 @@
1
1
  module Metanorma
2
2
  module Plugin
3
3
  module Lutaml
4
- VERSION = "0.7.81".freeze
4
+ VERSION = "0.7.83".freeze
5
5
  end
6
6
  end
7
7
  end
@@ -26,18 +26,29 @@ Gem::Specification.new do |spec|
26
26
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
27
27
  spec.require_paths = ["lib"]
28
28
 
29
- spec.required_ruby_version = ">= 3.0.0" # rubocop:disable Gemspec/RequiredRubyVersion
29
+ spec.required_ruby_version = Gem::Requirement.new(">= 3.3.0")
30
30
 
31
31
  spec.add_dependency "asciidoctor"
32
- spec.add_dependency "coradoc", "~> 1.1.8"
33
- spec.add_dependency "ea", ">= 0.6.41" # Ea::Xmi.load/load_graph (lutaml/ea#86): the partial-load API this gem calls
32
+ # ceradoc-adoc >= 2.0.38 widened its parsanol floor to >= 1.3.123, < 2
33
+ # (ceradoc#365), so the expressir 2.4.x chain co-resolves again.
34
+ spec.add_dependency "ceradoc", "~> 3.0"
35
+ spec.add_dependency "ceradoc-adoc", "~> 2.0"
36
+ spec.add_dependency "ceradoc-html", "~> 1.1"
37
+ # >= 0.6.157: first release with the Qea::Rules layer and the shipped
38
+ # ea/qea/rules/generalization.rb (0.6.149-0.6.156 are broken for the
39
+ # diagram/Liquid-drops path — lutaml/ea#234, #246). Ea::Xmi.load/load_graph
40
+ # (lutaml/ea#86): the partial-load API this gem calls.
41
+ spec.add_dependency "ea", "~> 0.6.157"
34
42
  spec.add_dependency "expressir", "~> 2.3", ">= 2.3.5"
35
43
  spec.add_dependency "isodoc", ">= 3.5.0"
36
44
  spec.add_dependency "liquid", "~> 5"
37
45
  spec.add_dependency "lutaml-jsonschema", "~> 0.1", ">= 0.1.29"
46
+ spec.add_dependency "lutaml-graphviz"
38
47
  spec.add_dependency "lutaml-lml"
39
48
  spec.add_dependency "lutaml-model", "~> 0.8.156"
40
- spec.add_dependency "lutaml-uml", ">= 0.5", "< 2"
49
+ # >= 1.0.4: Lutaml::Uml::Value#initial (enum literal codes) — required by
50
+ # ea >= 0.6.151+ which writes initial values during XMI parsing.
51
+ spec.add_dependency "lutaml-uml", "~> 1.0", ">= 1.0.4"
41
52
  spec.add_dependency "ogc-gml", "~> 1.1"
42
53
  spec.metadata["rubygems_mfa_required"] = "true"
43
54
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-plugin-lutaml
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.81
4
+ version: 0.7.83
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-20 00:00:00.000000000 Z
11
+ date: 2026-11-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor
@@ -25,33 +25,61 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: coradoc
28
+ name: ceradoc
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 1.1.8
33
+ version: '3.0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 1.1.8
40
+ version: '3.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: ceradoc-adoc
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '2.0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '2.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: ceradoc-html
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.1'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.1'
41
69
  - !ruby/object:Gem::Dependency
42
70
  name: ea
43
71
  requirement: !ruby/object:Gem::Requirement
44
72
  requirements:
45
- - - ">="
73
+ - - "~>"
46
74
  - !ruby/object:Gem::Version
47
- version: 0.6.41
75
+ version: 0.6.157
48
76
  type: :runtime
49
77
  prerelease: false
50
78
  version_requirements: !ruby/object:Gem::Requirement
51
79
  requirements:
52
- - - ">="
80
+ - - "~>"
53
81
  - !ruby/object:Gem::Version
54
- version: 0.6.41
82
+ version: 0.6.157
55
83
  - !ruby/object:Gem::Dependency
56
84
  name: expressir
57
85
  requirement: !ruby/object:Gem::Requirement
@@ -120,6 +148,20 @@ dependencies:
120
148
  - - ">="
121
149
  - !ruby/object:Gem::Version
122
150
  version: 0.1.29
151
+ - !ruby/object:Gem::Dependency
152
+ name: lutaml-graphviz
153
+ requirement: !ruby/object:Gem::Requirement
154
+ requirements:
155
+ - - ">="
156
+ - !ruby/object:Gem::Version
157
+ version: '0'
158
+ type: :runtime
159
+ prerelease: false
160
+ version_requirements: !ruby/object:Gem::Requirement
161
+ requirements:
162
+ - - ">="
163
+ - !ruby/object:Gem::Version
164
+ version: '0'
123
165
  - !ruby/object:Gem::Dependency
124
166
  name: lutaml-lml
125
167
  requirement: !ruby/object:Gem::Requirement
@@ -152,22 +194,22 @@ dependencies:
152
194
  name: lutaml-uml
153
195
  requirement: !ruby/object:Gem::Requirement
154
196
  requirements:
155
- - - ">="
197
+ - - "~>"
156
198
  - !ruby/object:Gem::Version
157
- version: '0.5'
158
- - - "<"
199
+ version: '1.0'
200
+ - - ">="
159
201
  - !ruby/object:Gem::Version
160
- version: '2'
202
+ version: 1.0.4
161
203
  type: :runtime
162
204
  prerelease: false
163
205
  version_requirements: !ruby/object:Gem::Requirement
164
206
  requirements:
165
- - - ">="
207
+ - - "~>"
166
208
  - !ruby/object:Gem::Version
167
- version: '0.5'
168
- - - "<"
209
+ version: '1.0'
210
+ - - ">="
169
211
  - !ruby/object:Gem::Version
170
- version: '2'
212
+ version: 1.0.4
171
213
  - !ruby/object:Gem::Dependency
172
214
  name: ogc-gml
173
215
  requirement: !ruby/object:Gem::Requirement
@@ -576,7 +618,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
576
618
  requirements:
577
619
  - - ">="
578
620
  - !ruby/object:Gem::Version
579
- version: 3.0.0
621
+ version: 3.3.0
580
622
  required_rubygems_version: !ruby/object:Gem::Requirement
581
623
  requirements:
582
624
  - - ">="