File Coverage

blib/lib/Filename/Media.pm
Criterion Covered Total %
statement 13 13 100.0
branch 2 2 100.0
condition n/a
subroutine 5 5 100.0
pod 1 1 100.0
total 21 21 100.0


line stmt bran cond sub pod time code
1             package Filename::Media;
2              
3             our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
4             our $DATE = '2020-05-30'; # DATE
5             our $DIST = 'Filename-Media'; # DIST
6             our $VERSION = '0.002'; # VERSION
7              
8 1     1   83423 use 5.010001;
  1         10  
9 1     1   5 use strict;
  1         2  
  1         29  
10 1     1   6 use warnings;
  1         2  
  1         28  
11              
12 1     1   5 use Exporter qw(import);
  1         1  
  1         162  
13             our @EXPORT_OK = qw(check_media_filename);
14              
15             our $STR_RE = "movie|mpega|aifc|aiff|djvu|flac|jpeg|jpg2|midi|mpeg|mpga|opus|svgz|tiff|wbmp|webm|3gp|aif|amr|art|asf|asx|avi|awb|axa|axv|bmp|cdr|cdt|cpt|cr2|crw|csd|dif|djv|erf|fli|flv|gif|gsm|ico|ief|jng|jp2|jpe|jpf|jpg|jpm|jpx|kar|lsf|lsx|m3u|m4a|mid|mkv|mng|mov|mp2|mp3|mp4|mpe|mpg|mpv|mxu|nef|oga|ogg|ogv|orc|orf|pat|pbm|pcx|pgm|pls|png|pnm|ppm|psd|ram|ras|rgb|sco|sd2|sid|snd|spx|svg|tif|wav|wax|wma|wmv|wmx|wvx|xbm|xpm|xwd|au|dl|dv|gl|qt|ra|rm|ts|wm"; # STR_RE
16             our $RE = qr(\.(?:$STR_RE)\z)i;
17              
18             sub check_media_filename {
19 5     5 1 87 my %args = @_;
20              
21 5 100       57 $args{filename} =~ $RE ? {} : 0;
22             }
23              
24             1;
25             # ABSTRACT: Check whether filename indicates being a media (audio/video/image) file
26              
27             __END__