File Coverage

blib/lib/Regexp/Pattern/Filename/Type/Archive.pm
Criterion Covered Total %
statement 14 14 100.0
branch n/a
condition n/a
subroutine 5 5 100.0
pod n/a
total 19 19 100.0


line stmt bran cond sub pod time code
1             package Regexp::Pattern::Filename::Type::Archive;
2              
3 1     1   311158 use 5.010001;
  1         6  
4 1     1   8 use strict;
  1         1  
  1         30  
5 1     1   5 use warnings;
  1         2  
  1         69  
6             #use utf8;
7              
8 1     1   707 use Filename::Type::Archive ();
  1         1349  
  1         40  
9 1     1   550 use Filename::Type::Compressed ();
  1         1453  
  1         270  
10              
11             our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
12             our $DATE = '2024-12-21'; # DATE
13             our $DIST = 'Regexp-Pattern-Filename-Type-Archive'; # DIST
14             our $VERSION = '0.004'; # VERSION
15              
16             our %RE;
17              
18             my $re = join('',
19             '(?:', join('|', map {quotemeta} sort keys %Filename::Type::Archive::SUFFIXES ), ')',
20             '(?:', join('|', map {quotemeta} sort keys %Filename::Type::Compressed::SUFFIXES), ')*',
21             );
22             $re = qr($re\z)i;
23              
24             $RE{filename_type_archive} = {
25             summary => 'Archive filename',
26             pat => $re,
27             tags => ['anchored'],
28             examples => [
29             {str=>'foo', matches=>0, summary=>'No extension'},
30             {str=>'zip', matches=>0, summary=>'Not an extension'},
31             {str=>'foo.zip', matches=>1},
32             {str=>'foo.tar.gz', matches=>1, summary=>'Plus compression'},
33             {str=>'foo bar.TBZ', matches=>1, summary=>'Case insensitive'},
34             {str=>'foo.ARJ is the file', matches=>0, summary=>'Regex is anchored'},
35             {str=>'foo.txt', matches=>0},
36             ],
37             };
38              
39             1;
40             # ABSTRACT: Archive filename
41              
42             __END__