aboutsummaryrefslogtreecommitdiffstats
path: root/lib/rubygems/package/tar_reader.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rubygems/package/tar_reader.rb')
-rw-r--r--lib/rubygems/package/tar_reader.rb21
1 files changed, 20 insertions, 1 deletions
diff --git a/lib/rubygems/package/tar_reader.rb b/lib/rubygems/package/tar_reader.rb
index 4aa9c26cc9..1a2fbaf678 100644
--- a/lib/rubygems/package/tar_reader.rb
+++ b/lib/rubygems/package/tar_reader.rb
@@ -3,14 +3,21 @@
# See LICENSE.txt for additional licensing information.
#--
-require 'rubygems/package'
+##
+# TarReader reads tar files and allows iteration over their items
class Gem::Package::TarReader
include Gem::Package
+ ##
+ # Raised if the tar IO is not seekable
+
class UnexpectedEOF < StandardError; end
+ ##
+ # Creates a new TarReader on +io+ and yields it to the block, if given.
+
def self.new(io)
reader = super
@@ -25,14 +32,24 @@ class Gem::Package::TarReader
nil
end
+ ##
+ # Creates a new tar file reader on +io+ which needs to respond to #pos,
+ # #eof?, #read, #getc and #pos=
+
def initialize(io)
@io = io
@init_pos = io.pos
end
+ ##
+ # Close the tar file
+
def close
end
+ ##
+ # Iterates over files in the tarball yielding each entry
+
def each
loop do
return if @io.eof?
@@ -84,3 +101,5 @@ class Gem::Package::TarReader
end
+require 'rubygems/package/tar_reader/entry'
+