blib/lib/RackMan/File.pm

filter: Statementstmt 75.0% 30 / 40 Branchbran 25.0% 1 / 4 Conditioncond 100% 2 / 2 MC/DCmcdc 100% 1 / 1 Subroutinesub 80.0% 8 / 10 Podpod 100% 4 / 4 totaltotal 75.4% 46 / 61 CC 4 SCAR 7.7
CC
4
Cov
72%
read
6.0
write
2.0
fullpath
2.0
CRAP 2.2
« blib/lib/RackMan/SCM.pm ↑ Summary blib/lib/RackMan/Device/VM.pm »
1 package RackMan::File;
2  
3 3 ▶use File::Basename;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use File::Path;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 3 ▶use Path::Class;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 3 ▶use RackMan;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 3 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10  
11 3 has name => (
12 is => "rw",
13 isa => "Str",
14 );
15  
16 3 has path => (
17 is => "rw",
18 isa => "Str",
19 );
20  
21 3 has content => (
22 is => "rw",
23 isa => "Str",
24 );
25  
26  
27 #
28 # fullpath()
29 # --------
30 0 ▶sub fullpath {
Subroutine fullpath: not called CC=1 SCAR=6.9
Pod documented
31 0 my $self = shift;
32 0 my $file = file(grep length, $self->path, $self->name);
33 0 return "$file"
34 }
35  
36  
37 #
38 # add_content()
39 # -----------
40 3 ▶sub add_content {
Subroutine add_content: called CC=2 SCAR=6.9
Pod documented
41 3 my $self = shift;
42 3 ▶ $self->content( join "", $self->content || "", @_ );
Condition100%2/2
$self->content || ''
l!l
21
MC/DC100%1/1
$self->content || ''
$self->content
Truth table100%2/2
A
A= $self->content
Aresult
11
00
43 }
44  
45  
46 #
47 # read()
48 # ----
49 0 ▶sub read {
Subroutine read: not called CC=2 SCAR=17.9
Pod documented
50 0 my $self = shift;
51 0 my $file = file($self->path, $self->name);
52 0 ▶ my $fh = $file->open("<")
Branch: 1 branch
BranchTrueFalseTotal
my $fh = $file->open("<") or "RackMan"->error("can't read '${file}': $!") 0 0 0
53 or RackMan->error("can't read '$file': $!");
54 {
55 0 local $/; # slurp mode
56 0 $self->content($fh->getline);
57 }
58 0 $fh->close;
59 }
60  
61  
62 #
63 # write()
64 # -----
65 1 ▶sub write {
Subroutine write: called CC=2 SCAR=7.0
Pod documented
66 1 my $self = shift;
67 1 my $file = file($self->path, $self->name);
68 1 mkpath dirname("$file");
69 1 ▶ my $fh = $file->open(">")
Branch: 1 branch
BranchTrueFalseTotal
my $fh = $file->open(">") or "RackMan"->error("can't write '${file}': $!") 1 0 1
70 or RackMan->error("can't write '$file': $!");
71 1 $fh->print($self->content);
72 1 $fh->close;
73 }
74  
75  
76 3 __PACKAGE__->meta->make_immutable
77  
78 __END__
« blib/lib/RackMan/SCM.pm ↑ Summary blib/lib/RackMan/Device/VM.pm »