blib/lib/vCard/Role/FileIO.pm

filter: Statementstmt 100% 17 / 17 Branchbran 50.0% 3 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod n/a totaltotal 89.2% 25 / 28 CC 4 SCAR 5.8
CC
4
Cov
87%
_path
2.1
_iomode_out
2.0
_iomode_in
2.0
CRAP 1.8
« lib/Text/vCard/Addressbook.pm ↑ Summary
1 package vCard::Role::FileIO;
2 3 $vCard::Role::FileIO::VERSION = '3.09';
3 3 ▶use Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use Path::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 3 requires qw/encoding_in encoding_out/;
7  
8 # PerlIO layers should look like ':encoding(UTF-8)'
9 # The ':encoding()' part does character set and encoding transformations.
10 # Without it you are just declaring the stream to be of a certain encoding.
11 # See PerlIO, PerlIO::encoding docs.
12  
13 2 ▶sub _iomode_out {
Subroutine _iomode_out: called CC=2 SCAR=7.1
14 2 my ($self) = @_;
15 2 ▶ return { binmode => ':raw' } if $self->encoding_out eq 'none';
Branch: 1 branch
BranchTrueFalseTotal
if $self->encoding_out eq "none" 0 2 2
16 2 return { binmode => ':raw:encoding(' . $self->encoding_out . ')' };
17 }
18  
19 3 ▶sub _iomode_in {
Subroutine _iomode_in: called CC=2 SCAR=7.1
20 3 my ($self) = @_;
21 3 ▶ return { binmode => ':raw' } if $self->encoding_in eq 'none';
Branch: 1 branch
BranchTrueFalseTotal
if $self->encoding_in eq "none" 0 3 3
22 3 return { binmode => ':raw:encoding(' . $self->encoding_in . ')' };
23 }
24  
25 # Filename can be a string, a Path::Tiny obj, or a Path::Class obj.
26 # Returns a Path::Tiny obj.
27 5 ▶sub _path {
Subroutine _path: called CC=2 SCAR=7.2
28 5 my ( $self, $filename ) = @_;
29 5 ▶ return ref $filename eq 'Path::Class::File' #
Branch: 1 branch
BranchTrueFalseTotal
ref $filename eq 'Path::Class::File' ? : 0 5 5
30 ? path("$filename")
31 : path($filename); # works for strings and Path::Tiny objects
32 }
33  
34 3 1;
« lib/Text/vCard/Addressbook.pm ↑ Summary