Pager/Unbuffered.pm

filter: Statementstmt 96.4% 27 / 28 Branchbran 60.0% 6 / 10 Conditioncond 55.5% 5 / 9 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 83.3% 5 / 6 Podpod 100% 2 / 2 totaltotal 75.0% 45 / 60 SCAR 22.6
CC
9
Cov
81%
new
10.3
open
2.0
BEGIN
1.0
CRAP 9.6
« Pager/less.pm ↑ Summary Pager/Page.pm »
1 package IO::Pager::Unbuffered;
2 4 our $VERSION = 1.04; #Untouched since 1.02
3  
4 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 4 ▶use base qw( IO::Pager );
Subroutine BEGIN: called CC=1 SCAR=0.0
7 4 ▶use SelectSaver;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9  
10 sub new(;$) { # [FH], procedural
11 5 ▶ my($class, $tied_fh);
Subroutine new: called CC=9 SCAR=23.3
Pod documented
12  
13 5 eval { ($class, $tied_fh) = &IO::Pager::_init };
14 #We're not on a TTY so...
15 5 ▶ if( defined($class) && $class eq '0' or $@ =~ '!TTY' ){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $class and $class eq 0 or $@ =~ /!TTY/) 2 3 5
Condition66%4/6
defined $class and $class eq 0 or $@ =~ /!TTY/
l!l&&r!l&&!r
023
defined $class and $class eq 0
!ll&&!rl&&r
230
MC/DC0%0/3
defined $class and $class eq 0 or $@ =~ /!TTY/
defined $class $class eq 0 $@ =~ /!TTY/
Truth table40%2/5
A and B or C
A= defined $classB= $class eq 0C= $@ =~ /!TTY/
ABCresult
11X1
0X11
1011
0X00
1000
16 #...leave filehandle alone if procedural
17 2 ▶ return $_[1] if defined($_[2]) && $_[2] eq 'procedural';
Branch: 1 branch
BranchTrueFalseTotal
if defined $_[2] and $_[2] eq "procedural" 0 2 2
Condition33%1/3
defined $_[2] and $_[2] eq "procedural"
!ll&&!rl&&r
200
MC/DC0%0/2
defined $_[2] and $_[2] eq "procedural"
defined $_[2] $_[2] eq "procedural"
Truth table33%1/3
A and B
A= defined $_[2]B= $_[2] eq "procedural"
ABresult
0X0
100
111
18  
19 #...fall back to IO::Handle for transparent OO programming
20 2 ▶ eval "require IO::Handle" or die $@;
Branch: 1 branch
BranchTrueFalseTotal
eval "require IO::Handle" or die $@ 0 2 2
21 2 return IO::Handle->new_from_fd(fileno($_[1]), 'w');
22 }
23 3 ▶ $!=$@, return 0 if $@ =~ 'pipe';
Branch: 1 branch
BranchTrueFalseTotal
if $@ =~ /pipe/ 0 3 3
24  
25 3 ▶ my $self = tie *$tied_fh, $class, $tied_fh or return 0;
Branch: 1 branch
BranchTrueFalseTotal
my $self = tie(*$tied_fh, $class, $tied_fh) or return 0 0 1 1
26 { # Truly unbuffered
27 1 my $saver = SelectSaver->new($self->{real_fh});
28 1 $|=1;
29 }
30 1 return $self;
31 }
32  
33 #Punt to base, preserving FH ($_[0]) for pass by reference to gensym
34 sub open(;$) { # [FH]
35 # IO::Pager::open($_[0], 'IO::Pager::Unbuffered');
36 0 ▶ &new('IO::Pager::procedural', $_[0], 'procedural');
Subroutine open: not called CC=1 SCAR=6.9
Pod documented
37 }
38  
39  
40 4 1;
41  
42 __END__
« Pager/less.pm ↑ Summary Pager/Page.pm »