1
require 'rubygems/indexer'
4
# Construct the master Gem index file.
6
class Gem::Indexer::MasterIndexBuilder < Gem::Indexer::AbstractIndexBuilder
10
@index = Gem::SourceIndex.new
16
@file.puts "--- !ruby/object:#{@index.class}"
19
gems = @index.sort_by { |name, gemspec| gemspec.sort_obj }
20
gems.each do |name, gemspec|
21
yaml = gemspec.to_yaml.gsub(/^/, ' ')
22
yaml = yaml.sub(/\A ---/, '') # there's a needed extra ' ' here
23
@file.print " #{gemspec.original_name}:"
31
index_file_name = File.join @directory, @filename
33
compress index_file_name, "Z"
34
paranoid index_file_name, "#{index_file_name}.Z"
36
@files << "#{@filename}.Z"
45
def paranoid(path, compressed_path)
46
data = Gem.read_binary path
47
compressed_data = Gem.read_binary compressed_path
49
if data != unzip(compressed_data) then
50
raise "Compressed file #{compressed_path} does not match uncompressed file #{path}"