Geminstaller C0 Coverage Information - RCov

spec/fixture/rubygems_dist/rubygems-trunk/lib/rubygems/package/tar_reader/entry.rb

Name Total Lines Lines of Code Total Coverage Code Coverage
spec/fixture/rubygems_dist/rubygems-trunk/lib/rubygems/package/tar_reader/entry.rb 140 65
77.86%
64.62%

Key

Code reported as executed by Ruby looks like this...and this: this line is also marked as covered.Lines considered as run by rcov, but not reported by Ruby, look like this,and this: these lines were inferred by rcov (using simple heuristics).Finally, here's a line marked as not executed.

Coverage Details

1 #++
2 # Copyright (C) 2004 Mauricio Julio Fernández Pradier
3 # See LICENSE.txt for additional licensing information.
4 #--
5 
6 ##
7 # Class for reading entries out of a tar file
8 
9 class Gem::Package::TarReader::Entry
10 
11   ##
12   # Header for this tar entry
13 
14   attr_reader :header
15 
16   ##
17   # Creates a new tar entry for +header+ that will be read from +io+
18 
19   def initialize(header, io)
20     @closed = false
21     @header = header
22     @io = io
23     @orig_pos = @io.pos
24     @read = 0
25   end
26 
27   def check_closed # :nodoc:
28     raise IOError, "closed #{self.class}" if closed?
29   end
30 
31   ##
32   # Number of bytes read out of the tar entry
33 
34   def bytes_read
35     @read
36   end
37 
38   ##
39   # Closes the tar entry
40 
41   def close
42     @closed = true
43   end
44 
45   ##
46   # Is the tar entry closed?
47 
48   def closed?
49     @closed
50   end
51 
52   ##
53   # Are we at the end of the tar entry?
54 
55   def eof?
56     check_closed
57 
58     @read >= @header.size
59   end
60 
61   ##
62   # Full name of the tar entry
63 
64   def full_name
65     if @header.prefix != "" then
66       File.join @header.prefix, @header.name
67     else
68       @header.name
69     end
70   end
71 
72   ##
73   # Read one byte from the tar entry
74 
75   def getc
76     check_closed
77 
78     return nil if @read >= @header.size
79 
80     ret = @io.getc
81     @read += 1 if ret
82 
83     ret
84   end
85 
86   ##
87   # Is this tar entry a directory?
88 
89   def directory?
90     @header.typeflag == "5"
91   end
92 
93   ##
94   # Is this tar entry a file?
95 
96   def file?
97     @header.typeflag == "0"
98   end
99 
100   ##
101   # The position in the tar entry
102 
103   def pos
104     check_closed
105 
106     bytes_read
107   end
108 
109   ##
110   # Reads +len+ bytes from the tar file entry, or the rest of the entry if
111   # nil
112 
113   def read(len = nil)
114     check_closed
115 
116     return nil if @read >= @header.size
117 
118     len ||= @header.size - @read
119     max_read = [len, @header.size - @read].min
120 
121     ret = @io.read max_read
122     @read += ret.size
123 
124     ret
125   end
126 
127   ##
128   # Rewinds to the beginning of the tar file entry
129 
130   def rewind
131     check_closed
132 
133     raise Gem::Package::NonSeekableIO unless @io.respond_to? :pos=
134 
135     @io.pos = @orig_pos
136     @read = 0
137   end
138 
139 end
140 

Generated on Mon May 10 23:40:28 -0700 2010 with rcov 0.9.8