aboutsummaryrefslogtreecommitdiffstats
path: root/lib/rubygems/indexer/abstract_index_builder.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rubygems/indexer/abstract_index_builder.rb')
-rw-r--r--lib/rubygems/indexer/abstract_index_builder.rb12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/rubygems/indexer/abstract_index_builder.rb b/lib/rubygems/indexer/abstract_index_builder.rb
index f25f21707b..5815dcda87 100644
--- a/lib/rubygems/indexer/abstract_index_builder.rb
+++ b/lib/rubygems/indexer/abstract_index_builder.rb
@@ -22,16 +22,18 @@ class Gem::Indexer::AbstractIndexBuilder
@files = []
end
+ ##
# Build a Gem index. Yields to block to handle the details of the
# actual building. Calls +begin_index+, +end_index+ and +cleanup+ at
# appropriate times to customize basic operations.
+
def build
FileUtils.mkdir_p @directory unless File.exist? @directory
raise "not a directory: #{@directory}" unless File.directory? @directory
file_path = File.join @directory, @filename
- @files << file_path
+ @files << @filename
File.open file_path, "wb" do |file|
@file = file
@@ -39,14 +41,20 @@ class Gem::Indexer::AbstractIndexBuilder
yield
end_index
end
+
cleanup
ensure
@file = nil
end
+ ##
# Compress the given file.
+
def compress(filename, ext="rz")
- zipped = zip(File.open(filename, 'rb'){ |fp| fp.read })
+ data = open filename, 'rb' do |fp| fp.read end
+
+ zipped = zip data
+
File.open "#{filename}.#{ext}", "wb" do |file|
file.write zipped
end