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   2454 use Moo;
  1         17262  
  1         7  
3 1     1   2055 use Carp qw(confess);
  1         3  
  1         57  
4 1     1   501 use Archive::Peek::Tar;
  1         3  
  1         53  
5 1     1   721 use Archive::Peek::Zip;
  1         20  
  1         54  
6 1     1   753 use Types::Path::Tiny qw( File );
  1         152554  
  1         13  
7             our $VERSION = '0.37';
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 13231 my $self = shift;
18 4         24 my $filename = $self->filename;
19 4         24 my $basename = $filename->basename;
20 4 100       224 if ( $basename =~ /\.zip$/i ) {
    50          
21 2         18 bless $self, 'Archive::Peek::Zip';
22             } elsif ( $basename =~ /(\.tar|\.tar\.gz|\.tgz|\.bz2|\.bzip2)$/i ) {
23 2         17 bless $self, 'Archive::Peek::Tar';
24             } else {
25 0           confess("Failed to open $filename");
26             }
27             }
28              
29             1;
30              
31             __END__