summaryrefslogtreecommitdiff
path: root/trunk/lib/rubygems/indexer/abstract_index_builder.rb
diff options
context:
space:
mode:
authoryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-08-25 15:13:14 +0000
committeryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-08-25 15:13:14 +0000
commitd0233291bc8a5068e52c69c210e5979e5324b5bc (patch)
tree7d9459449c33792c63eeb7baa071e76352e0baab /trunk/lib/rubygems/indexer/abstract_index_builder.rb
parent0dc342de848a642ecce8db697b8fecd83a63e117 (diff)
parent72eaacaa15256ab95c3b52ea386f88586fb9da40 (diff)
re-adding tag v1_9_0_4 as an alias of trunk@18848v1_9_0_4
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/tags/v1_9_0_4@18849 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'trunk/lib/rubygems/indexer/abstract_index_builder.rb')
-rw-r--r--trunk/lib/rubygems/indexer/abstract_index_builder.rb88
1 files changed, 0 insertions, 88 deletions
diff --git a/trunk/lib/rubygems/indexer/abstract_index_builder.rb b/trunk/lib/rubygems/indexer/abstract_index_builder.rb
deleted file mode 100644
index 5815dcda87..0000000000
--- a/trunk/lib/rubygems/indexer/abstract_index_builder.rb
+++ /dev/null
@@ -1,88 +0,0 @@
-require 'zlib'
-
-require 'rubygems/indexer'
-
-# Abstract base class for building gem indicies. Uses the template pattern
-# with subclass specialization in the +begin_index+, +end_index+ and +cleanup+
-# methods.
-class Gem::Indexer::AbstractIndexBuilder
-
- # Directory to put index files in
- attr_reader :directory
-
- # File name of the generated index
- attr_reader :filename
-
- # List of written files/directories to move into production
- attr_reader :files
-
- def initialize(filename, directory)
- @filename = filename
- @directory = directory
- @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 << @filename
-
- File.open file_path, "wb" do |file|
- @file = file
- start_index
- yield
- end_index
- end
-
- cleanup
- ensure
- @file = nil
- end
-
- ##
- # Compress the given file.
-
- def compress(filename, ext="rz")
- data = open filename, 'rb' do |fp| fp.read end
-
- zipped = zip data
-
- File.open "#{filename}.#{ext}", "wb" do |file|
- file.write zipped
- end
- end
-
- # Called immediately before the yield in build. The index file is open and
- # available as @file.
- def start_index
- end
-
- # Called immediately after the yield in build. The index file is still open
- # and available as @file.
- def end_index
- end
-
- # Called from within builder after the index file has been closed.
- def cleanup
- end
-
- # Return an uncompressed version of a compressed string.
- def unzip(string)
- Zlib::Inflate.inflate(string)
- end
-
- # Return a compressed version of the given string.
- def zip(string)
- Zlib::Deflate.deflate(string)
- end
-
-end
-