blib/lib/Acme/Capture.pm

filter: Statementstmt 52.9% 27 / 51 Branchbran 16.6% 1 / 6 Conditioncond 0.0% 0 / 18 MC/DCmcdc 0.0% 0 / 8 Subroutinesub 35.7% 5 / 14 Podpod 0.0% 0 / 8 totaltotal 31.4% 33 / 105 CC 9 SCAR 34.7
CC
9
Cov
37%
_relayer
76.1
capture
1.8
capture_merged
1.8
CRAP 32.0
↑ Summary
1 package Acme::Capture;
2 1 $Acme::Capture::VERSION = '0.01';
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 ▶use Exporter ();
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Capture::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 #--------------------------------------------------------------------------#
10 # create API subroutines and export them
11 # [do STDOUT flag, do STDERR flag, do merge flag, do tee flag]
12 #--------------------------------------------------------------------------#
13  
14 1 my %api = (
15 capture => [1,1,0,0],
16 capture_stdout => [1,0,0,0],
17 capture_stderr => [0,1,0,0],
18 capture_merged => [1,1,1,0],
19 tee => [1,1,0,1],
20 tee_stdout => [1,0,0,1],
21 tee_stderr => [0,1,0,1],
22 tee_merged => [1,1,1,1],
23 );
24  
25 1 for my $sub (keys %api) {
26 8 my $args = join q{, }, @{$api{$sub}};
27 0 ▶ eval "sub $sub(&;@) { unshift \@_, $args; goto \\&Capture::Tiny::_capture_tee; }"; ## no critic
Subroutine capture: not called CC=1 SCAR=6.1
Subroutine capture_merged: not called CC=1 SCAR=6.1
Subroutine capture_stderr: not called CC=1 SCAR=6.1
Subroutine capture_stdout: not called CC=1 SCAR=6.1
Subroutine tee: not called CC=1 SCAR=6.1
Subroutine tee_merged: not called CC=1 SCAR=6.1
Subroutine tee_stderr: not called CC=1 SCAR=6.1
Subroutine tee_stdout: not called CC=1 SCAR=6.1
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
28 }
29  
30 {
31 1 ▶ no warnings 'redefine';
Subroutine BEGIN: called CC=1 SCAR=0.0
32 0 ▶ eval <<'EOT' or die "Can't redefine _relayer() ==> $@";
Subroutine _relayer: not called CC=9 SCAR=43.3
Branch: 3 branches
BranchTrueFalseTotal
@$layers > 4 && $layers->[0] eq 'unix' && $layers->[1] eq 'crlf' && $layers->[2] eq 'utf8' && $layers->[3] eq 'unix' && $layers->[4] eq 'encoding(utf8)' ? : 0 0 0
if ($unix_utf8_crlf and $^O eq 'MSWin32') { } 0 0 0
eval " sub Capture::Tiny::_relayer {\n my (\$fh, \$layers) = \@_;\n\n my \$unix_utf8_crlf = \@\$layers > 4\n && \$layers->[0] eq 'unix'\n && \$layers->[1] eq 'crlf'\n && \$layers->[2] eq 'utf8'\n && \$layers->[3] eq 'unix'\n && \$layers->[4] eq 'encoding(utf8)' ? 1 : 0;\n\n if (\$unix_utf8_crlf and \$^O eq 'MSWin32') {\n binmode(\$fh, ':unix:encoding(utf8):crlf');\n }\n else {\n # _debug(\"# requested layers (\@{\$layers}) for \@{[fileno \$fh]}\\n\");\n my %seen = ( unix => 1, perlio => 1 ); # filter these out\n my \@unique = grep { !\$seen{\$_}++ } \@\$layers;\n # _debug(\"# applying unique layers (\@unique) to \@{[fileno \$fh]}\\n\");\n binmode(\$fh, join(\":\", \":raw\", \@unique));\n }\n };\n\n 1;\n" or die "Can't redefine _relayer() ==> $@" 1 0 1
Condition0%0/18
@$layers > 4 and $layers->[0] eq "unix" and $layers->[1] eq "crlf" and $layers->[2] eq "utf8" and $layers->[3] eq "unix" and $layers->[4] eq "encoding(utf8)"
!ll&&!rl&&r
000
@$layers > 4 and $layers->[0] eq "unix" and $layers->[1] eq "crlf" and $layers->[2] eq "utf8" and $layers->[3] eq "unix"
!ll&&!rl&&r
000
@$layers > 4 and $layers->[0] eq "unix" and $layers->[1] eq "crlf" and $layers->[2] eq "utf8"
!ll&&!rl&&r
000
@$layers > 4 and $layers->[0] eq "unix" and $layers->[1] eq "crlf"
!ll&&!rl&&r
000
@$layers > 4 and $layers->[0] eq "unix"
!ll&&!rl&&r
000
$unix_utf8_crlf and $^O eq "MSWin32"
!ll&&!rl&&r
000
MC/DC0%0/6
@$layers > 4 and $layers->[0] eq "unix" and $layers->[1] eq "crlf" and $layers->[2] eq "utf8" and $layers->[3] eq "unix" and $layers->[4] eq "encoding(utf8)"
@$layers > 4 $layers->[0] eq "unix" $layers->[1] eq "crlf" $layers->[2] eq "utf8" $layers->[3] eq "unix" $layers->[4] eq "encoding(utf8)"
MC/DC0%0/2
$unix_utf8_crlf and $^O eq "MSWin32"
$unix_utf8_crlf $^O eq "MSWin32"
Truth table0%0/7
A and B and C and D and E and F
A= @$layers > 4B= $layers->[0] eq "unix"C= $layers->[1] eq "crlf"D= $layers->[2] eq "utf8"E= $layers->[3] eq "unix"F= $layers->[4] eq "encoding(utf8)"
ABCDEFresult
0XXXXX0
10XXXX0
110XXX0
1110XX0
11110X0
1111100
1111111
Truth table0%0/3
A and B
A= $unix_utf8_crlfB= $^O eq "MSWin32"
ABresult
0X0
100
111
33 sub Capture::Tiny::_relayer {
34 my ($fh, $layers) = @_;
35  
36 my $unix_utf8_crlf = @$layers > 4
37 && $layers->[0] eq 'unix'
38 && $layers->[1] eq 'crlf'
39 && $layers->[2] eq 'utf8'
40 && $layers->[3] eq 'unix'
41 && $layers->[4] eq 'encoding(utf8)' ? 1 : 0;
42  
43 if ($unix_utf8_crlf and $^O eq 'MSWin32') {
44 binmode($fh, ':unix:encoding(utf8):crlf');
45 }
46 else {
47 # _debug("# requested layers (@{$layers}) for @{[fileno $fh]}\n");
48 my %seen = ( unix => 1, perlio => 1 ); # filter these out
49 my @unique = grep { !$seen{$_}++ } @$layers;
50 # _debug("# applying unique layers (@unique) to @{[fileno $fh]}\n");
51 binmode($fh, join(":", ":raw", @unique));
52 }
53 };
54  
55 1;
56 EOT
57 }
58  
59 1 our @ISA = qw/Exporter/;
60 1 our @EXPORT_OK = keys %api;
61 1 our %EXPORT_TAGS = ( 'all' => \@EXPORT_OK );
62  
63 1 1;
64  
65 __END__
↑ Summary