All/Link.pm

filter: Statementstmt 76.7% 33 / 43 Branchbran 40.0% 8 / 20 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 77.7% 7 / 9 Podpod 60.0% 3 / 5 totaltotal 66.2% 51 / 77 CC 11 SCAR 18.8
CC
11
Cov
65%
target
12.3
symlink
6.0
AUTOLOAD
2.1
CRAP 6.6
« All/MLDBM.pm ↑ Summary All/File.pm »
1 5 ▶use strict; use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
2 package IO::All::Link;
3  
4 5 ▶use IO::All::File -base;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 5 const type => 'link';
7  
8 sub link {
9 9 ▶ my $self = shift;
Subroutine link: called CC=2 SCAR=7.0
Pod documented
10 9 bless $self, __PACKAGE__;
11 9 ▶ $self->name(shift) if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 9 0 9
12 9 $self->_init;
13 }
14  
15 sub readlink {
16 3 ▶ my $self = shift;
Subroutine readlink: called CC=1 SCAR=0.0
Pod documented
17 3 $self->_constructor->(CORE::readlink($self->name));
18 }
19  
20 sub symlink {
21 0 ▶ my $self = shift;
Subroutine symlink: not called CC=2 SCAR=17.9
Pod undocumented
22 0 my $target = shift;
23 0 ▶ $self->assert_filepath if $self->_assert;
Branch: 1 branch
BranchTrueFalseTotal
if $self->_assert 0 0 0
24 0 CORE::symlink($target, $self->pathname);
25 }
26  
27 sub AUTOLOAD {
28 2 ▶ my $self = shift;
Subroutine AUTOLOAD: called CC=2 SCAR=7.5
29 2 our $AUTOLOAD;
30 2 (my $method = $AUTOLOAD) =~ s/.*:://;
31 2 my $target = $self->target;
32 2 ▶ unless ($target) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($target) 0 2 2
33 0 $self->throw("Can't call $method on symlink");
34 0 return;
35 }
36 2 $target->$method(@_);
37 }
38  
39 sub target {
40 2 ▶ my $self = shift;
Subroutine target: called CC=8 SCAR=25.1
Pod undocumented
41 2 ▶ return *$self->{target} if *$self->{target};
Branch: 1 branch
BranchTrueFalseTotal
if *$self->{"target"} 1 1 2
42 1 my %seen;
43 1 my $link = $self;
44 1 my $new;
45 1 ▶ while ($new = $link->readlink) {
Branch: 1 branch
BranchTrueFalseTotal
if ($new = $link->readlink) 1 0 1
46 1 ▶ my $type = $new->type or return;
Branch: 1 branch
BranchTrueFalseTotal
my $type = $new->type or return 0 1 1
47 1 ▶ last if $type eq 'file';
Branch: 1 branch
BranchTrueFalseTotal
if $type eq "file" 0 1 1
48 1 ▶ last if $type eq 'dir';
Branch: 1 branch
BranchTrueFalseTotal
if $type eq "dir" 1 0 1
49 0 ▶ return unless $type eq 'link';
Branch: 1 branch
BranchTrueFalseTotal
unless $type eq "link" 0 0 0
50 0 ▶ return if $seen{$new->name}++;
Branch: 1 branch
BranchTrueFalseTotal
if $seen{$new->name}++ 0 0 0
51 0 $link = $new;
52 }
53 1 *$self->{target} = $new;
54 }
55  
56 0 ▶sub exists { -l shift->pathname }
Subroutine exists: not called CC=1 SCAR=6.9
Pod documented
57  
58 5 1;
« All/MLDBM.pm ↑ Summary All/File.pm »