blib/lib/YAML/PP/Writer/File.pm

filter: Statementstmt 100% 34 / 34 Branchbran 100% 6 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod 100% 3 / 3 totaltotal 100% 52 / 52 CC 4 SCAR 5.1
CC
4
Cov
100%
_open_handle
3.0
finish
2.0
BEGIN
1.0
CRAP 1.7
« blib/lib/YAML/PP/Schema/Binary.pm ↑ Summary blib/lib/YAML/PP/Writer.pm »
1 49 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 49 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 package YAML::PP::Writer::File;
4  
5 49 our $VERSION = 'v0.43.0'; # VERSION
6  
7 49 ▶use Scalar::Util qw/ openhandle /;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 49 ▶use YAML::PP::Writer;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 49 our @ISA = qw/ YAML::PP::Writer /;
11  
12 49 ▶use Carp qw/ croak /;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 6 ▶sub _open_handle {
Subroutine _open_handle: called CC=3 SCAR=11.0
15 6 my ($self) = @_;
16 6 ▶ if (openhandle($self->{output})) {
Branch: 1 branch
BranchTrueFalseTotal
if (&openhandle($self->{"output"})) 1 5 6
17 1 $self->{filehandle} = $self->{output};
18 1 return $self->{output};
19 }
20 open my $fh, '>:encoding(UTF-8)', $self->{output}
21 5 ▶ or croak "Could not open '$self->{output}' for writing: $!";
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, ">:encoding(UTF-8)", $self->{"output"} or croak(qq[Could not open '$self->{"output"}' for writing: $!]) 4 1 5
22 4 $self->{filehandle} = $fh;
23 4 return $fh;
24 }
25  
26 30 ▶sub write {
Subroutine write: called CC=1 SCAR=0.0
Pod documented
27 30 my ($self, $line) = @_;
28 30 my $fh = $self->{filehandle};
29 30 print $fh $line;
30 }
31  
32 6 ▶sub init {
Subroutine init: called CC=1 SCAR=0.0
Pod documented
33 6 my ($self) = @_;
34 6 my $fh = $self->_open_handle;
35 }
36  
37 5 ▶sub finish {
Subroutine finish: called CC=2 SCAR=6.9
Pod documented
38 5 my ($self) = @_;
39 5 ▶ if (openhandle($self->{output})) {
Branch: 1 branch
BranchTrueFalseTotal
if (&openhandle($self->{"output"})) 1 4 5
40 # Original argument was a file handle, so the caller needs
41 # to close it
42 1 return;
43 }
44 4 close $self->{filehandle};
45 }
46  
47 49 1;
48  
49 __END__
« blib/lib/YAML/PP/Schema/Binary.pm ↑ Summary blib/lib/YAML/PP/Writer.pm »