Tester/LogWriter.pm

filter: Statementstmt 100% 50 / 50 Branchbran 50.0% 2 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 13 / 13 Podpod 0.0% 0 / 3 totaltotal 92.8% 65 / 70 CC 3 SCAR 3.4
CC
3
Cov
96%
_ensure_handle
3.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.4
« Tester/Response/Sentence.pm ↑ Summary Tester/Role/HTTPResult.pm »
1 3 ▶use v5.14.0;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 package JMAP::Tester::LogWriter 0.113;
3  
4 3 ▶use Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 3 requires 'write';
7  
8 3 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 {
11 package JMAP::Tester::LogWriter::Code 0.113;
12  
13 3 ▶ use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 3 ▶ use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 3 with 'JMAP::Tester::LogWriter';
16 3 has code => (is => 'ro', required => 1);
17 16 ▶ sub write { $_[0]->code->($_[1]) }
Subroutine write: called CC=1 SCAR=0.0
Pod undocumented
18 }
19  
20 {
21 3 package JMAP::Tester::LogWriter::Handle 0.113;
22  
23 3 ▶ use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
24 3 ▶ use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
25 3 with 'JMAP::Tester::LogWriter';
26 3 has handle => (is => 'ro', required => 1);
27 3 ▶ sub write { $_[0]->handle->print($_[1]) }
Subroutine write: called CC=1 SCAR=0.0
Pod undocumented
28 }
29  
30 {
31 3 package JMAP::Tester::LogWriter::Filename 0.113;
32  
33 3 ▶ use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
34 3 ▶ use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
35 3 with 'JMAP::Tester::LogWriter';
36 3 has filename_template => (
37 is => 'ro',
38 default => 'jmap-tester-{T}-{PID}.log',
39 );
40  
41 3 has _handle => (is => 'rw');
42 3 has _pid => (is => 'rw', init_arg => undef, default => -1);
43  
44 1 ▶ sub write { $_[0]->_ensure_handle->print($_[1]) }
Subroutine write: called CC=1 SCAR=0.0
Pod undocumented
45  
46 1 ▶ sub _ensure_handle {
Subroutine _ensure_handle: called CC=3 SCAR=11.1
47 1 my ($self) = @_;
48 1 ▶ return $self->_handle if $self->_pid == $$;
Branch: 1 branch
BranchTrueFalseTotal
if $self->_pid == $$ 0 1 1
49  
50 1 my $fn = $self->filename_template =~ s/\{T\}/$^T/gr =~ s/\{PID\}/$$/gr;
51 1 ▶ open my $fh, '>>', $fn or Carp::confess("can't open $fn for writing: $!");
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, ">>", $fn or Carp::confess("can't open $fn for writing: $!") 1 0 1
52  
53 1 $fh->autoflush(1);
54  
55 1 $self->_handle($fh);
56 1 $self->_pid($$);
57 1 return $fh;
58 }
59 }
60  
61 3 1;
62  
63 __END__
« Tester/Response/Sentence.pm ↑ Summary Tester/Role/HTTPResult.pm »