URI/file.pm

filter: Statementstmt 92.5% 50 / 54 Branchbran 72.2% 13 / 18 Conditioncond 46.8% 15 / 32 MC/DCmcdc 20.0% 3 / 15 Subroutinesub 92.3% 12 / 13 Podpod 87.5% 7 / 8 totaltotal 71.4% 100 / 140 CC 21 SCAR 27.6
CC
21
Cov
75%
canonical
33.9
os_class
5.0
cwd
3.0
CRAP 15.8
« URI/file/Mac.pm ↑ Summary URI/_generic.pm »
1 package URI::file;
2  
3 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 4 ▶use parent 'URI::_generic';
Subroutine BEGIN: called CC=1 SCAR=0.0
7 4 our $VERSION = '5.40';
8  
9 4 ▶use URI::Escape qw(uri_unescape);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 4 our $DEFAULT_AUTHORITY = "";
12  
13 # Map from $^O values to implementation classes. The Unix
14 # class is the default.
15 4 our %OS_CLASS = (
16 os2 => "OS2",
17 mac => "Mac",
18 MacOS => "Mac",
19 MSWin32 => "Win32",
20 win32 => "Win32",
21 msdos => "FAT",
22 dos => "FAT",
23 qnx => "QNX",
24 );
25  
26 170 ▶sub os_class {
Subroutine os_class: called CC=5 SCAR=16.2
Pod undocumented
27 170 ▶ my ($OS) = shift || $^O;
Condition66%2/3
shift() || $^O
l!l&&r!l&&!r
140300
MC/DC0%0/2
shift() || $^O
shift() $^O
Truth table66%2/3
A || B
A= shift()B= $^O
ABresult
1X1
011
000
28  
29 170 ▶ my $class = "URI::file::" . ($OS_CLASS{$OS} || "Unix");
Condition100%2/2
$URI::file::OS_CLASS{$OS} || 'Unix'
l!l
9080
MC/DC100%1/1
$URI::file::OS_CLASS{$OS} || 'Unix'
$URI::file::OS_CLASS{$OS}
Truth table100%2/2
A
A= $URI::file::OS_CLASS{$OS}
Aresult
11
00
30 4 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
31 170 ▶ unless (%{"$class\::"}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (%{"${class}::";}) 10 160 170
32 10 eval "require $class";
33 10 ▶ die $@ if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 10 10
34 }
35 170 $class;
36 }
37  
38 2 ▶sub host { uri_unescape(shift->authority(@_)) }
Subroutine host: called CC=1 SCAR=0.0
Pod documented
39  
40 69 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
41 69 my ($class, $path, $os) = @_;
42 69 os_class($os)->new($path);
43 }
44  
45 15 ▶sub new_abs {
Subroutine new_abs: called CC=2 SCAR=6.9
Pod documented
46 15 my $class = shift;
47 15 my $file = $class->new(@_);
48 15 ▶ return $file->abs($class->cwd) unless $$file =~ /^file:/;
Branch: 1 branch
BranchTrueFalseTotal
unless $$file =~ /^file:/ 11 4 15
49 4 $file;
50 }
51  
52 12 ▶sub cwd {
Subroutine cwd: called CC=3 SCAR=11.0
Pod documented
53 12 my $class = shift;
54 12 require Cwd;
55 12 my $cwd = Cwd::cwd();
56 12 ▶ $cwd = VMS::Filespec::unixpath($cwd) if $^O eq 'VMS';
Branch: 1 branch
BranchTrueFalseTotal
if $^O eq "VMS" 0 12 12
57 12 $cwd = $class->new($cwd);
58 12 ▶ $cwd .= "/" unless substr($cwd, -1, 1) eq "/";
Branch: 1 branch
BranchTrueFalseTotal
unless substr($cwd, -1, 1) eq "/" 11 1 12
59 12 $cwd;
60 }
61  
62 46 ▶sub canonical {
Subroutine canonical: called CC=14 SCAR=35.2
Pod documented
63 46 my $self = shift;
64 46 my $other = $self->SUPER::canonical;
65  
66 46 my $scheme = $other->scheme;
67 46 my $auth = $other->authority;
68 46 ▶ return $other if !defined($scheme) && !defined($auth); # relative
Branch: 1 branch
BranchTrueFalseTotal
unless defined $scheme or defined $auth 6 40 46
Condition66%2/3
defined $scheme or defined $auth
l!l&&r!l&&!r
4006
MC/DC50%1/2
defined $scheme or defined $auth
defined $scheme defined $auth
Truth table66%2/3
A or B
A= defined $schemeB= defined $auth
ABresult
1X1
011
000
69  
70 40 ▶ if ( !defined($auth)
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $auth or $auth eq "" or lc $auth eq "localhost" or defined $URI::file::DEFAULT_AUTHORITY and lc $auth eq lc $URI::file::DEFAULT_AUTHORITY) 36 4 40
Condition58%7/12
not defined $auth or $auth eq "" or lc $auth eq "localhost" or defined $URI::file::DEFAULT_AUTHORITY and lc $auth eq lc $URI::file::DEFAULT_AUTHORITY
l!l&&r!l&&!r
3604
not defined $auth or $auth eq "" or lc $auth eq "localhost"
l!l&&r!l&&!r
3604
not defined $auth or $auth eq ""
l!l&&r!l&&!r
3604
defined $URI::file::DEFAULT_AUTHORITY and lc $auth eq lc $URI::file::DEFAULT_AUTHORITY
!ll&&!rl&&r
400
MC/DC20%1/5
not defined $auth or $auth eq "" or lc $auth eq "localhost" or defined $URI::file::DEFAULT_AUTHORITY and lc $auth eq lc $URI::file::DEFAULT_AUTHORITY
not defined $auth $auth eq "" lc $auth eq "localhost" defined $URI::file::DEFAULT_AUTHORITY lc $auth eq lc $URI::file::DEFAULT_AUTHORITY
Truth table33%2/6
not(A) or B or C or D and E
A= not defined $authB= $auth eq ""C= lc $auth eq "localhost"D= defined $URI::file::DEFAULT_AUTHORITYE= lc $auth eq lc $URI::file::DEFAULT_AUTHORITY
ABCDEresult
1XXXX1
01XXX1
001XX1
000111
0000X0
000100
71 || $auth eq ""
72 || lc($auth) eq "localhost"
73 || (defined($DEFAULT_AUTHORITY) && lc($auth) eq lc($DEFAULT_AUTHORITY)))
74 {
75 # avoid cloning if $auth already match
76 36 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if (defined $auth || defined $URI::file::DEFAULT_AUTHORITY and !(defined $auth && defined $URI::file::DEFAULT_AUTHORITY) || $auth ne $URI::file::DEFAULT_AUTHORITY) 0 36 36
Condition16%2/12
defined $auth || defined $URI::file::DEFAULT_AUTHORITY and !(defined $auth && defined $URI::file::DEFAULT_AUTHORITY) || $auth ne $URI::file::DEFAULT_AUTHORITY
!ll&&!rl&&r
3600
defined $auth or defined $URI::file::DEFAULT_AUTHORITY
l!l&&r!l&&!r
0036
not defined $auth && defined $URI::file::DEFAULT_AUTHORITY or $auth ne $URI::file::DEFAULT_AUTHORITY
l!l&&r!l&&!r
000
defined $auth && defined $URI::file::DEFAULT_AUTHORITY
!ll&&!rl&&r
000
MC/DC0%0/5
defined $auth || defined $URI::file::DEFAULT_AUTHORITY and !(defined $auth && defined $URI::file::DEFAULT_AUTHORITY) || $auth ne $URI::file::DEFAULT_AUTHORITY
defined $auth defined $URI::file::DEFAULT_AUTHORITY defined $auth defined $URI::file::DEFAULT_AUTHORITY $auth ne $URI::file::DEFAULT_AUTHORITY
Truth table11%1/9
A or B and not(C && D) or E
A= defined $authB= defined $URI::file::DEFAULT_AUTHORITYC= defined $authD= defined $URI::file::DEFAULT_AUTHORITYE= $auth ne $URI::file::DEFAULT_AUTHORITY
ABCDEresult
00XXX0
1X1100
011100
1X0XX1
1X10X1
1X1111
010XX1
0110X1
011111
77 (defined($auth) || defined($DEFAULT_AUTHORITY))
78 && ( !defined($auth)
79 || !defined($DEFAULT_AUTHORITY)
80 || $auth ne $DEFAULT_AUTHORITY)
81 )
82 {
83 0 ▶ $other = $other->clone if $self == $other;
Branch: 1 branch
BranchTrueFalseTotal
if $self == $other 0 0 0
84 0 $other->authority($DEFAULT_AUTHORITY);
85 }
86 }
87  
88 40 $other;
89 }
90  
91 101 ▶sub file {
Subroutine file: called CC=1 SCAR=0.0
Pod documented
92 101 my ($self, $os) = @_;
93 101 os_class($os)->file($self);
94 }
95  
96 0 ▶sub dir {
Subroutine dir: not called CC=1 SCAR=6.9
Pod documented
97 0 my ($self, $os) = @_;
98 0 os_class($os)->dir($self);
99 }
100  
101 4 1;
102  
103 __END__
« URI/file/Mac.pm ↑ Summary URI/_generic.pm »