Module: Sumi::Sundries::Imprint
Overview
Converts SVG and declarations to PDFs through the native Toji CLI.
Constant Summary collapse
Instance Method Summary collapse
-
#available? ⇒ Boolean
Reports whether the Toji executable is installed on PATH.
-
#call(svg, output, declaration:, **options) {|svg| ... } ⇒ String
Produces and atomically replaces one PDF through the native CLI.
-
#fingerprint ⇒ Hash{String => Object}?
Returns the selected executable's content identity for output caches.
Instance Method Details
#available? ⇒ Boolean
Reports whether the Toji executable is installed on PATH.
20 |
# File 'sundries/lib/sumi/sundries/imprint.rb', line 20 def available? = F.executable?(COMMAND) |
#call(svg, output, declaration:, **options) {|svg| ... } ⇒ String
Produces and atomically replaces one PDF through the native CLI. Input paths and output staging remain private to this call.
57 58 59 60 61 62 |
# File 'sundries/lib/sumi/sundries/imprint.rb', line 57 def call(svg, output, declaration:, **, &block) ArgumentError.("Imprint declaration must be a Hash") unless declaration.is_a?(::Hash) unknown = .keys - %i[css dpi height width preview] ArgumentError.("Unknown Imprint option: #{unknown.first}") unless unknown.empty? Export.call(svg, output, format: :pdf, declaration:, fallback: false, **, &block) end |
#fingerprint ⇒ Hash{String => Object}?
Returns the selected executable's content identity for output caches. PATH is resolved on each call. Absence returns nil.
27 28 29 30 31 32 33 34 35 36 |
# File 'sundries/lib/sumi/sundries/imprint.rb', line 27 def fingerprint path = F.executable(COMMAND) return unless path process = run(path, "--version") report = JSON.parse(process.out) Error.("Invalid Toji version report") unless report.is_a?(Hash) && report["contract"] == 1 {"sha256" => Digest::SHA256.file(path).hexdigest, "runtime" => report} rescue JSON::ParserError => e Error.("Invalid Toji version report: #{e.}") end |