| 1 | 1 | ▶ | use Object::Pad ':experimental(:all)'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | package IO::Handle::Common::Handle; | ||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | class IO::Handle::Common::Handle : does(IO::Handle::Common::Base); | ||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use utf8; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use v5.40; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | no warnings 'experimental::re_strict'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use re 'strict'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||
| 13 | 1 | ▶ | use Const::Fast; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 1 | ▶ | use Unicode::UTF8; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | 1 | ▶ | use List::Util qw'any none first'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | 1 | ▶ | use Path::Tiny (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | 1 | ▶ | use FileHandle; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | 1 | ▶ | use IO::Handle; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | 1 | ▶ | use IO::Handle::Common::Base qw'refstr'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | 1 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||
| 22 | 1 | const our $DEFAULT_LAYER => 'encoding(UTF-8)'; | |||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||
| 24 | 1 | ▶ | use open ':std', IO => $DEFAULT_LAYER; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||
| 26 | field $charset : param = 'UTF-8'; | ||||||||||||||||||||||||||||||||||||||||||
| 27 | 1 | field $fileno; | |||||||||||||||||||||||||||||||||||||||||
| 28 | field $handle : reader(fh) | ||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | ▶ | ; # TODO: decipher AUTOLOAD logic that led to charset reader here | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fh: not called CC=1 SCAR=2.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 30 | 1 | field $path; | |||||||||||||||||||||||||||||||||||||||||
| 31 | field $mode : param = ">"; | ||||||||||||||||||||||||||||||||||||||||||
| 32 | 1 | field $autoflush : param = 1; | |||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||
| 34 | 1 | ▶ | sub AUTOLOAD { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
AUTOLOAD: not called CC=4 SCAR=28.4
| |||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | our $AUTOLOAD; | |||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | my $invoke = shift; | |||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | const my $meth_re => qr!^.*::!; | |||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | my $method = ( $AUTOLOAD =~ s/$meth_re//r ); | |||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | ▶ | if ( blessed $invoke && $invoke->isa('IO::Handle::Common::Handle') ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
builtin::blessed($invoke) and $invoke->isa("IO::Handle::Common::Handle")
MC/DC0%0/2
builtin::blessed($invoke) and $invoke->isa("IO::Handle::Common::Handle")
builtin::blessed($invoke)
$invoke->isa("IO::Handle::Common::Handle")
Truth table0%0/3
A and B
A= builtin::blessed($invoke)B= $invoke->isa("IO::Handle::Common::Handle")
| |||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | ▶ | if ( my $charset = $invoke->fh ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | $invoke->fh->$method(@_); | |||||||||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||||||||||||||||
| 46 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | die "No class common method '$method' ($AUTOLOAD)"; | |||||||||||||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||
| 51 | 1 | ADJUST : params (:$fn //= undef, :$fh //= undef, :$fd //= undef) { | |||||||||||||||||||||||||||||||||||||||||
| 52 | my @arg = ( $fn, $fh, $fd ); | ||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||
| 54 | die "Only one of the following can be defined: \$fn, \$fh, \$fd" | ||||||||||||||||||||||||||||||||||||||||||
| 55 | if scalar( ( grep { defined $_ } @arg ) > 1 ); | ||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||
| 57 | $handle = IO::Handle->new; | ||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||
| 59 | if ($fn) { | ||||||||||||||||||||||||||||||||||||||||||
| 60 | $path = Path::Tiny::path($fn); | ||||||||||||||||||||||||||||||||||||||||||
| 61 | $handle = $path->filehandle($mode); | ||||||||||||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||||||||||||
| 63 | elsif ($fh) { | ||||||||||||||||||||||||||||||||||||||||||
| 64 | $handle = $fh; | ||||||||||||||||||||||||||||||||||||||||||
| 65 | $fileno = fileno($fh); | ||||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||
| 67 | elsif ($fd) { | ||||||||||||||||||||||||||||||||||||||||||
| 68 | $handle = FileHandle->new_from_fd( $fd, $mode ); | ||||||||||||||||||||||||||||||||||||||||||
| 69 | $handle->binmode($IO::Handle::Common::Handle::DEFAULT_LAYER); | ||||||||||||||||||||||||||||||||||||||||||
| 70 | $fileno = $fd; | ||||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||
| 73 | $handle->autoflush($autoflush) if $handle | ||||||||||||||||||||||||||||||||||||||||||
| 74 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | ▶ | method say ( $say, %opt ) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
say: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | say STDERR Dumper( $self, $say, \%opt ); | |||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | ▶ | if ( refstr($say) eq 'ARRAY' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | $handle->say($_) for @$say; | |||||||||||||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||||||||||||
| 81 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | $handle->say( $handle, $say ); | |||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||
| 84 | 1 | } | |||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | ▶ | method refresh (%opt) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
refresh: not called CC=11 SCAR=48.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 87 | $handle = IO::Handle::Common::Handle->new( | ||||||||||||||||||||||||||||||||||||||||||
| 88 | fd => $opt{fd}, | ||||||||||||||||||||||||||||||||||||||||||
| 89 | mode => $opt{mode} | ||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | ▶ | ) unless $handle && blessed($handle) && $handle->opened; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$handle and builtin::blessed($handle) and $handle->opened
$handle and builtin::blessed($handle)
MC/DC0%0/3
$handle and builtin::blessed($handle) and $handle->opened
$handle
builtin::blessed($handle)
$handle->opened
Truth table0%0/4
A and B and C
A= $handleB= builtin::blessed($handle)C= $handle->opened
| |||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | say STDERR Dumper( $self, \%opt ); | |||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | ▶ | if ( $opt{on} && refstr( $opt{on} ) eq 'CODE' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$opt{"on"} and refstr($opt{"on"}) eq "CODE"
MC/DC0%0/2
$opt{"on"} and refstr($opt{"on"}) eq "CODE"
$opt{"on"}
refstr($opt{"on"}) eq "CODE"
Truth table0%0/3
A and B
A= $opt{"on"}B= refstr($opt{"on"}) eq "CODE"
| |||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | ( delete $opt{on} )->( $handle, %opt ); | |||||||||||||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | ▶ | if ( $opt{method} && $handle->can( $opt{method} ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$opt{"method"} and $handle->can($opt{"method"})
MC/DC0%0/2
$opt{"method"} and $handle->can($opt{"method"})
$opt{"method"}
$handle->can($opt{"method"})
Truth table0%0/3
A and B
A= $opt{"method"}B= $handle->can($opt{"method"})
| |||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | my $package = blessed($handle); | |||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | my $meth = delete $opt{method}; | |||||||||||||||||||||||||||||||||||||||||
| 99 | die "Named parameter 'callarg' must be an ARRAY" | ||||||||||||||||||||||||||||||||||||||||||
| 100 | if $opt{callarg} | ||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | ▶ | && refstr( $opt{callarg} ) ne 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$opt{"callarg"} and refstr($opt{"callarg"}) ne "ARRAY"
MC/DC0%0/2
$opt{"callarg"} and refstr($opt{"callarg"}) ne "ARRAY"
$opt{"callarg"}
refstr($opt{"callarg"}) ne "ARRAY"
Truth table0%0/3
A and B
A= $opt{"callarg"}B= refstr($opt{"callarg"}) ne "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | $handle->$meth( $opt{callarg}->@* ); | |||||||||||||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||
| 105 | $handle->close | ||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | ▶ | unless any { $_ } ( @opt{qw'keep_open noclose interactive'} ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | $self; | |||||||||||||||||||||||||||||||||||||||||
| 109 | 1 | } | |||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | ▶ | method autoflush ( $enable = 1 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
autoflush: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | ▶ | $autoflush = $enable if $autoflush != $enable; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | $handle->autoflush($autoflush); | |||||||||||||||||||||||||||||||||||||||||
| 114 | 1 | } | |||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||
| 116 | method default_layer : common { | ||||||||||||||||||||||||||||||||||||||||||
| 117 | $DEFAULT_LAYER; | ||||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||