aboutsummaryrefslogtreecommitdiffstats
path: root/lib/rubygems/indexer/master_index_builder.rb
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-11-10 07:48:56 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-11-10 07:48:56 +0000
commitfbf59bdbea63efd34ccc144e648467d2f52e7345 (patch)
tree244f0e7ae112cc7dd135e5d1ac24e6c70ba71b4a /lib/rubygems/indexer/master_index_builder.rb
parent7a4aad75356496559460041a6c063bdb736c7236 (diff)
downloadruby-fbf59bdbea63efd34ccc144e648467d2f52e7345.tar.gz
Import RubyGems trunk revision 1493.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13862 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rubygems/indexer/master_index_builder.rb')
-rw-r--r--lib/rubygems/indexer/master_index_builder.rb44
1 files changed, 44 insertions, 0 deletions
diff --git a/lib/rubygems/indexer/master_index_builder.rb b/lib/rubygems/indexer/master_index_builder.rb
new file mode 100644
index 0000000000..f435c44e41
--- /dev/null
+++ b/lib/rubygems/indexer/master_index_builder.rb
@@ -0,0 +1,44 @@
+require 'rubygems/indexer'
+
+# Construct the master Gem index file.
+class Gem::Indexer::MasterIndexBuilder < Gem::Indexer::AbstractIndexBuilder
+
+ def start_index
+ super
+ @index = Gem::SourceIndex.new
+ end
+
+ def end_index
+ super
+ @file.puts @index.to_yaml
+ end
+
+ def cleanup
+ super
+
+ index_file_name = File.join @directory, @filename
+
+ compress index_file_name, "Z"
+ compressed_file_name = "#{index_file_name}.Z"
+
+ paranoid index_file_name, compressed_file_name
+
+ @files << compressed_file_name
+ end
+
+ def add(spec)
+ @index.add_spec(spec)
+ end
+
+ private
+
+ def paranoid(fn, compressed_fn)
+ data = File.open(fn, 'rb') do |fp| fp.read end
+ compressed_data = File.open(compressed_fn, 'rb') do |fp| fp.read end
+
+ if data != unzip(compressed_data) then
+ fail "Compressed file #{compressed_fn} does not match uncompressed file #{fn}"
+ end
+ end
+
+end