instance method
Gem::Package::TarWriter#add_file_signed
add_file_signed(name, mode, signer) { |io| ... }
lib/rubygems/package/tar_writer.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.0.0/lib/rubygems/package/tar_writer.rb, line 170
def add_file_signed(name, mode, signer)
digest_algorithms = [
signer.digest_algorithm,
Gem::Security.create_digest("SHA512"),
].compact.uniq
digests = add_file_digest name, mode, digest_algorithms do |io|
yield io
end
signature_digest = digests.values.compact.find do |digest|
digest_name =
if digest.respond_to? :name
digest.name
else
digest.class.name[/::([^:]+)\z/, 1]
end
digest_name == signer.digest_name
end
raise "no #{signer.digest_name} in #{digests.values.compact}" unless signature_digest
if signer.key
signature = signer.sign signature_digest.digest
add_file_simple "#{name}.sig", 0o444, signature.length do |io|
io.write signature
end
end
digests
end
Adds name with permissions mode to the tar, yielding io for writing the file. The signer is used to add a digest file using its digest_algorithm per add_file_digest and a cryptographic signature in name.sig. If the signer has no key only the checksum file is added.
Returns the digest.
See also
#add_file_digest
#add_file_simple
#add_file
#add_symlink
also in
4.1 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0