IOMux/Open.pm

filter: Statementstmt 100% 24 / 24 Branchbran 50.0% 4 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 100% 1 / 1 totaltotal 89.7% 35 / 39 CC 6 SCAR 10.1
CC
6
Cov
88%
import
4.2
new
3.1
BEGIN
1.0
CRAP 2.7
« IOMux/Pipe/Write.pm ↑ Summary IOMux/Handler/Service.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::Open;
10 2 ▶use vars '$VERSION';
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 $VERSION = '1.01';
12  
13  
14 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 2 ▶use Log::Report 'iomux';
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 2 my %modes =
20 ( '-|' => 'IOMux::Pipe::Read'
21 , '|-' => 'IOMux::Pipe::Write'
22 , '|-|' => 'IOMux::IPC'
23 , '|=|' => 'IOMux::IPC'
24 , '>' => 'IOMux::File::Write'
25 , '>>' => 'IOMux::File::Write'
26 , '<' => 'IOMux::File::Read'
27 , tcp => 'IOMux::Net::TCP'
28 );
29  
30 sub import(@)
31 3 ▶{ my $class = shift;
Subroutine import: called CC=4 SCAR=14.3
32 3 foreach my $mode (@_)
33 2 ▶ { my $impl = $modes{$mode}
Branch: 1 branch
BranchTrueFalseTotal
my $impl = $modes{$mode} or &error(&__x("unknown mode {mode} in use {pkg}", "mode", $mode, "pkg", $class)) 2 0 2
34 or error __x"unknown mode {mode} in use {pkg}"
35 , mode => $mode, pkg => $class;
36 2 eval "require $impl";
37 2 ▶ panic $@ if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 2 2
38 }
39 }
40
41  
42 sub new($@)
43 4 ▶{ my ($class, $mode) = (shift, shift);
Subroutine new: called CC=3 SCAR=11.4
Pod documented
44 4 ▶ my $real = $modes{$mode}
Branch: 1 branch
BranchTrueFalseTotal
my $real = $modes{$mode} or &error(&__x("unknown mode '{mode}' to open() on mux", "mode", $mode)) 4 0 4
45 or error __x"unknown mode '{mode}' to open() on mux", mode => $mode;
46  
47 4 ▶ $real->can('open')
Branch: 1 branch
BranchTrueFalseTotal
$real->can("open") or &error(&__x("package {pkg} for mode '{mode}' not required by {me}", "pkg", $real, "mode", $mode, "me", $class)) 4 0 4
48 or error __x"package {pkg} for mode '{mode}' not required by {me}"
49 , pkg => $real, mode => $mode, me => $class;
50  
51 4 $real->open($mode, @_);
52 }
53  
54 #--------------
55  
56 2 1;
« IOMux/Pipe/Write.pm ↑ Summary IOMux/Handler/Service.pm »