diff options
author | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-03-31 22:40:06 +0000 |
---|---|---|
committer | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-03-31 22:40:06 +0000 |
commit | 8cc45aae947d453acca029e13eb64f3f5f0bf942 (patch) | |
tree | f9485a20c99defe1aae3f32555a41d23c2298ad8 /lib/rubygems/indexer/abstract_index_builder.rb | |
parent | dc8359969ec71ece10357ba9396430db7f029e45 (diff) |
Import RubyGems 1.1.0
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15873 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rubygems/indexer/abstract_index_builder.rb')
-rw-r--r-- | lib/rubygems/indexer/abstract_index_builder.rb | 12 |
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 |