End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
instance method
Gem::Package::TarWriter#add_file_digest
add_file_digest(name, mode, digest_algorithms) { |io| ... }
lib/rubygems/package/tar_writer.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.0.5/lib/rubygems/package/tar_writer.rb, line 134
def add_file_digest(name, mode, digest_algorithms) # :yields: io
digests = digest_algorithms.map do |digest_algorithm|
digest = digest_algorithm.new
digest_name =
if digest.respond_to? :name
digest.name
else
digest_algorithm.class.name[/::([^:]+)\z/, 1]
end
[digest_name, digest]
end
digests = Hash[*digests.flatten]
add_file name, mode do |io|
Gem::Package::DigestIO.wrap io, digests do |digest_io|
yield digest_io
end
end
digests
end
Adds name with permissions mode to the tar, yielding io for writing the file. The digest_algorithm is written to a read-only name.sum file following the given file contents containing the digest name and hexdigest separated by a tab.
The created digest object is returned.