NG/File.pm

filter: Statementstmt 47.6% 20 / 42 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 54.5% 6 / 11 Podpod n/a totaltotal 37.1% 26 / 70 CC 5 SCAR 15.4
CC
5
Cov
38%
__ANON__
12.0
__ANON__
6.0
__ANON__
6.0
CRAP 4.7
« NG/Array.pm ↑ Summary NG/Time.pm »
1 1 ▶use NG::Array;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 1 ▶use NG::Hashtable;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use NG::Time;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use NG::Class;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use File::Copy::Recursive ();
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Digest::MD5 qw(md5_hex);
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 NG::Class::def 'NG::File' => ['name'] => {
9 0 ▶ build => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
10 0 my ( $self, $filepath ) = @_;
11 0 $self->name = $filepath;
12 },
13 0 ▶ read => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
14 0 my ( $self, $filepath ) = @_;
15 0 ▶ $filepath //= $self->name;
Condition0%0/3
$filepath //= $self->name
l!l&&r!l&&!r
000
MC/DC0%0/2
$filepath //= $self->name
$filepath $self->name
Truth table0%0/3
A //= B
A= $filepathB= $self->name
ABresult
1X1
011
000
16 0 open my $fh, '<', $filepath;
17 0 my $content = new NG::Array;
18 0 ▶ while (<$fh>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $fh)) 0 0 0
19 0 chomp;
20 0 $content->push($_);
21 }
22 0 return $content;
23 },
24 0 ▶ copy => sub { shift; File::Copy::Recursive::rcopy(@_) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
25 0 ▶ md5 => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
26 0 my ( $self, $filepath ) = @_;
27 0 ▶ $filepath //= $self->name;
Condition0%0/3
$filepath //= $self->name
l!l&&r!l&&!r
000
MC/DC0%0/2
$filepath //= $self->name
$filepath $self->name
Truth table0%0/3
A //= B
A= $filepathB= $self->name
ABresult
1X1
011
000
28 0 open my $fh, '<', $filepath;
29 return md5_hex(
30 0 do { local $/; <$fh> }
31 );
32 },
33 0 ▶ fstat => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
34 0 my ( $self, $filepath ) = @_;
35 0 ▶ $filepath //= $self->name;
Condition0%0/3
$filepath //= $self->name
l!l&&r!l&&!r
000
MC/DC0%0/2
$filepath //= $self->name
$filepath $self->name
Truth table0%0/3
A //= B
A= $filepathB= $self->name
ABresult
1X1
011
000
36 0 my $ret = NG::Array->new( stat($filepath) );
37 0 return NG::Hashtable->new(
38 dev => $ret->get(0),
39 inode => $ret->get(1),
40 mode => sprintf( "%04o", $ret->get(2) & 07777 ),
41 nlink => $ret->get(3),
42 uid => $ret->get(4),
43 gid => $ret->get(5),
44 rdev => $ret->get(6),
45 size => $ret->get(7),
46 atime => NG::Time->new->from_epoch( $ret->get(8) ),
47 mtime => NG::Time->new->from_epoch( $ret->get(9) ),
48 ctime => NG::Time->new->from_epoch( $ret->get(10) ),
49 blksize => $ret->get(11),
50 blocks => $ret->get(12),
51 );
52 },
53 1 };
54  
55 1 1;
56 __END__
« NG/Array.pm ↑ Summary NG/Time.pm »