lib/Rex/Interface/File/Local.pm

filter: Statementstmt 92.1% 35 / 38 Branchbran 66.6% 4 / 6 Conditioncond 33.3% 2 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 90.0% 9 / 10 Podpod 0.0% 0 / 6 totaltotal 71.4% 50 / 70 CC 6 SCAR 6.6
CC
6
Cov
82%
write
3.3
new
2.1
open
2.0
CRAP 1.9
« lib/Rex/Commands/Tail.pm ↑ Summary lib/Rex/Commands/SCM.pm »
1 #
2 # (c) Jan Gehring <jan.gehring@gmail.com>
3 #
4  
5 package Rex::Interface::File::Local;
6  
7 16 ▶use v5.14.4;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 16 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 16 our $VERSION = '1.16.1'; # VERSION
11  
12 16 ▶use Rex::Interface::File::Base;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 16 ▶use base qw(Rex::Interface::File::Base);
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 195 ▶sub new {
Subroutine new: called CC=2 SCAR=7.2
Pod undocumented
16 195 my $that = shift;
17 195 ▶ my $proto = ref($that) || $that;
Condition33%1/3
ref $that || $that
l!l&&r!l&&!r
01950
MC/DC0%0/2
ref $that || $that
ref $that $that
Truth table33%1/3
A || B
A= ref $thatB= $that
ABresult
1X1
011
000
18 195 my $self = $proto->SUPER::new(@_);
19  
20 195 bless( $self, $proto );
21  
22 195 return $self;
23 }
24  
25 195 ▶sub open {
Subroutine open: called CC=2 SCAR=7.0
Pod undocumented
26 195 my ( $self, $mode, $file ) = @_;
27  
28 195 Rex::Logger::debug("Opening $file with mode: $mode");
29  
30 195 ▶ open( $self->{fh}, $mode, $file ) or return;
Branch: 1 branch
BranchTrueFalseTotal
CORE::open $self->{"fh"}, $mode, $file or return 195 0 195
31  
32 195 return 1;
33 }
34  
35 778 ▶sub read {
Subroutine read: called CC=1 SCAR=0.0
Pod undocumented
36 778 my ( $self, $len ) = @_;
37  
38 778 my $buf;
39 778 read( $self->{fh}, $buf, $len );
40 778 return $buf;
41 }
42  
43 274 ▶sub write {
Subroutine write: called CC=3 SCAR=12.0
Pod undocumented
44 274 my ( $self, $buf ) = @_;
45  
46 274 ▶ utf8::encode($buf)
Branch: 1 branch
BranchTrueFalseTotal
if "Rex::Config"->get_write_utf8_files and utf8::is_utf8($buf) 0 274 274
Condition33%1/3
"Rex::Config"->get_write_utf8_files and utf8::is_utf8($buf)
!ll&&!rl&&r
27400
MC/DC0%0/2
"Rex::Config"->get_write_utf8_files and utf8::is_utf8($buf)
"Rex::Config"->get_write_utf8_files utf8::is_utf8($buf)
Truth table33%1/3
A and B
A= "Rex::Config"->get_write_utf8_filesB= utf8::is_utf8($buf)
ABresult
0X0
100
111
47 if Rex::Config->get_write_utf8_files && utf8::is_utf8($buf);
48  
49 274 my $fh = $self->{fh};
50 274 print $fh $buf;
51 }
52  
53 0 ▶sub seek {
Subroutine seek: not called CC=1 SCAR=6.9
Pod undocumented
54 0 my ( $self, $pos ) = @_;
55  
56 0 my $fh = $self->{fh};
57 0 seek( $fh, $pos, 0 );
58 }
59  
60 384 ▶sub close {
Subroutine close: called CC=2 SCAR=6.9
Pod undocumented
61 384 my ($self) = @_;
62  
63 384 my $fh = $self->{fh};
64 384 ▶ close $fh if $fh;
Branch: 1 branch
BranchTrueFalseTotal
if $fh 195 189 384
65 384 $self->{fh} = undef;
66 384 $self = undef;
67 }
68  
69 16 1;
« lib/Rex/Commands/Tail.pm ↑ Summary lib/Rex/Commands/SCM.pm »