File Coverage

blib/lib/Archive/Peek.pm
Criterion Covered Total %
statement 21 22 95.4
branch 3 4 75.0
condition n/a
subroutine 6 6 100.0
pod 0 1 0.0
total 30 33 90.9


line stmt bran cond sub pod time code
1             package Archive::Peek;
2 1     1   1259 use Moo;
  1         11485  
  1         5  
3 1     1   1443 use Carp qw(confess);
  1         2  
  1         46  
4 1     1   428 use Archive::Peek::Tar;
  1         4  
  1         36  
5 1     1   472 use Archive::Peek::Zip;
  1         17  
  1         51  
6 1     1   517 use Types::Path::Tiny qw( File );
  1         131873  
  1         9  
7             our $VERSION = '0.36';
8              
9             has 'filename' => (
10             is => 'ro',
11             isa => File,
12             required => 1,
13             coerce => 1,
14             );
15              
16             sub BUILD {
17 4     4 0 9962 my $self = shift;
18 4         17 my $filename = $self->filename;
19 4         20 my $basename = $filename->basename;
20 4 100       161 if ( $basename =~ /\.zip$/i ) {
    50          
21 2         15 bless $self, 'Archive::Peek::Zip';
22             } elsif ( $basename =~ /(\.tar|\.tar\.gz|\.tgz|\.bz2|\.bzip2)$/i ) {
23 2         16 bless $self, 'Archive::Peek::Tar';
24             } else {
25 0           confess("Failed to open $filename");
26             }
27             }
28              
29             1;
30              
31             __END__