File Coverage

blib/lib/Archive/Tar/Streamed.pm
Criterion Covered Total %
statement 34 34 100.0
branch 3 4 75.0
condition 2 2 100.0
subroutine 10 10 100.0
pod 2 4 50.0
total 51 54 94.4


line stmt bran cond sub pod time code
1              
2             package Archive::Tar::Streamed;
3 5     5   273632 use strict;
  5         11  
  5         427  
4              
5             BEGIN {
6 5     5   29 use vars qw ($VERSION @ISA);
  5         9  
  5         354  
7 5     5   110 $VERSION = 0.03;
8             }
9              
10 5     5   27822 use Archive::Tar;
  5         1378102  
  5         490  
11 5     5   64 use Archive::Tar::Constant;
  5         11  
  5         1629  
12 5     5   35 use Carp;
  5         10  
  5         1928  
13              
14             sub new {
15 4     4 0 1322 my ($pkg,$arch) = @_;
16              
17 4         34 bless {file => $arch}, $pkg;
18             }
19              
20             sub add {
21 6     6 1 7842 my $self = shift;
22              
23 6         61 my $arch = Archive::Tar->new;
24 6 50       134 $arch->add_files(@_) or croak "add: $!";
25 6         11862 my $tf = $arch->write;
26 6         27943 syswrite $self->{file}, $tf, length($tf) - (BLOCK * 2);
27             }
28              
29             sub next {
30 19     19 1 25153 my $self = shift;
31              
32 19   100     166 $self->{pending} ||= [];
33 19 100       31 return shift @{$self->{pending}} if @{$self->{pending}};
  1         4  
  19         1745  
34 18         113 my $arch = Archive::Tar->new;
35 18         329 my ($fil,@pend) = $arch->read( $self->{file}, 0, {limit => 1});
36 18         13986 $self->{pending} = \@pend;
37 18         121 $fil;
38             }
39              
40             sub writeeof {
41 3     3 0 27 my $self = shift;
42              
43 3         50 syswrite $self->{file},TAR_END;
44             }
45              
46             1;
47             __END__