blib/lib/File/Find/Object/PathComp.pm

filter: Statementstmt 94.4% 51 / 54 Branchbran 100% 6 / 6 Conditioncond 33.3% 3 / 9 MC/DCmcdc 40.0% 2 / 5 Subroutinesub 92.8% 13 / 14 Podpod n/a totaltotal 85.2% 75 / 88 SCAR 19.6
CC
7
Cov
87%
_is_same_inode
12.0
_should_scan_dir
3.0
_calc_dir_files
2.0
CRAP 7.1
« Build ↑ Summary blib/lib/File/Find/Object/Result.pm »
1 package File::Find::Object::PathComp;
2 7 $File::Find::Object::PathComp::VERSION = '0.3.7';
3 7 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 7 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 7 ▶use integer;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 7 ▶use parent 'File::Find::Object::Base';
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 use Class::XSAccessor accessors => {
11 (
12 7 map { $_ => $_ } (
13 qw(
14 _actions
15 _curr_file
16 _files
17 _last_dir_scanned
18 _open_dir_ret
19 _stat_ret
20 _traverse_to
21 )
22 )
23 )
24 },
25 getters => { _inodes => '_inodes' },
26 setters => { _set_inodes => '_inodes' },
27 7 ▶ ;
Subroutine BEGIN: called CC=1 SCAR=0.0
28  
29 7 ▶use File::Spec;
Subroutine BEGIN: called CC=1 SCAR=0.0
30  
31 7 __PACKAGE__->_make_copy_methods(
32 [
33 qw(
34 _files
35 _traverse_to
36 )
37 ]
38 );
39  
40 sub _dev
41 {
42 87 ▶ return shift->_stat_ret->[0];
Subroutine _dev: called CC=1 SCAR=0.0
43 }
44  
45 sub _inode
46 {
47 70 ▶ return shift->_stat_ret->[1];
Subroutine _inode: called CC=1 SCAR=0.0
48 }
49  
50 sub _is_same_inode
51 {
52 0 ▶ my $self = shift;
Subroutine _is_same_inode: not called CC=3 SCAR=24.8
53  
54 # $st is an array ref with the return of perldoc -f stat .
55 0 my $st = shift;
56  
57 # On MS-Windows, all inodes in stat are returned as 0, so we need to
58 # check that both inodes are not zero. This is why there's the
59 # $self->_inode() != 0 check at the end.
60 0 ▶ return ( $self->_dev() == $st->[0]
Condition0%0/6
$self->_dev == $st->[0] && $self->_inode == $st->[1] && $self->_inode != 0
!ll&&!rl&&r
000
$self->_dev == $st->[0] and $self->_inode == $st->[1]
!ll&&!rl&&r
000
MC/DC0%0/3
$self->_dev == $st->[0] && $self->_inode == $st->[1] && $self->_inode != 0
$self->_dev == $st->[0] $self->_inode == $st->[1] $self->_inode != 0
Truth table0%0/4
A and B && C
A= $self->_dev == $st->[0]B= $self->_inode == $st->[1]C= $self->_inode != 0
ABCresult
0XX0
10X0
1100
1111
61 && $self->_inode() == $st->[1]
62 && $self->_inode() != 0 );
63 }
64  
65 sub _should_scan_dir
66 {
67 63 ▶ my $self = shift;
Subroutine _should_scan_dir: called CC=3 SCAR=11.0
68 63 my $dir_str = shift;
69  
70 63 ▶ if ( defined( $self->_last_dir_scanned() )
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->_last_dir_scanned and $self->_last_dir_scanned eq $dir_str) { } 7 56 63
Condition100%3/3
defined $self->_last_dir_scanned and $self->_last_dir_scanned eq $dir_str
!ll&&!rl&&r
35217
MC/DC100%2/2
defined $self->_last_dir_scanned and $self->_last_dir_scanned eq $dir_str
defined $self->_last_dir_scanned $self->_last_dir_scanned eq $dir_str
Truth table100%3/3
A and B
A= defined $self->_last_dir_scannedB= $self->_last_dir_scanned eq $dir_str
ABresult
0X0
100
111
71 && ( $self->_last_dir_scanned() eq $dir_str ) )
72 {
73 7 return;
74 }
75 else
76 {
77 56 $self->_last_dir_scanned($dir_str);
78 56 return 1;
79 }
80 }
81  
82 sub _set_up_dir
83 {
84 56 ▶ my $self = shift;
Subroutine _set_up_dir: called CC=1 SCAR=0.0
85 56 my $dir_str = shift;
86  
87 56 $self->_files( $self->_calc_dir_files($dir_str) );
88  
89 56 $self->_traverse_to( $self->_files_copy() );
90  
91 56 return $self->_open_dir_ret(1);
92 }
93  
94 sub _calc_dir_files
95 {
96 56 ▶ my $self = shift;
Subroutine _calc_dir_files: called CC=2 SCAR=6.9
97 56 my $dir_str = shift;
98  
99 56 my $handle;
100 my @files;
101 56 ▶ if ( !opendir( $handle, $dir_str ) )
Branch: 1 branch
BranchTrueFalseTotal
if (not opendir($handle, $dir_str)) { } 4 52 56
102 {
103 # Handle this error gracefully.
104 }
105 else
106 {
107 @files =
108 52 ( sort { $a cmp $b } File::Spec->no_upwards( readdir($handle) ) );
109 52 closedir($handle);
110 }
111  
112 56 return \@files;
113 }
114  
115 sub _component_open_dir
116 {
117 63 ▶ my $self = shift;
Subroutine _component_open_dir: called CC=2 SCAR=6.9
118 63 my $dir_str = shift;
119  
120 63 ▶ if ( !$self->_should_scan_dir($dir_str) )
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->_should_scan_dir($dir_str)) 7 56 63
121 {
122 7 return $self->_open_dir_ret();
123 }
124  
125 56 return $self->_set_up_dir($dir_str);
126 }
127  
128 sub _next_traverse_to
129 {
130 112 ▶ my $self = shift;
Subroutine _next_traverse_to: called CC=1 SCAR=0.0
131  
132 112 return shift( @{ $self->_traverse_to() } );
133 }
134  
135 7 1;
136  
137 __END__
« Build ↑ Summary blib/lib/File/Find/Object/Result.pm »