2007-11-10 02:48:56 -05:00
|
|
|
require 'rubygems/indexer'
|
|
|
|
|
2008-03-31 18:40:06 -04:00
|
|
|
##
|
2007-11-10 02:48:56 -05:00
|
|
|
# Construct a quick index file and all of the individual specs to support
|
|
|
|
# incremental loading.
|
2008-03-31 18:40:06 -04:00
|
|
|
|
2007-11-10 02:48:56 -05:00
|
|
|
class Gem::Indexer::QuickIndexBuilder < Gem::Indexer::AbstractIndexBuilder
|
|
|
|
|
|
|
|
def initialize(filename, directory)
|
|
|
|
directory = File.join directory, 'quick'
|
|
|
|
|
|
|
|
super filename, directory
|
|
|
|
end
|
|
|
|
|
|
|
|
def cleanup
|
|
|
|
super
|
|
|
|
|
2008-03-31 18:40:06 -04:00
|
|
|
quick_index_file = File.join @directory, @filename
|
2007-11-10 02:48:56 -05:00
|
|
|
compress quick_index_file
|
|
|
|
|
|
|
|
# the complete quick index is in a directory, so move it as a whole
|
2008-03-31 18:40:06 -04:00
|
|
|
@files.delete 'index'
|
|
|
|
@files << 'quick'
|
2007-11-10 02:48:56 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def add(spec)
|
2007-11-20 00:56:43 -05:00
|
|
|
@file.puts spec.original_name
|
2007-11-10 02:48:56 -05:00
|
|
|
add_yaml(spec)
|
|
|
|
add_marshal(spec)
|
|
|
|
end
|
|
|
|
|
|
|
|
def add_yaml(spec)
|
2007-11-20 00:56:43 -05:00
|
|
|
fn = File.join @directory, "#{spec.original_name}.gemspec.rz"
|
2007-11-10 02:48:56 -05:00
|
|
|
zipped = zip spec.to_yaml
|
|
|
|
File.open fn, "wb" do |gsfile| gsfile.write zipped end
|
|
|
|
end
|
|
|
|
|
|
|
|
def add_marshal(spec)
|
|
|
|
# HACK why does this not work in #initialize?
|
|
|
|
FileUtils.mkdir_p File.join(@directory, "Marshal.#{Gem.marshal_version}")
|
|
|
|
|
|
|
|
fn = File.join @directory, "Marshal.#{Gem.marshal_version}",
|
2007-11-20 00:56:43 -05:00
|
|
|
"#{spec.original_name}.gemspec.rz"
|
2007-11-10 02:48:56 -05:00
|
|
|
|
|
|
|
zipped = zip Marshal.dump(spec)
|
|
|
|
File.open fn, "wb" do |gsfile| gsfile.write zipped end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|