DMOSS/File.pm

filter: Statementstmt 60.8% 28 / 46 Branchbran 25.0% 6 / 24 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 50.0% 6 / 12 Podpod 100% 8 / 8 totaltotal 51.5% 49 / 95 CC 14 SCAR 17.1
CC
14
Cov
48%
new
8.2
basename
6.0
dirname
6.0
CRAP 5.5
« DMOSS/Attr.pm ↑ Summary DMOSS/Plugin/SpellChecker.pm »
1 package DMOSS::File;
2 # ABSTRACT: DMOSS file object
3 3 $DMOSS::File::VERSION = '0.01_2';
4 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 3 ▶use File::Basename ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8 3 ▶use File::Slurp qw/slurp/;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 ▶sub new {
Subroutine new: called CC=7 SCAR=21.1
Pod documented
11 1 my ($class, $basedir, $fullpath) = @_;
12 1 my $self = bless({}, $class);
13  
14 1 $self->fullpath($fullpath);
15 1 ▶ $self->basename(File::Basename::basename($fullpath)) if $fullpath;
Branch: 1 branch
BranchTrueFalseTotal
if $fullpath 0 1 1
16 1 ▶ $self->dirname(File::Basename::dirname($fullpath)) if $fullpath;
Branch: 1 branch
BranchTrueFalseTotal
if $fullpath 0 1 1
17 1 my $path = $fullpath;
18 1 ▶ $path =~ s/$basedir//g if $path;
Branch: 1 branch
BranchTrueFalseTotal
if $path 0 1 1
19 1 ▶ $path =~ s/^\/+//g if $path;
Branch: 1 branch
BranchTrueFalseTotal
if $path 0 1 1
20 1 $self->{path} = $path;
21 1 ▶ $self->{isfile} = 1 unless ($fullpath and -d $fullpath);
Branch: 1 branch
BranchTrueFalseTotal
unless $fullpath and -d $fullpath 1 0 1
Condition33%1/3
$fullpath and -d $fullpath
!ll&&!rl&&r
100
MC/DC0%0/2
$fullpath and -d $fullpath
$fullpath -d $fullpath
Truth table33%1/3
A and B
A= $fullpathB= -d $fullpath
ABresult
0X0
100
111
22  
23 #$self->content(slurp $fullpath) if -e $fullpath;
24  
25 1 return $self;
26 }
27  
28 0 ▶sub basename {
Subroutine basename: not called CC=2 SCAR=17.9
Pod documented
29 0 my ($self, $basename) = @_;
30 0 ▶ $self->{basename} = $basename if $basename;
Branch: 1 branch
BranchTrueFalseTotal
if $basename 0 0 0
31  
32 0 return $self->{basename};
33 }
34  
35 1 ▶sub fullpath {
Subroutine fullpath: called CC=2 SCAR=7.1
Pod documented
36 1 my ($self, $fullpath) = @_;
37 1 ▶ $self->{fullpath} = $fullpath if $fullpath;
Branch: 1 branch
BranchTrueFalseTotal
if $fullpath 0 1 1
38  
39 1 return $self->{fullpath};
40 }
41  
42 0 ▶sub dirname {
Subroutine dirname: not called CC=2 SCAR=17.9
Pod documented
43 0 my ($self, $dirname) = @_;
44 0 ▶ $self->{dirname} = $dirname if $dirname;
Branch: 1 branch
BranchTrueFalseTotal
if $dirname 0 0 0
45  
46 0 return $self->{dirname};
47 }
48  
49 0 ▶sub path {
Subroutine path: not called CC=2 SCAR=17.9
Pod documented
50 0 my ($self, $path) = @_;
51 0 ▶ $self->{path} = $path if $path;
Branch: 1 branch
BranchTrueFalseTotal
if $path 0 0 0
52  
53 0 return $self->{path};
54 }
55  
56 0 ▶sub type {
Subroutine type: not called CC=2 SCAR=17.9
Pod documented
57 0 my ($self, $type) = @_;
58 0 ▶ $self->{type} = $type if $type;
Branch: 1 branch
BranchTrueFalseTotal
if $type 0 0 0
59  
60 0 return $self->{type};
61 }
62  
63 0 ▶sub content {
Subroutine content: not called CC=2 SCAR=17.9
Pod documented
64 0 my ($self, $content) = @_;
65 0 ▶ $self->{content} = $content if $content;
Branch: 1 branch
BranchTrueFalseTotal
if $content 0 0 0
66  
67 0 return $self->{content};
68 }
69  
70 0 ▶sub isfile {
Subroutine isfile: not called CC=2 SCAR=17.9
Pod documented
71 0 my ($self, $isfile) = @_;
72 0 ▶ $self->{isfile} = $isfile if $isfile;
Branch: 1 branch
BranchTrueFalseTotal
if $isfile 0 0 0
73  
74 0 return $self->{isfile};
75 }
76  
77 3 1;
78  
79 __END__
« DMOSS/Attr.pm ↑ Summary DMOSS/Plugin/SpellChecker.pm »