vectory 0.13.2 → 0.13.4

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.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Vectory
4
- VERSION = "0.13.2"
4
+ VERSION = "0.13.4"
5
5
  end
data/lib/vectory.rb CHANGED
@@ -15,13 +15,11 @@ module Vectory
15
15
  class NotWrittenToDiskError < Error; end
16
16
 
17
17
  class ParsingError < Error; end
18
- end
19
18
 
20
- require_relative "vectory/errors"
21
- require_relative "vectory/version"
19
+ require_relative "vectory/errors"
20
+ require_relative "vectory/version"
22
21
 
23
- # Lazy load: all other internal Vectory dependencies via autoload
24
- module Vectory
22
+ # Lazy load: all other internal Vectory dependencies via autoload
25
23
  # Core utilities
26
24
  autoload :Utils, "vectory/utils"
27
25
 
@@ -34,15 +32,21 @@ module Vectory
34
32
  autoload :Eps, "vectory/eps"
35
33
  autoload :Ps, "vectory/ps"
36
34
  autoload :Emf, "vectory/emf"
35
+ autoload :Png, "vectory/png"
36
+ autoload :PngRenderer, "vectory/png_renderer"
37
+ autoload :SvgInputPolicy, "vectory/svg_input_policy"
37
38
  autoload :Svg, "vectory/svg"
38
39
  autoload :SvgMapping, "vectory/svg_mapping"
39
40
  autoload :SvgDocument, "vectory/svg_document"
40
41
  autoload :SvgIdDisambiguator, "vectory/svg_id_disambiguator"
42
+ autoload :SvgClassSuffixer, "vectory/svg_class_suffixer"
43
+ autoload :SvgNamespaceBinding, "vectory/svg_namespace_binding"
44
+ autoload :SvgSubtreeGraft, "vectory/svg_subtree_graft"
45
+ autoload :SvgTransform, "vectory/svg_transform"
46
+ autoload :SvgTransformPipeline, "vectory/svg_transform_pipeline"
41
47
  autoload :FileMagic, "vectory/file_magic"
42
- end
43
48
 
44
- # Define additional module methods
45
- module Vectory
49
+ # Define additional module methods
46
50
  def self.ui
47
51
  @ui ||= Logger.new($stdout).tap do |logger|
48
52
  logger.level = ENV["VECTORY_LOG"] || Logger::WARN
@@ -0,0 +1,235 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "digest"
5
+ require "fileutils"
6
+ require "json"
7
+ require "open3"
8
+ require "optparse"
9
+ require "rbconfig"
10
+ require "rubygems/package"
11
+ require "tmpdir"
12
+
13
+ # Uses real packaged gems and Bundler. The selection phase simulates an unsupported
14
+ # platform for svgpng alone; the downstream phase runs on the actual host.
15
+ class PngShellCheck
16
+ TARGETS = %w[arm64-darwin x86_64-darwin x86_64-linux aarch64-linux
17
+ x86_64-linux-musl aarch64-linux-musl x64-mingw-ucrt ruby].freeze
18
+
19
+ def initialize(options)
20
+ @options = options
21
+ @root = File.expand_path("..", __dir__)
22
+ @bundler = Gem.bin_path("bundler", "bundle")
23
+ end
24
+
25
+ def run
26
+ shell = File.expand_path(@options.fetch(:shell))
27
+ verify_package(shell, "ruby", @options.fetch(:sha256))
28
+ packages = @options[:shell_only] ? [shell] : release_packages(shell)
29
+ Dir.mktmpdir("vectory-png-shell-") do |directory|
30
+ check_selection(directory, packages) unless @options[:shell_only]
31
+ selection_notice if @options[:shell_only]
32
+ check_downstream(directory, shell)
33
+ end
34
+ report_success(shell)
35
+ end
36
+
37
+ private
38
+
39
+ def selection_notice
40
+ puts "SELECTION NOT RUN (--shell-only); unsupported-platform resolution remains unproven"
41
+ end
42
+
43
+ def report_success(shell)
44
+ puts "PASS real shell downstream; host=#{Gem::Platform.local}; shell_sha256=#{Digest::SHA256.file(shell).hexdigest}"
45
+ end
46
+
47
+ def verify_digest(path, digest)
48
+ raise "Missing artifact: #{path}" unless File.file?(path)
49
+ raise "SHA256 mismatch: #{path}" unless Digest::SHA256.file(path).hexdigest == digest
50
+ end
51
+
52
+ def verify_package(path, target, digest)
53
+ verify_digest(path, digest)
54
+ spec = Gem::Package.new(path).spec
55
+ return if spec.name == "svgpng" && spec.version.to_s == "0.1.0" && spec.platform.to_s == target
56
+
57
+ raise "Wrong package metadata: #{path} (#{spec.full_name})"
58
+ end
59
+
60
+ def release_packages(shell)
61
+ directory = File.expand_path(@options.fetch(:release_set))
62
+ manifest = JSON.parse(File.read(File.join(directory, "checksums.json")))
63
+ entries = manifest_entries(manifest)
64
+ entries.map { |entry| release_package(directory, entry, shell) }
65
+ end
66
+
67
+ def manifest_entries(manifest)
68
+ entries = manifest.fetch("artifacts")
69
+ unless manifest["schema_version"] == 1 && manifest["version"] == "0.1.0" &&
70
+ entries.map { |entry| entry.fetch("target") }.sort == TARGETS.sort
71
+ raise "checksums.json must identify exactly the eight 0.1.0 packages"
72
+ end
73
+
74
+ entries
75
+ end
76
+
77
+ def release_package(directory, entry, shell)
78
+ target = entry.fetch("target")
79
+ expected = target == "ruby" ? "svgpng-0.1.0.gem" : "svgpng-0.1.0-#{target}.gem"
80
+ raise "Unexpected artifact filename" unless entry.fetch("path") == expected
81
+
82
+ path = File.join(directory, expected)
83
+ verify_package(path, target, entry.fetch("sha256"))
84
+ verify_same_shell(path, shell) if target == "ruby"
85
+ path
86
+ end
87
+
88
+ def verify_same_shell(path, shell)
89
+ return if Digest::SHA256.file(path).hexdigest == Digest::SHA256.file(shell).hexdigest
90
+
91
+ raise "Downstream shell differs from full-set shell"
92
+ end
93
+
94
+ def bundle_environment(directory)
95
+ environment = ENV.keys.grep(/\ABUNDLE(?:R)?_/).to_h { |key| [key, nil] }
96
+ environment.merge("BUNDLE_GEMFILE" => File.join(directory, "Gemfile"),
97
+ "BUNDLE_IGNORE_CONFIG" => "true", "BUNDLE_PATH__SYSTEM" => "true", "RUBYOPT" => nil,
98
+ "GEM_HOME" => File.join(directory, "gems"),
99
+ "GEM_PATH" => [File.join(directory, "gems"), Gem.default_dir].join(File::PATH_SEPARATOR))
100
+ end
101
+
102
+ def prepare_bundle(directory, packages, gemfile)
103
+ FileUtils.mkdir_p(File.join(directory, "vendor", "cache"))
104
+ packages.each { |path| FileUtils.cp(path, File.join(directory, "vendor", "cache")) }
105
+ File.write(File.join(directory, "Gemfile"), gemfile)
106
+ seed_dependencies(File.join(directory, "gems"))
107
+ bundle_environment(directory)
108
+ end
109
+
110
+ # Reuse installed dependencies without builds or writes to the caller's gem home.
111
+ # svgpng is deliberately excluded so Bundler must install the supplied package.
112
+ def seed_dependencies(home)
113
+ Gem::Specification.each do |spec|
114
+ next if spec.name == "svgpng" || spec.name == "vectory" || spec.default_gem?
115
+
116
+ link_dependency(home, spec)
117
+ end
118
+ end
119
+
120
+ def link_dependency(home, spec)
121
+ FileUtils.mkdir_p([File.join(home, "specifications"), File.join(home, "gems")])
122
+ File.write(File.join(home, "specifications", "#{spec.full_name}.gemspec"), spec.to_ruby)
123
+ File.symlink(spec.full_gem_path, File.join(home, "gems", spec.full_name))
124
+ link_extension(home, spec) unless spec.extensions.empty?
125
+ end
126
+
127
+ def link_extension(home, spec)
128
+ extension = File.join(home, "extensions", Gem::Platform.local.to_s, Gem.extension_api_version, spec.full_name)
129
+ FileUtils.mkdir_p(File.dirname(extension))
130
+ File.symlink(spec.extension_dir, extension)
131
+ end
132
+
133
+ def execute(environment, directory, *arguments, expected: 0)
134
+ stdout, stderr, result = Open3.capture3(environment, RbConfig.ruby, *arguments, chdir: directory)
135
+ unless result.exitstatus == expected
136
+ raise "Command failed (expected #{expected}, got #{result.exitstatus}): #{arguments.join(' ')}\n#{stdout}#{stderr}"
137
+ end
138
+
139
+ [stdout, stderr]
140
+ end
141
+
142
+ def check_selection(directory, packages)
143
+ location = File.join(directory, "selection")
144
+ environment = prepare_bundle(location, packages, <<~GEMFILE)
145
+ source "https://rubygems.org"
146
+ gem "svgpng", "= 0.1.0"
147
+ GEMFILE
148
+ # An isolated Gemfile avoids pretending Vectory's unrelated native dependencies
149
+ # are installable on this synthetic platform. Bundler still resolves real gems.
150
+ launcher = <<~RUBY
151
+ require "rubygems"
152
+ unsupported = Gem::Platform.new("universal-unsupportedos")
153
+ Gem::Platform.define_singleton_method(:local) { unsupported }
154
+ Gem.platforms = [Gem::Platform::RUBY, unsupported]
155
+ load #{@bundler.inspect}
156
+ RUBY
157
+ File.write(File.join(location, "unsupported_bundle.rb"), launcher)
158
+ execute(environment, location, "unsupported_bundle.rb", "install", "--local", "--no-cache", "--quiet")
159
+ assert_shell(environment, location)
160
+ puts "PASS simulated unsupported-platform Bundler selection from eight checksummed packages (not an actual unsupported OS)"
161
+ end
162
+
163
+ def assert_shell(environment, directory)
164
+ execute(environment, directory, @bundler, "exec", "ruby", "-e", <<~RUBY)
165
+ require "svgpng"
166
+ spec = Gem.loaded_specs.fetch("svgpng")
167
+ abort "Bundler selected a native svgpng package" unless spec.platform.to_s == "ruby"
168
+ abort "Bundler used an external svgpng installation" unless File.realpath(spec.full_gem_path).start_with?(#{File.realpath(File.join(directory, 'gems', 'gems')).inspect})
169
+ require "digest"
170
+ abort "Installed shell checksum mismatch" unless Digest::SHA256.file(spec.cache_file).hexdigest == #{@options.fetch(:sha256).inspect}
171
+ begin
172
+ Svgpng.render('<svg xmlns="http://www.w3.org/2000/svg" width="2" height="1"/>',
173
+ profile: {}, fonts: {}, fallback_fonts: [])
174
+ abort "Ruby shell unexpectedly rendered"
175
+ rescue Svgpng::UnsupportedPlatformError
176
+ puts "actual shell UnsupportedPlatformError"
177
+ end
178
+ RUBY
179
+ end
180
+
181
+ def check_downstream(directory, shell)
182
+ location = File.join(directory, "downstream")
183
+ environment = prepare_bundle(location, [shell], <<~GEMFILE)
184
+ source "https://rubygems.org"
185
+ gem "vectory", path: #{@root.inspect}
186
+ gem "svgpng", "= 0.1.0", force_ruby_platform: true
187
+ GEMFILE
188
+ execute(environment, location, @bundler, "install", "--local", "--no-cache", "--quiet")
189
+ assert_shell(environment, location)
190
+ File.write(File.join(location, "input.eps"), <<~POSTSCRIPT)
191
+ %!PS-Adobe-3.0 EPSF-3.0
192
+ %%BoundingBox: 0 0 2 1
193
+ newpath 0 0 moveto 2 0 lineto 2 1 lineto closepath fill
194
+ showpage
195
+ POSTSCRIPT
196
+ check_conversions(environment, location)
197
+ end
198
+
199
+ def check_conversions(environment, location)
200
+ cli = File.join(@root, "exe", "vectory")
201
+ execute(environment, location, @bundler, "exec", "ruby", cli,
202
+ "convert", "input.eps", "--format", "svg", "--output", "output.svg")
203
+ svg = File.join(location, "output.svg")
204
+ raise "Non-PNG conversion produced no SVG" unless File.read(svg).include?("<svg")
205
+
206
+ stdout, stderr = execute(environment, location, @bundler, "exec", "ruby", cli,
207
+ "convert", "output.svg", "--format", "png", "--output", "output.png", expected: 5)
208
+ raise "PNG failure did not identify unsupported platform: #{stdout}#{stderr}" unless (stdout + stderr).include?("No packaged SVGPNG renderer")
209
+ raise "Failed PNG conversion wrote output" if File.exist?(File.join(location, "output.png"))
210
+
211
+ puts "PASS actual EPS→SVG conversion; actual SVG→PNG shell failure exits 5 without output"
212
+ end
213
+ end
214
+
215
+ options = {}
216
+ parser = OptionParser.new do |opts|
217
+ opts.banner = "Usage: script/check_png_shell --shell GEM --sha256 SHA [--release-set DIR | --shell-only]"
218
+ opts.on("--shell GEM", "Real svgpng 0.1.0 ruby package") { |value| options[:shell] = value }
219
+ opts.on("--sha256 SHA", "Expected shell SHA256") { |value| options[:sha256] = value }
220
+ opts.on("--release-set DIR", "Full eight-package set with checksums.json") { |value| options[:release_set] = value }
221
+ opts.on("--shell-only", "Run downstream behavior only; selection remains unproven") { options[:shell_only] = true }
222
+ end
223
+
224
+ begin
225
+ parser.parse!
226
+ raise OptionParser::MissingArgument, "--shell and --sha256 are required" unless options[:shell] && options[:sha256]
227
+ unless options[:shell_only] || options[:release_set]
228
+ raise OptionParser::MissingArgument, "--release-set required for selection; use --shell-only explicitly for partial evidence"
229
+ end
230
+
231
+ PngShellCheck.new(options).run
232
+ rescue StandardError => e
233
+ warn "FAIL: #{e.message}"
234
+ exit 1
235
+ end
data/vectory.gemspec CHANGED
@@ -11,11 +11,15 @@ Gem::Specification.new do |spec|
11
11
  spec.summary = "Pairwise vector image conversions."
12
12
  spec.description = <<~DESCRIPTION
13
13
  Vectory performs pairwise vector image conversions for common
14
- vector image formats, such as SVG, EMF, EPS and PS.
14
+ vector image formats, such as SVG, EMF, EPS and PS, with PNG output via
15
+ svgpng prebuilt native packages on arm64-darwin, x86_64-darwin, x86_64-linux,
16
+ aarch64-linux, x86_64-linux-musl, aarch64-linux-musl and x64-mingw-ucrt. Its portable
17
+ shell package preserves installation elsewhere and reports unsupported PNG output.
15
18
  DESCRIPTION
16
19
 
17
20
  spec.homepage = "https://github.com/metanorma/vectory"
18
21
  spec.license = "BSD-2-Clause"
22
+ spec.metadata["rubygems_mfa_required"] = "true"
19
23
 
20
24
  spec.bindir = "exe"
21
25
  spec.executables = ["vectory"]
@@ -23,14 +27,16 @@ Gem::Specification.new do |spec|
23
27
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
24
28
  f.match(%r{^(bin|spec|TODO\.[^/]+)/})
25
29
  end
26
- spec.test_files = `git ls-files -- {spec}/*`.split("\n")
27
30
  spec.required_ruby_version = ">= 3.1.0"
28
31
 
29
32
  spec.add_dependency "base64"
33
+ spec.add_dependency "crass", "~> 1.0", ">= 1.0.7"
30
34
  spec.add_dependency "emfsvg", "~> 0.1", ">= 0.1.2"
31
35
  spec.add_dependency "image_size", ">= 3.2.0"
36
+ spec.add_dependency "leptris", "~> 1.9.399"
32
37
  spec.add_dependency "marcel", "~> 1.0"
33
- spec.add_dependency "leptris", ">= 1.9.361.1"
34
38
  spec.add_dependency "postsvg", "~> 0.3"
39
+ spec.add_dependency "svgpng", "~> 0.1.0"
35
40
  spec.add_dependency "thor", "~> 1.0"
41
+ spec.add_dependency "yeptris", "~> 0.6.56.1"
36
42
  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.13.2
4
+ version: 0.13.4
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-10-23 00:00:00.000000000 Z
11
+ date: 2026-11-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: base64
@@ -24,6 +24,26 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: crass
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.0'
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: 1.0.7
37
+ type: :runtime
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - "~>"
42
+ - !ruby/object:Gem::Version
43
+ version: '1.0'
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: 1.0.7
27
47
  - !ruby/object:Gem::Dependency
28
48
  name: emfsvg
29
49
  requirement: !ruby/object:Gem::Requirement
@@ -59,33 +79,33 @@ dependencies:
59
79
  - !ruby/object:Gem::Version
60
80
  version: 3.2.0
61
81
  - !ruby/object:Gem::Dependency
62
- name: marcel
82
+ name: leptris
63
83
  requirement: !ruby/object:Gem::Requirement
64
84
  requirements:
65
85
  - - "~>"
66
86
  - !ruby/object:Gem::Version
67
- version: '1.0'
87
+ version: 1.9.399
68
88
  type: :runtime
69
89
  prerelease: false
70
90
  version_requirements: !ruby/object:Gem::Requirement
71
91
  requirements:
72
92
  - - "~>"
73
93
  - !ruby/object:Gem::Version
74
- version: '1.0'
94
+ version: 1.9.399
75
95
  - !ruby/object:Gem::Dependency
76
- name: leptris
96
+ name: marcel
77
97
  requirement: !ruby/object:Gem::Requirement
78
98
  requirements:
79
- - - ">="
99
+ - - "~>"
80
100
  - !ruby/object:Gem::Version
81
- version: 1.9.361.1
101
+ version: '1.0'
82
102
  type: :runtime
83
103
  prerelease: false
84
104
  version_requirements: !ruby/object:Gem::Requirement
85
105
  requirements:
86
- - - ">="
106
+ - - "~>"
87
107
  - !ruby/object:Gem::Version
88
- version: 1.9.361.1
108
+ version: '1.0'
89
109
  - !ruby/object:Gem::Dependency
90
110
  name: postsvg
91
111
  requirement: !ruby/object:Gem::Requirement
@@ -100,6 +120,20 @@ dependencies:
100
120
  - - "~>"
101
121
  - !ruby/object:Gem::Version
102
122
  version: '0.3'
123
+ - !ruby/object:Gem::Dependency
124
+ name: svgpng
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
103
137
  - !ruby/object:Gem::Dependency
104
138
  name: thor
105
139
  requirement: !ruby/object:Gem::Requirement
@@ -114,9 +148,26 @@ dependencies:
114
148
  - - "~>"
115
149
  - !ruby/object:Gem::Version
116
150
  version: '1.0'
151
+ - !ruby/object:Gem::Dependency
152
+ name: yeptris
153
+ requirement: !ruby/object:Gem::Requirement
154
+ requirements:
155
+ - - "~>"
156
+ - !ruby/object:Gem::Version
157
+ version: 0.6.56.1
158
+ type: :runtime
159
+ prerelease: false
160
+ version_requirements: !ruby/object:Gem::Requirement
161
+ requirements:
162
+ - - "~>"
163
+ - !ruby/object:Gem::Version
164
+ version: 0.6.56.1
117
165
  description: |
118
166
  Vectory performs pairwise vector image conversions for common
119
- vector image formats, such as SVG, EMF, EPS and PS.
167
+ vector image formats, such as SVG, EMF, EPS and PS, with PNG output via
168
+ svgpng prebuilt native packages on arm64-darwin, x86_64-darwin, x86_64-linux,
169
+ aarch64-linux, x86_64-linux-musl, aarch64-linux-musl and x64-mingw-ucrt. Its portable
170
+ shell package preserves installation elsewhere and reports unsupported PNG output.
120
171
  email:
121
172
  - open.source@ribose.com
122
173
  executables:
@@ -165,21 +216,32 @@ files:
165
216
  - lib/vectory/file_magic.rb
166
217
  - lib/vectory/image.rb
167
218
  - lib/vectory/image_resize.rb
219
+ - lib/vectory/png.rb
220
+ - lib/vectory/png_options.rb
221
+ - lib/vectory/png_renderer.rb
168
222
  - lib/vectory/ps.rb
169
223
  - lib/vectory/svg.rb
224
+ - lib/vectory/svg_class_suffixer.rb
170
225
  - lib/vectory/svg_document.rb
171
226
  - lib/vectory/svg_id_disambiguator.rb
227
+ - lib/vectory/svg_input_policy.rb
172
228
  - lib/vectory/svg_mapping.rb
229
+ - lib/vectory/svg_namespace_binding.rb
230
+ - lib/vectory/svg_subtree_graft.rb
231
+ - lib/vectory/svg_transform.rb
232
+ - lib/vectory/svg_transform_pipeline.rb
173
233
  - lib/vectory/utils.rb
174
234
  - lib/vectory/vector.rb
175
235
  - lib/vectory/version.rb
236
+ - script/check_png_shell
176
237
  - scripts/regenerate_fixtures.rb
177
238
  - tmp/.keep
178
239
  - vectory.gemspec
179
240
  homepage: https://github.com/metanorma/vectory
180
241
  licenses:
181
242
  - BSD-2-Clause
182
- metadata: {}
243
+ metadata:
244
+ rubygems_mfa_required: 'true'
183
245
  post_install_message:
184
246
  rdoc_options: []
185
247
  require_paths: