IOMux/File/Read.pm

filter: Statementstmt 92.8% 39 / 42 Branchbran 50.0% 5 / 10 Conditioncond 20.0% 1 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 90.0% 9 / 10 Podpod 66.6% 2 / 3 totaltotal 76.7% 56 / 73 CC 8 SCAR 17.4
CC
8
Cov
79%
init
10.9
mode
2.0
BEGIN
1.0
CRAP 5.7
« IOMux/Bundle.pm ↑ Summary IOMux/Pipe/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::File::Read;
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';
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 3 ▶use Fcntl;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 3 ▶use File::Basename 'basename';
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22  
23 sub init($)
24 4 ▶{ my ($self, $args) = @_;
Subroutine init: called CC=8 SCAR=23.9
Pod undocumented
25  
26 my $file = $args->{file}
27 4 ▶ or error __x"no file to open specified in {pkg}", pkg => __PACKAGE__;
Branch: 1 branch
BranchTrueFalseTotal
my $file = $args->{"file"} or &error(&__x("no file to open specified in {pkg}", "pkg", __PACKAGE__)) 4 0 4
28  
29 4 my $flags = $args->{modeflags};
30 4 ▶ unless(ref $file || defined $flags)
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $file or defined $flags) 4 0 4
Condition33%1/3
ref $file or defined $flags
l!l&&r!l&&!r
004
MC/DC0%0/2
ref $file or defined $flags
ref $file defined $flags
Truth table33%1/3
A or B
A= ref $fileB= defined $flags
ABresult
1X1
011
000
31 4 { $flags = O_RDONLY|O_NONBLOCK;
32 4 ▶ $flags |= O_EXCL if $args->{exclusive};
Branch: 1 branch
BranchTrueFalseTotal
if $args->{"exclusive"} 0 4 4
33 }
34  
35 4 my $fh;
36 4 ▶ if(ref $file)
Branch: 1 branch
BranchTrueFalseTotal
if (ref $file) { } 0 4 4
37 0 { $fh = $file;
38 0 ▶ $self->{IMFR_mode} = $args->{mode} || '<';
Condition0%0/2
$args->{'mode'} || '<'
l!l
00
MC/DC0%0/1
$args->{'mode'} || '<'
$args->{'mode'}
Truth table0%0/2
A
A= $args->{'mode'}
Aresult
11
00
39 }
40 else
41 4 ▶ { sysopen $fh, $file, $flags
Branch: 1 branch
BranchTrueFalseTotal
sysopen $fh, $file, $flags or &fault(&__x("cannot open file {fn} for {pkg}", "fn", $file, "pkg", __PACKAGE__)) 4 0 4
42 or fault __x"cannot open file {fn} for {pkg}"
43 , fn => $file, pkg => __PACKAGE__;
44 4 $self->{IMFR_mode} = $flags;
45 }
46 4 $args->{name} = '<'.(basename $file);
47 4 $args->{fh} = $fh;
48  
49 4 $self->SUPER::init($args);
50 4 $self;
51 }
52  
53  
54 sub open($$@)
55 2 ▶{ my ($class, $mode, $file, %args) = @_;
Subroutine open: called CC=1 SCAR=0.0
Pod documented
56 2 $class->new(file => $file, mode => $mode, %args);
57 }
58  
59 #-------------------
60  
61 0 ▶sub mode() {shift->{IMFR_mode}}
Subroutine mode: not called CC=1 SCAR=6.9
Pod documented
62  
63 3 1;
« IOMux/Bundle.pm ↑ Summary IOMux/Pipe/Read.pm »