diff options
Diffstat (limited to 'lib/rubygems/package/tar_writer.rb')
-rw-r--r-- | lib/rubygems/package/tar_writer.rb | 47 |
1 files changed, 12 insertions, 35 deletions
diff --git a/lib/rubygems/package/tar_writer.rb b/lib/rubygems/package/tar_writer.rb index e1b38ad6b5..f2c11e3544 100644 --- a/lib/rubygems/package/tar_writer.rb +++ b/lib/rubygems/package/tar_writer.rb @@ -4,8 +4,6 @@ # See LICENSE.txt for additional licensing information. #++ -require 'digest' - ## # Allows writing of tar files @@ -123,8 +121,7 @@ class Gem::Package::TarWriter @io.pos = init_pos header = Gem::Package::TarHeader.new :name => name, :mode => mode, - :size => size, :prefix => prefix, - :mtime => Time.now + :size => size, :prefix => prefix @io.write header @io.pos = final_pos @@ -143,15 +140,7 @@ class Gem::Package::TarWriter 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 then - digest.name - else - /::([^:]+)$/ =~ digest_algorithm.name - $1 - end - - [digest_name, digest] + [digest.name, digest] end digests = Hash[*digests.flatten] @@ -176,32 +165,22 @@ class Gem::Package::TarWriter def add_file_signed name, mode, signer digest_algorithms = [ signer.digest_algorithm, - Digest::SHA512, - ].compact.uniq + OpenSSL::Digest::SHA512, + ].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 then - digest.name - else - /::([^:]+)$/ =~ digest.class.name - $1 - end - - digest_name == signer.digest_name + signature_digest = digests.values.find do |digest| + digest.name == signer.digest_name end - if signer.key then - signature = signer.sign signature_digest.digest + signature = signer.sign signature_digest.digest - add_file_simple "#{name}.sig", 0444, signature.length do |io| - io.write signature - end - end + add_file_simple "#{name}.sig", 0444, signature.length do |io| + io.write signature + end if signature digests end @@ -216,8 +195,7 @@ class Gem::Package::TarWriter name, prefix = split_name name header = Gem::Package::TarHeader.new(:name => name, :mode => mode, - :size => size, :prefix => prefix, - :mtime => Time.now).to_s + :size => size, :prefix => prefix).to_s @io.write header os = BoundedStream.new @io, size @@ -278,8 +256,7 @@ class Gem::Package::TarWriter header = Gem::Package::TarHeader.new :name => name, :mode => mode, :typeflag => "5", :size => 0, - :prefix => prefix, - :mtime => Time.now + :prefix => prefix @io.write header |