Match/Util.pm

filter: Statementstmt 100% 34 / 34 Branchbran 90.0% 9 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 11 / 11 Podpod 100% 3 / 3 totaltotal 98.2% 57 / 58 CC 6 SCAR 4.9
CC
6
Cov
98%
wildcard
2.0
filename
2.0
__ANON__
2.0
CRAP 1.6
« Match/Sugar.pm ↑ Summary
1 package File::Find::Match::Util;
2 1 require 5.008;
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use base 'Exporter';
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use File::Basename ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 1 our $VERSION = '0.10';
10 1 our @EXPORT = qw( );
11 1 our @EXPORT_OK = qw( filename ext wildcard );
12  
13 2 ▶sub filename ($) {
Subroutine filename: called CC=2 SCAR=6.9
Pod documented
14 2 ▶ my $basename = shift or croak 'Usage: filename($basename)';
Branch: 1 branch
BranchTrueFalseTotal
my $basename = shift() or croak("Usage: filename(\$basename)") 1 1 2
15
16 7 ▶ return sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
17 7 ▶ croak "filename() predicate passed undef filename!" if not defined $_[0];
Branch: 1 branch
BranchTrueFalseTotal
unless defined $_[0] 2 5 7
18 5 File::Basename::basename($_[0]) eq $basename;
19 1 };
20 }
21  
22 3 ▶sub ext ($) {
Subroutine ext: called CC=2 SCAR=6.9
Pod documented
23 3 ▶ my $ext = shift or croak 'Usage: ext($extension)';
Branch: 1 branch
BranchTrueFalseTotal
my $ext = shift() or croak("Usage: ext(\$extension)") 1 2 3
24  
25 3 ▶ return sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
26 3 ▶ my $s = shift or croak "predicate ext($ext) called with bad arguments";
Branch: 1 branch
BranchTrueFalseTotal
my $s = shift() or croak("predicate ext($ext) called with bad arguments") 2 1 3
27 2 substr($s, rindex($s, '.') + 1) eq $ext;
28 1 };
29 }
30  
31 1 ▶sub wildcard ($) {
Subroutine wildcard: called CC=2 SCAR=7.0
Pod documented
32 1 ▶ my $pat = shift or croak 'Usage: wildcard($pattern)';
Branch: 1 branch
BranchTrueFalseTotal
my $pat = shift() or croak("Usage: wildcard(\$pattern)") 1 0 1
33 1 my $re = quotemeta $pat;
34 1 $re =~ s/\\\*/(.+)/g;
35 1 my $regex = qr/$re/;
36 1 ▶ return sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
37 1 $_[0] =~ $regex;
38 1 };
39 }
40  
41  
42 1 1;
43 __END__
« Match/Sugar.pm ↑ Summary