File Coverage

lib/App/PRT/Collector/FileHandle.pm
Criterion Covered Total %
statement 23 23 100.0
branch n/a
condition n/a
subroutine 5 5 100.0
pod 0 2 0.0
total 28 30 93.3


line stmt bran cond sub pod time code
1             package App::PRT::Collector::FileHandle;
2 2     2   2430 use strict;
  2         5  
  2         60  
3 2     2   11 use warnings;
  2         4  
  2         57  
4 2     2   11 use File::Temp qw(tempdir tempfile);
  2         3  
  2         392  
5              
6             sub new {
7 3     3 0 18058 my ($class, $input_fh) = @_;
8              
9 3         21 bless {
10             input_fh => $input_fh,
11             }, $class;
12             }
13              
14             sub collect {
15 1     1 0 5 my ($self) = @_;
16              
17 1         3 my $input_fh = $self->{input_fh};
18 1         2 my $content = do { local $/; <$input_fh> };
  1         4  
  1         30  
19              
20 1         5 my $dir = tempdir( CLEANUP => 1 );
21              
22 1         374 my ($fh, $file) = tempfile('prt-XXXX', DIR => $dir, SUFFIX => '.pm');
23 1         374 $self->{dir} = $dir;
24 1         2 $self->{file} = $file;
25              
26 1         16 print $fh $content;
27 1         26 close $fh;
28              
29 1         16 [ $file ];
30             }
31              
32             1;