IOMux/Bundle.pm

filter: Statementstmt 64.1% 50 / 78 Branchbran 37.5% 9 / 24 Conditioncond 22.2% 2 / 9 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 51.7% 15 / 29 Podpod 95.2% 20 / 21 totaltotal 57.4% 96 / 167 CC 18 SCAR 18.4
CC
18
Cov
55%
init
18.1
muxReadFlagged
12.0
muxRemove
6.0
CRAP 6.3
« IOMux/Poll.pm ↑ Summary IOMux/File/Read.pm »
1 # Copyrights 2011-2020 by [Mark Overmeer <markov@cpan.org>].
2 # For other contributors see ChangeLog.
3 # See the manual pages for details on the licensing terms.
4 # Pod stripped from pm file by OODoc 2.02.
5 # This code is part of distribution IOMux. Meta-POD processed with OODoc
6 # into POD and HTML manual-pages. See README.md
7 # Copyright Mark Overmeer. Licensed under the same terms as Perl itself.
8  
9 package IOMux::Bundle;
10 3 ▶use vars '$VERSION';
Subroutine BEGIN: called CC=1 SCAR=0.0
11 3 $VERSION = '1.01';
12  
13 3 ▶use base 'IOMux::Handler::Read', 'IOMux::Handler::Write';
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 3 ▶use Log::Report 'iomux';
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 3 ▶use Scalar::Util qw(blessed);
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 ##### WORK IN PROGRESS!
23  
24  
25 sub init($)
26 1 ▶{ my ($self, $args) = @_;
Subroutine init: called CC=10 SCAR=29.0
Pod undocumented
27  
28 # stdin to be a writer is a bit counter-intuitive, therefore some
29 # extra tests.
30  
31 1 my @filenos;
32 1 my $name = $args->{name};
33  
34 my $in = $self->{IMB_stdin} = $args->{stdin}
35 1 ▶ or error __x"no stdin handler for {name}", name => $name;
Branch: 1 branch
BranchTrueFalseTotal
my $in = $self->{"IMB_stdin"} = $args->{"stdin"} or &error(&__x("no stdin handler for {name}", "name", $name)) 1 0 1
36 1 ▶ blessed $in && $in->isa('IOMux::Handler::Write')
Branch: 1 branch
BranchTrueFalseTotal
builtin::blessed($in) and $in->isa("IOMux::Handler::Write") or &error(&__x("stdin {name} is not at writer", "name", $name)) 1 0 1
Condition33%1/3
builtin::blessed($in) and $in->isa("IOMux::Handler::Write")
!ll&&!rl&&r
001
MC/DC0%0/2
builtin::blessed($in) and $in->isa("IOMux::Handler::Write")
builtin::blessed($in) $in->isa("IOMux::Handler::Write")
Truth table33%1/3
A and B
A= builtin::blessed($in)B= $in->isa("IOMux::Handler::Write")
ABresult
0X0
100
111
37 or error __x"stdin {name} is not at writer", name => $name;
38 1 push @filenos, $in->fileno;
39  
40 my $out = $self->{IMB_stdout} = $args->{stdout}
41 1 ▶ or error __x"no stdout handler for {name}", name => $name;
Branch: 1 branch
BranchTrueFalseTotal
my $out = $self->{"IMB_stdout"} = $args->{"stdout"} or &error(&__x("no stdout handler for {name}", "name", $name)) 1 0 1
42 1 ▶ blessed $out && $out->isa('IOMux::Handler::Read')
Branch: 1 branch
BranchTrueFalseTotal
builtin::blessed($out) and $out->isa("IOMux::Handler::Read") or &error(&__x("stdout {name} is not at reader", "name", $name)) 1 0 1
Condition33%1/3
builtin::blessed($out) and $out->isa("IOMux::Handler::Read")
!ll&&!rl&&r
001
MC/DC0%0/2
builtin::blessed($out) and $out->isa("IOMux::Handler::Read")
builtin::blessed($out) $out->isa("IOMux::Handler::Read")
Truth table33%1/3
A and B
A= builtin::blessed($out)B= $out->isa("IOMux::Handler::Read")
ABresult
0X0
100
111
43 or error __x"stdout {name} is not at reader", name => $name;
44 1 push @filenos, $out->fileno;
45  
46 1 ▶ if(my $err = $self->{IMB_stderr} = $args->{stderr})
Branch: 1 branch
BranchTrueFalseTotal
if (my $err = $self->{"IMB_stderr"} = $args->{"stderr"}) 0 1 1
47 0 ▶ { blessed $err && $err->isa('IOMux::Handler::Read')
Branch: 1 branch
BranchTrueFalseTotal
builtin::blessed($err) and $err->isa("IOMux::Handler::Read") or &error(&__x("stderr {name} is not at reader", "name", $name)) 0 0 0
Condition0%0/3
builtin::blessed($err) and $err->isa("IOMux::Handler::Read")
!ll&&!rl&&r
000
MC/DC0%0/2
builtin::blessed($err) and $err->isa("IOMux::Handler::Read")
builtin::blessed($err) $err->isa("IOMux::Handler::Read")
Truth table0%0/3
A and B
A= builtin::blessed($err)B= $err->isa("IOMux::Handler::Read")
ABresult
0X0
100
111
48 or error __x"stderr {name} is not at reader", name => $name;
49 0 push @filenos, $err->fileno;
50 }
51  
52 1 $args->{name} .= ', ('.join(',',@filenos).')';
53  
54 1 $self->SUPER::init($args);
55  
56 1 $self->{IMB_filenos} = \@filenos;
57 1 $self;
58 }
59  
60 #---------------
61  
62 2 ▶sub stdin() {shift->{IMB_stdin}}
Subroutine stdin: called CC=1 SCAR=0.0
Pod documented
63 0 ▶sub stdout() {shift->{IMB_stdout}}
Subroutine stdout: not called CC=1 SCAR=6.9
Pod documented
64 0 ▶sub stderr() {shift->{IMB_stderr}}
Subroutine stderr: not called CC=1 SCAR=6.9
Pod documented
65  
66  
67 sub connections()
68 1 ▶{ my $s = shift;
Subroutine connections: called CC=1 SCAR=0.0
Pod documented
69 1 grep defined, $s->{IMB_stdin}, $s->{IMB_stdout}, $s->{IMB_stderr};
70 }
71  
72 #---------------
73  
74 # say, print and printf use write()
75 2 ▶sub write(@) { shift->{IMB_stdin}->write(@_) }
Subroutine write: called CC=1 SCAR=0.0
Pod documented
76 0 ▶sub muxOutbufferEmpty() { shift->{IMB_stdin}->muxOutbufferEmpty(@_) }
Subroutine muxOutbufferEmpty: not called CC=1 SCAR=6.9
Pod documented
77 0 ▶sub muxOutputWaiting() { shift->{IMB_stdin}->muxOutputWaiting(@_) }
Subroutine muxOutputWaiting: not called CC=1 SCAR=6.9
Pod documented
78 0 ▶sub muxWriteFlagged() { shift->{IMB_stdin}->muxWriteFlagged(@_) }
Subroutine muxWriteFlagged: not called CC=1 SCAR=6.9
Pod documented
79  
80 0 ▶sub readline(@) { shift->{IMB_stdout}->readline(@_) }
Subroutine readline: not called CC=1 SCAR=6.9
Pod documented
81 1 ▶sub slurp(@) { shift->{IMB_stdout}->slurp(@_) }
Subroutine slurp: called CC=1 SCAR=0.0
Pod documented
82 0 ▶sub muxInput($) { shift->{IMB_stdout}->muxInput(@_) }
Subroutine muxInput: not called CC=1 SCAR=6.9
Pod documented
83 0 ▶sub muxEOF($) { shift->{IMB_stdout}->muxEOF(@_) }
Subroutine muxEOF: not called CC=1 SCAR=6.9
Pod documented
84  
85 sub muxReadFlagged($)
86 0 ▶{ my ($self, $fileno) = @_;
Subroutine muxReadFlagged: not called CC=3 SCAR=24.8
Pod documented
87 0 ▶ if(my $e = $self->{IMB_stderr})
Branch: 1 branch
BranchTrueFalseTotal
if (my $e = $self->{"IMB_stderr"}) 0 0 0
88 0 ▶ { return $e->muxReadFlagged(@_)
Branch: 1 branch
BranchTrueFalseTotal
if $fileno == $e->fileno 0 0 0
89 if $fileno==$e->fileno;
90 }
91 0 $self->{IMB_stdin}->muxReadFlagged(@_);
92 }
93  
94 0 ▶sub timeout() { shift->{IMB_stdin}->timeout(@_) }
Subroutine timeout: not called CC=1 SCAR=6.9
Pod documented
95  
96 sub close(;$)
97 1 ▶{ my ($self, $cb) = @_;
Subroutine close: called CC=2 SCAR=8.1
Pod documented
98 my $close_error = sub
99 0 ▶ { if(my $err = $self->{IMB_stderr}) { $err->close($cb) }
Subroutine __ANON__: called CC=3 SCAR=15.4
Branch: 2 branches
BranchTrueFalseTotal
if (my $err = $self->{'IMB_stderr'}) { } 0 1 1
elsif ($cb) { } 0 1 1
100 0 elsif($cb) { $cb->($self) }
101 1 };
102  
103 my $close_out = sub
104 1 ▶ { if(my $out = $self->{IMB_stdout}) { $out->close($close_error) }
Subroutine __ANON__: called CC=2 SCAR=8.1
Branch: 1 branch
BranchTrueFalseTotal
if (my $out = $self->{'IMB_stdout'}) { } 1 0 1
105 0 else { $close_error->() }
106 1 };
107  
108 1 ▶ if(my $in = $self->{IMB_stdin}) { $in->close($close_out) }
Branch: 1 branch
BranchTrueFalseTotal
if (my $in = $self->{'IMB_stdin'}) { } 1 0 1
109 0 else { $close_out->() }
110 }
111  
112 sub muxRemove()
113 0 ▶{ my $self = shift;
Subroutine muxRemove: not called CC=2 SCAR=17.9
Pod documented
114 0 $_->muxRemove for $self->connections;
115 0 trace "mux remove bundle ".$self->name;
116 }
117  
118 sub muxInit($)
119 1 ▶{ my ($self, $mux) = @_;
Subroutine muxInit: called CC=2 SCAR=6.9
Pod documented
120  
121 $_->muxInit($mux, $self) # I want control
122 1 for $self->connections;
123  
124 1 trace "mux add bundle ".$self->name;
125 }
126  
127 #---------------
128
129 sub muxError($)
130 0 ▶{ my ($self, $errbuf) = @_;
Subroutine muxError: not called CC=1 SCAR=6.9
Pod documented
131 0 print STDERR $$errbuf;
132 0 $$errbuf = '';
133 }
134  
135 #---------------
136  
137 sub show()
138 0 ▶{ my $self = shift;
Subroutine show: not called CC=1 SCAR=6.9
Pod documented
139 0 join "\n", (map $_->show, $self->connections), '';
140 }
141  
142 0 ▶sub fdset() {panic}
Subroutine fdset: not called CC=1 SCAR=6.9
Pod documented
143  
144 3 1;
« IOMux/Poll.pm ↑ Summary IOMux/File/Read.pm »