def get_metadata path
    format = Gem::Format.from_file_by_path path
    spec = format.spec

    metadata = nil

    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.gunzip entry.read
        end
      end
    end

    return spec, metadata
  end
#
Extracts the Gem::Specification and raw metadata from the .gem file at
+path+.