All/Pipe.pm

filter: Statementstmt 89.1% 33 / 37 Branchbran 37.5% 6 / 16 Conditioncond 40.0% 2 / 5 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 87.5% 7 / 8 Podpod 66.6% 2 / 3 totaltotal 70.4% 50 / 71 SCAR 26.4
CC
11
Cov
71%
open_msg
12.0
open
6.8
_assert_open
3.1
CRAP 14.0
« All/MLDBM.pm ↑ Summary All/STDIO.pm »
1 3 ▶use strict; use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
2 package IO::All::Pipe;
3  
4 3 ▶use IO::All -base;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶use IO::File;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 3 const type => 'pipe';
8  
9 sub pipe {
10 2 ▶ my $self = shift;
Subroutine pipe: called CC=2 SCAR=7.0
Pod documented
11 2 bless $self, __PACKAGE__;
12 2 ▶ $self->name(shift) if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 2 0 2
13 2 return $self->_init;
14 }
15  
16 sub _assert_open {
17 2 ▶ my $self = shift;
Subroutine _assert_open: called CC=3 SCAR=11.4
18 2 ▶ return if $self->is_open;
Branch: 1 branch
BranchTrueFalseTotal
if $self->is_open 0 2 2
19 2 ▶ $self->mode(shift) unless $self->mode;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->mode 2 0 2
20 2 $self->open;
21 }
22  
23 sub open {
24 2 ▶ my $self = shift;
Subroutine open: called CC=6 SCAR=19.2
Pod documented
25 2 $self->is_open(1);
26 2 require IO::Handle;
27 2 ▶ $self->io_handle(IO::Handle->new)
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->io_handle 2 0 2
28 unless defined $self->io_handle;
29 2 my $command = $self->name;
30 2 $command =~ s/(^\||\|$)//;
31 2 ▶ my $mode = shift || $self->mode || '<';
Condition40%2/5
shift() || $self->mode || '<'
l!l
20
shift() or $self->mode
l!l&&r!l&&!r
020
MC/DC0%0/2
shift() || $self->mode || '<'
shift() $self->mode
Truth table33%1/3
A or B
A= shift()B= $self->mode
ABresult
1X1
011
000
32 2 ▶ my $pipe_mode =
Branch: 2 branches
BranchTrueFalseTotal
$mode eq '>' ? : 0 2 2
$mode eq '<' ? : 2 0 2
33 $mode eq '>' ? '|-' :
34 $mode eq '<' ? '-|' :
35 $self->throw("Invalid usage mode '$mode' for pipe");
36 2 CORE::open($self->io_handle, $pipe_mode, $command);
37 2 $self->_set_binmode;
38 }
39  
40 3 my %mode_msg = (
41 '>' => 'output',
42 '<' => 'input',
43 '>>' => 'append',
44 );
45 sub open_msg {
46 0 ▶ my $self = shift;
Subroutine open_msg: not called CC=3 SCAR=24.8
Pod undocumented
47 0 ▶ my $name = defined $self->name
Branch: 1 branch
BranchTrueFalseTotal
defined $self->name ? : 0 0 0
48 ? " '" . $self->name . "'"
49 : '';
50 my $direction = defined $mode_msg{$self->mode}
51 0 ▶ ? ' for ' . $mode_msg{$self->mode}
Branch: 1 branch
BranchTrueFalseTotal
defined $mode_msg{$self->mode} ? : 0 0 0
52 : '';
53 0 return qq{Can't open pipe$name$direction:\n$!};
54 }
55  
56 3 1;
« All/MLDBM.pm ↑ Summary All/STDIO.pm »