vectory 0.12.0 → 0.13.1

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: 3a9abbde7cd6a7876ad8a2f8077786e870dcf860b3206bef30f061f997145d31
4
- data.tar.gz: 05c8f3c7a6ab01aa09e3facc83d145ba17a6a8ea7dde5e2bba02ab1405d49999
3
+ metadata.gz: 5f48a547c1520b19d88d77ad41c2e2967da41896163f49ef39492f6f6e73b1af
4
+ data.tar.gz: cb36e0382b283f7ad50816a5ce5ff5b6a80736a44f8a062db57dd8ce836385f2
5
5
  SHA512:
6
- metadata.gz: a9651cbe852b2ba5dbdbdb07db31105aa33bf9a41bcc7bd0cb4f621c679ba41f4343f85ae0d4f3722a34cfaab2cb4cb80210e2aa383b71d7df34256b36a781ac
7
- data.tar.gz: c03d30678dfa73b41dac5b987cd70905fc0edc2dcd5621a7bdfb2d61bf8be11769f1d4135602c93aa7b51b243e05b915d0c7b0e55f5002badc50d45365863e3a
6
+ metadata.gz: 11759d94c1a88218d39f5e4561a661c1c0bee4f371d9c369571d95c34e141dadfb308646c890fc08ddef5a5484fe381e5303b07fc153985b0989fd249e85d8c8
7
+ data.tar.gz: 1a0151957b311956558f7935e548e92d2678d283238eb66445ec7203916b3fba3753f93140affb5145b732df6f8cd3b75746a2985f9801875a2bf4688f021ad3
@@ -1,5 +1,7 @@
1
- # Auto-generated by Cimas: Do not edit it manually!
2
- # See https://github.com/metanorma/cimas
1
+ # Trusted publishing (OIDC) release — matches lutaml-model/.github/workflows/release.yml.
2
+ # metanorma/ci switches to OIDC when the rubygems-api-key secret is omitted;
3
+ # each gem must be registered for trusted publishing on rubygems.org
4
+ # (owner=claricle, workflow=release.yml).
3
5
  name: release
4
6
 
5
7
  on:
@@ -10,19 +12,21 @@ on:
10
12
  Next release version. Possible values: x.y.z, major, minor, patch or pre|rc|etc
11
13
  required: true
12
14
  default: 'skip'
13
- push:
14
- tags: [ v* ]
15
+ repository_dispatch:
16
+ types: [ do-release ]
15
17
 
18
+ # Least-privilege ceiling for the called rubygems-release.yml: its release job
19
+ # needs contents:write (git tag push) and id-token:write (OIDC Trusted Publishing).
16
20
  permissions:
17
21
  contents: write
18
- packages: write
19
22
  id-token: write
20
23
 
24
+ concurrency:
25
+ group: release
26
+ cancel-in-progress: false
27
+
21
28
  jobs:
22
29
  release:
23
30
  uses: metanorma/ci/.github/workflows/rubygems-release.yml@main
24
31
  with:
25
32
  next_version: ${{ github.event.inputs.next_version }}
26
- secrets:
27
- rubygems-api-key: ${{ secrets.CLARICLE_CI_RUBYGEMS_API_KEY }}
28
- pat_token: ${{ secrets.CLARICLE_CI_PAT_TOKEN }}
data/Gemfile CHANGED
@@ -9,6 +9,7 @@ gem "canon", "~> 0.1.7"
9
9
  gem "connection_pool", "~> 2.0"
10
10
  gem "openssl", "~> 3.0"
11
11
  gem "rake"
12
+ gem "nokogiri" # dev-only: exercises SvgMapping's duck-typed document-object input (metanorma passes Nokogiri docs)
12
13
  gem "rspec"
13
14
  gem "rubocop"
14
15
  gem "rubocop-performance"
data/lib/vectory/svg.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "nokogiri"
3
+ require "leptris"
4
4
  require "postsvg"
5
5
 
6
6
  module Vectory
@@ -55,7 +55,7 @@ module Vectory
55
55
  private
56
56
 
57
57
  def svg_root
58
- doc = Nokogiri::XML(content)
58
+ doc = Leptris::XML.parse(content)
59
59
  doc.at_xpath("//svg:svg", "svg" => SVG_NS) || doc.at_xpath("//svg")
60
60
  end
61
61
 
@@ -77,7 +77,11 @@ module Vectory
77
77
  def content=(content)
78
78
  # non-root node inserts the xml tag which breaks markup when placed in
79
79
  # another xml document
80
- document = Nokogiri::XML(content).root
80
+ document = begin
81
+ Leptris::XML.parse(content).root
82
+ rescue Leptris::XML::ParseError
83
+ nil
84
+ end
81
85
  unless document
82
86
  raise ParsingError, "Could not parse '#{content&.slice(0, 30)}'"
83
87
  end
@@ -1,4 +1,4 @@
1
- require "nokogiri"
1
+ require "leptris"
2
2
 
3
3
  module Vectory
4
4
  # Represents and processes an SVG document within XML.
@@ -21,7 +21,7 @@ module Vectory
21
21
  class << self
22
22
  # Updates ID references in CSS style statements within a document.
23
23
  #
24
- # @param document [Nokogiri::XML::Document] The SVG document
24
+ # @param document [Leptris::XML::Document] The SVG document
25
25
  # @param ids [Array<String>] IDs to update
26
26
  # @param suffix [Integer, String] The suffix to apply (integers are zero-padded)
27
27
  # @return [void]
@@ -56,7 +56,7 @@ module Vectory
56
56
 
57
57
  # Updates ID attributes in SVG elements.
58
58
  #
59
- # @param document [Nokogiri::XML::Document] The SVG document
59
+ # @param document [Leptris::XML::Document] The SVG document
60
60
  # @param ids [Array<String>] IDs to update
61
61
  # @param suffix [Integer, String] The suffix to apply (integers are zero-padded)
62
62
  # @return [void]
@@ -76,7 +76,7 @@ module Vectory
76
76
  #
77
77
  # @param content [String] SVG XML content
78
78
  def initialize(content)
79
- @document = Nokogiri::XML(content)
79
+ @document = Leptris::XML.parse(content)
80
80
  end
81
81
 
82
82
  # Returns the processed SVG content as XML string.
@@ -1,3 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "leptris"
4
+
1
5
  module Vectory
2
6
  # Processes SVG mapping in XML documents.
3
7
  #
@@ -7,6 +11,11 @@ module Vectory
7
11
  # - Applying ID suffixes for uniqueness in multi-document scenarios
8
12
  # - Simplifying svgmap structure for final output
9
13
  #
14
+ # The document is processed on a leptris tree: pass XML content, or any
15
+ # document object responding to #to_xml (serialized once on entry).
16
+ # #call returns the processed Leptris document; callers working on
17
+ # their own DOM (e.g. Nokogiri) re-serialize and graft the result back.
18
+ #
10
19
  # == ID Suffixing
11
20
  #
12
21
  # SVG IDs are suffixed in two stages to ensure uniqueness:
@@ -30,7 +39,7 @@ module Vectory
30
39
  class SvgMapping
31
40
  # Namespace helper for XML namespace handling
32
41
  class Namespace
33
- # @param xmldoc [Nokogiri::XML::Document] The XML document
42
+ # @param xmldoc [Leptris::XML::Document] The XML document
34
43
  def initialize(xmldoc)
35
44
  @namespace = xmldoc.root.namespace
36
45
  end
@@ -61,7 +70,7 @@ module Vectory
61
70
  # @param path [String] Path to the XML file
62
71
  # @return [Vectory::SvgMapping] New mapping instance
63
72
  def self.from_path(path)
64
- new(Nokogiri::XML(File.read(path)))
73
+ new(File.read(path))
65
74
  end
66
75
 
67
76
  # Creates an SvgMapping from an XML string.
@@ -69,25 +78,27 @@ module Vectory
69
78
  # @param xml [String] XML content
70
79
  # @return [Vectory::SvgMapping] New mapping instance
71
80
  def self.from_xml(xml)
72
- new(Nokogiri::XML(xml))
81
+ new(xml)
73
82
  end
74
83
 
75
84
  # Initializes a new SvgMapping processor.
76
85
  #
77
- # @param doc [Nokogiri::XML::Document] The document containing svgmap elements
86
+ # @param doc [String, #to_xml] XML content, or a document object
87
+ # (serialized once on entry)
78
88
  # @param local_directory [String] Directory for resolving relative file paths
79
89
  # @param id_suffix [String, nil] Optional suffix derived from document/container
80
90
  # identity. Applied before the index suffix to provide cross-document
81
91
  # uniqueness. Example: "_ISO_17301-1_2016"
82
92
  def initialize(doc, local_directory = "", id_suffix: nil)
83
- @doc = doc
93
+ xml = doc.respond_to?(:to_xml) ? doc.to_xml : doc
94
+ @doc = Leptris::XML.parse(xml)
84
95
  @local_directory = local_directory
85
96
  @id_suffix = id_suffix
86
97
  end
87
98
 
88
99
  # Processes all svgmap elements in the document.
89
100
  #
90
- # @return [Nokogiri::XML::Document] The processed document
101
+ # @return [Leptris::XML::Document] The processed document
91
102
  def call
92
103
  @namespace = Namespace.new(@doc)
93
104
 
@@ -109,7 +120,7 @@ module Vectory
109
120
 
110
121
  # Processes a single svgmap element.
111
122
  #
112
- # @param svgmap [Nokogiri::XML::Element] The svgmap element to process
123
+ # @param svgmap [Leptris::XML::Element] The svgmap element to process
113
124
  # @param index [Integer] Position of this svgmap in the document (0-indexed)
114
125
  def process_svgmap(svgmap, index)
115
126
  image = extract_image_tag(svgmap)
@@ -125,19 +136,19 @@ module Vectory
125
136
 
126
137
  # Extracts the image element (SVG inline or image with src) from svgmap.
127
138
  #
128
- # @param svgmap [Nokogiri::XML::Element] The svgmap element
129
- # @return [Nokogiri::XML::Element, nil] The image/svg element or nil
139
+ # @param svgmap [Leptris::XML::Element] The svgmap element
140
+ # @return [Leptris::XML::Element, nil] The image/svg element or nil
130
141
  def extract_image_tag(svgmap)
131
- image = svgmap.at(@namespace.ns(".//image"))
142
+ image = svgmap.at_xpath(@namespace.ns(".//image"))
132
143
  return image if image && image["src"] && !image["src"].empty?
133
144
 
134
- svgmap.at(".//m:svg", "m" => SVG_NS)
145
+ svgmap.at_xpath(".//m:svg", "m" => SVG_NS)
135
146
  end
136
147
 
137
148
  # Generates processed SVG content for an svgmap.
138
149
  #
139
- # @param image [Nokogiri::XML::Element] The image/svg element
140
- # @param svgmap [Nokogiri::XML::Element] The parent svgmap element
150
+ # @param image [Leptris::XML::Element] The image/svg element
151
+ # @param svgmap [Leptris::XML::Element] The parent svgmap element
141
152
  # @param index [Integer] Index suffix to apply
142
153
  # @return [String, nil] Processed SVG content or nil if invalid
143
154
  def generate_content(image, svgmap, index)
@@ -153,7 +164,7 @@ module Vectory
153
164
 
154
165
  # Builds an SvgDocument from an image element.
155
166
  #
156
- # @param image [Nokogiri::XML::Element] The image element
167
+ # @param image [Leptris::XML::Element] The image element
157
168
  # @return [Vectory::SvgDocument, nil] The SVG document or nil if invalid
158
169
  def build_svg_document(image)
159
170
  vector = build_vector(image)
@@ -164,7 +175,7 @@ module Vectory
164
175
 
165
176
  # Builds a Vector from an image element.
166
177
  #
167
- # @param image [Nokogiri::XML::Element] The image element
178
+ # @param image [Leptris::XML::Element] The image element
168
179
  # @return [Vectory::Vector, nil] The vector or nil if invalid
169
180
  def build_vector(image)
170
181
  return Vectory::Svg.from_content(image.to_xml) if image.name == "svg"
@@ -182,7 +193,7 @@ module Vectory
182
193
 
183
194
  # Builds a mapping from target hrefs to their link targets.
184
195
  #
185
- # @param svgmap [Nokogiri::XML::Element] The svgmap element
196
+ # @param svgmap [Leptris::XML::Element] The svgmap element
186
197
  # @return [Hash{String => String}] Mapping of href to target
187
198
  def from_targets_to_links_map(svgmap)
188
199
  targets = svgmap.xpath(@namespace.ns("./target"))
@@ -199,13 +210,13 @@ module Vectory
199
210
 
200
211
  # Extracts link target from a target element.
201
212
  #
202
- # @param target_tag [Nokogiri::XML::Element] The target element
213
+ # @param target_tag [Leptris::XML::Element] The target element
203
214
  # @return [String, nil] The link target or nil
204
215
  def link_target(target_tag)
205
- xref = target_tag.at(@namespace.ns("./xref"))
216
+ xref = target_tag.at_xpath(@namespace.ns("./xref"))
206
217
  return "##{xref['target']}" if xref
207
218
 
208
- link = target_tag.at(@namespace.ns("./link"))
219
+ link = target_tag.at_xpath(@namespace.ns("./link"))
209
220
  return unless link
210
221
 
211
222
  link["target"]
@@ -214,11 +225,11 @@ module Vectory
214
225
  # Simplifies svgmap after processing.
215
226
  # Removes svgmap wrapper if no more target elements with eref.
216
227
  #
217
- # @param svgmap [Nokogiri::XML::Element] The svgmap element
228
+ # @param svgmap [Leptris::XML::Element] The svgmap element
218
229
  def simplify_svgmap(svgmap)
219
- return if svgmap.at(@namespace.ns("./target/eref"))
230
+ return if svgmap.at_xpath(@namespace.ns("./target/eref"))
220
231
 
221
- svgmap.replace(svgmap.at(@namespace.ns("./figure")))
232
+ svgmap.replace(svgmap.at_xpath(@namespace.ns("./figure")))
222
233
  end
223
234
  end
224
235
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Vectory
4
- VERSION = "0.12.0"
4
+ VERSION = "0.13.1"
5
5
  end
data/vectory.gemspec CHANGED
@@ -30,7 +30,7 @@ Gem::Specification.new do |spec|
30
30
  spec.add_dependency "emfsvg", "~> 0.1", ">= 0.1.2"
31
31
  spec.add_dependency "image_size", ">= 3.2.0"
32
32
  spec.add_dependency "marcel", "~> 1.0"
33
- spec.add_dependency "nokogiri", "~> 1.14"
33
+ spec.add_dependency "leptris", ">= 1.9.361.1"
34
34
  spec.add_dependency "postsvg", "~> 0.3"
35
35
  spec.add_dependency "thor", "~> 1.0"
36
36
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vectory
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.0
4
+ version: 0.13.1
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-07-27 00:00:00.000000000 Z
11
+ date: 2026-10-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: base64
@@ -73,19 +73,19 @@ dependencies:
73
73
  - !ruby/object:Gem::Version
74
74
  version: '1.0'
75
75
  - !ruby/object:Gem::Dependency
76
- name: nokogiri
76
+ name: leptris
77
77
  requirement: !ruby/object:Gem::Requirement
78
78
  requirements:
79
- - - "~>"
79
+ - - ">="
80
80
  - !ruby/object:Gem::Version
81
- version: '1.14'
81
+ version: 1.9.361.1
82
82
  type: :runtime
83
83
  prerelease: false
84
84
  version_requirements: !ruby/object:Gem::Requirement
85
85
  requirements:
86
- - - "~>"
86
+ - - ">="
87
87
  - !ruby/object:Gem::Version
88
- version: '1.14'
88
+ version: 1.9.361.1
89
89
  - !ruby/object:Gem::Dependency
90
90
  name: postsvg
91
91
  requirement: !ruby/object:Gem::Requirement