blib/lib/File/PlainPath.pm

filter: Statementstmt 100% 35 / 35 Branchbran 100% 8 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod 100% 1 / 1 totaltotal 100% 49 / 49 CC 5 SCAR 9.4
CC
5
Cov
100%
import
4.0
path
2.0
BEGIN
1.0
CRAP 2.6
↑ Summary
1 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 package File::PlainPath;
4  
5 # ABSTRACT: Construct portable filesystem paths in a simple way
6  
7 4 our $VERSION = '0.030'; # VERSION
8  
9 4 ▶use File::Spec;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11  
12 4 require Exporter;
13 4 our @ISA = qw(Exporter);
14 4 our @EXPORT_OK = qw(path to_path);
15  
16 sub import
17 7 ▶{
Subroutine import: called CC=4 SCAR=13.9
18 7 my $class = shift;
19 7 my %opts = ();
20 7 my @export = ();
21 7 ▶ while (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 11 7 18
22 11 my $arg = shift;
23 11 ▶ if ($arg =~ m{^ [-] (.+) $}x)
Branch: 1 branch
BranchTrueFalseTotal
if ($arg =~ /^ [-] (.+) $/x) 6 5 11
24 {
25 6 $opts{$1} = shift;
26 6 next;
27 }
28 5 push @export, $arg;
29 }
30
31 7 ▶ if (exists $opts{'separator'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $opts{"separator"}) 6 1 7
32 6 $^H{+__PACKAGE__} = $opts{'separator'};
33 }
34
35 7 @_ = ($class, @export);
36 7 goto \&Exporter::import;
37 }
38  
39  
40 15 ▶sub path {
Subroutine path: called CC=2 SCAR=6.9
Pod documented
41 15 my @caller = caller(0);
42 my $separator = exists $caller[10]{+__PACKAGE__} ?
43 15 ▶ $caller[10]{+__PACKAGE__} : '/';
Branch: 1 branch
BranchTrueFalseTotal
exists $caller[10]{'File::PlainPath'} ? : 10 5 15
44 15 my $separator_re = qr{ \Q$separator\E }x;
45  
46 15 my @paths = @_;
47 15 my @path_components = map { split($separator_re, $_) } @paths;
48  
49 15 return File::Spec->catfile(@path_components);
50 }
51  
52  
53 4 *to_path = *path;
54  
55  
56 4 1;
57  
58 __END__
↑ Summary