mirror of
https://github.com/ruby/ruby.git
synced 2025-08-24 21:44:30 +02:00
parent
8103d46a4d
commit
688ccc9602
3 changed files with 54 additions and 30 deletions
|
@ -85,7 +85,7 @@ command help for an example.
|
|||
end
|
||||
|
||||
if @options[:spec]
|
||||
spec, metadata = get_metadata path, security_policy
|
||||
spec, metadata = Gem::Package.metadata(path, security_policy)
|
||||
|
||||
if metadata.nil?
|
||||
alert_error "--spec is unsupported on '#{name}' (old format gem)"
|
||||
|
@ -173,32 +173,4 @@ command help for an example.
|
|||
|
||||
path
|
||||
end
|
||||
|
||||
##
|
||||
# Extracts the Gem::Specification and raw metadata from the .gem file at
|
||||
# +path+.
|
||||
#--
|
||||
# TODO move to Gem::Package as #raw_spec or something
|
||||
|
||||
def get_metadata(path, security_policy = nil)
|
||||
format = Gem::Package.new path, security_policy
|
||||
spec = format.spec
|
||||
|
||||
metadata = nil
|
||||
|
||||
File.open path, Gem.binary_mode do |io|
|
||||
tar = Gem::Package::TarReader.new io
|
||||
tar.each_entry do |entry|
|
||||
case entry.full_name
|
||||
when 'metadata' then
|
||||
metadata = entry.read
|
||||
when 'metadata.gz' then
|
||||
metadata = Gem::Util.gunzip entry.read
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return spec, metadata
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue