OptArgs2/StatusLine.pm

filter: Statementstmt 89.1% 41 / 46 Branchbran 70.0% 14 / 20 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 8 / 8 Podpod 100% 1 / 1 totaltotal 83.3% 65 / 78 CC 13 SCAR 19.5
CC
13
Cov
82%
STORE
11.8
import
4.0
BEGIN
1.0
CRAP 7.0
« OptArgs2/Pager_CI.pm ↑ Summary OptArgs2/Cmd_CI.pm »
1 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 package OptArgs2::StatusLine;
5  
6 11 ▶sub RS { chr(30) }
Subroutine RS: called CC=1 SCAR=0.0
Pod documented
7 1 my $RS = RS;
8  
9 sub TIESCALAR {
10 1 ▶ my $class = shift;
Subroutine TIESCALAR: called CC=1 SCAR=0.0
11 1 bless [], $class;
12 }
13  
14 30 ▶sub FETCH { $_[0]->[0] }
Subroutine FETCH: called CC=1 SCAR=0.0
15  
16 sub STORE {
17 12 ▶ my $self = shift;
Subroutine STORE: called CC=10 SCAR=24.7
18 12 ▶ my $arg = shift // return;
Condition50%1/2
shift() // (return)
l!l
120
MC/DC0%0/1
shift() // (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
19 12 my $str;
20  
21 12 ▶ if ( 'SCALAR' eq ref $arg ) {
Branch: 4 branches
BranchTrueFalseTotal
if ('SCALAR' eq ref $arg) { } 1 11 12
elsif ($arg =~ /$RS/) { } 4 7 11
elsif (not defined $self->[0]) { } 1 6 7
elsif ($self->[0] =~ /(.*)$RS/) { } 6 0 6
22 1 ▶ if ( not defined $self->[0] ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $self->[0]) { } 0 1 1
23 0 $str = $$arg . $RS;
24 }
25 else {
26 1 $str = $self->[0] =~ s/[^$RS]+/$$arg/r;
27 }
28 }
29 elsif ( $arg =~ m/$RS/ ) {
30 4 $str = $arg;
31 }
32 elsif ( not defined $self->[0] ) {
33 1 require File::Basename;
34 1 $str = File::Basename::basename($0) . ': ' . RS . $arg;
35 }
36 elsif ( $self->[0] =~ m/(.*)$RS/ ) {
37 6 $str = $1 . RS . $arg;
38 }
39 else {
40 0 warn "Internal Error - should never happen!";
41 0 return;
42 }
43  
44 12 ▶ my $NL = $str =~ s/\n\z// ? "\n" : "\r";
Branch: 1 branch
BranchTrueFalseTotal
$str =~ s/\n\z// ? : 0 12 12
45 12 my $fh = select;
46  
47 12 ▶ if ( -t $fh ) {
Branch: 1 branch
BranchTrueFalseTotal
if (-t $fh) { } 0 12 12
48 0 $fh->printflush( $str . "\e[K" . $NL );
49 }
50 else {
51 12 $fh->print( $str . "\n" );
52 }
53  
54 12 ▶ $str =~ s/(.*$RS).*/$1/ if $NL eq "\n";
Branch: 1 branch
BranchTrueFalseTotal
if $NL eq "\n" 0 12 12
55 12 $self->[0] = $str;
56 }
57  
58 sub import {
59 1 ▶ my $class = shift;
Subroutine import: called CC=4 SCAR=13.9
60 1 my $caller = scalar caller;
61  
62 1 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
63 1 foreach my $arg (@_) {
64 2 ▶ if ( $arg =~ m/^\$(.*)/ ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($arg =~ /^\$(.*)/) { } 1 1 2
elsif ($arg eq 'RS') { } 1 0 1
65 1 my $name = $1;
66 1 tie my $x, 'OptArgs2::StatusLine';
67 1 *{ $caller . '::' . $name } = \$x;
68 }
69 elsif ( $arg eq 'RS' ) {
70 1 *{ $caller . '::RS' } = \&RS;
71 }
72 else {
73 0 die 'expected "RS" or "$scalar"';
74 }
75  
76 }
77 }
78  
79 1 1;
80  
81 __END__
« OptArgs2/Pager_CI.pm ↑ Summary OptArgs2/Cmd_CI.pm »