line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package vCard::Role::FileIO; |
2
|
|
|
|
|
|
|
$vCard::Role::FileIO::VERSION = '3.09'; |
3
|
3
|
|
|
3
|
|
19665
|
use Moo::Role; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
16
|
|
4
|
3
|
|
|
3
|
|
719
|
use Path::Tiny; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
608
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
sub _iomode_out { |
14
|
2
|
|
|
2
|
|
5
|
my ($self) = @_; |
15
|
2
|
50
|
|
|
|
16
|
return { binmode => ':raw' } if $self->encoding_out eq 'none'; |
16
|
2
|
|
|
|
|
19
|
return { binmode => ':raw:encoding(' . $self->encoding_out . ')' }; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub _iomode_in { |
20
|
3
|
|
|
3
|
|
4
|
my ($self) = @_; |
21
|
3
|
50
|
|
|
|
16
|
return { binmode => ':raw' } if $self->encoding_in eq 'none'; |
22
|
3
|
|
|
|
|
25
|
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
|
|
|
|
|
|
|
sub _path { |
28
|
5
|
|
|
5
|
|
10
|
my ( $self, $filename ) = @_; |
29
|
5
|
50
|
|
|
|
39
|
return ref $filename eq 'Path::Class::File' # |
30
|
|
|
|
|
|
|
? path("$filename") |
31
|
|
|
|
|
|
|
: path($filename); # works for strings and Path::Tiny objects |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
1; |