Data/Unixish/_pad.pm

filter: Statementstmt 91.8% 45 / 49 Branchbran 60.0% 6 / 10 Conditioncond 100% 5 / 5 MC/DCmcdc 100% 3 / 3 Subroutinesub 100% 12 / 12 Podpod n/a totaltotal 89.8% 71 / 79 CC 8 SCAR 12.3
CC
8
Cov
88%
__pad_item
8.0
_pad
2.0
__pad_begin
2.0
CRAP 3.4
« Data/Unixish/cond.pm ↑ Summary Data/Unixish/splice.pm »
1 package Data::Unixish::_pad;
2  
3 13 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 13 ▶use locale;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 13 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 13 ▶use syntax 'each_on_array'; # to support perl < 5.12
Subroutine BEGIN: called CC=1 SCAR=0.0
7 13 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 #use Log::Any '$log';
9  
10 13 ▶use String::Pad qw(pad);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 13 ▶use Text::ANSI::Util qw(ta_pad);
Subroutine BEGIN: called CC=1 SCAR=0.0
12 13 ▶use Text::ANSI::WideUtil qw(ta_mbpad);
Subroutine BEGIN: called CC=1 SCAR=0.0
13 13 ▶use Text::WideChar::Util qw(mbpad);
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 13 our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
16 13 our $DATE = '2025-02-24'; # DATE
17 13 our $DIST = 'Data-Unixish'; # DIST
18 13 our $VERSION = '1.574'; # VERSION
19  
20 17 ▶sub _pad {
Subroutine _pad: called CC=2 SCAR=6.9
21 17 my ($which, %args) = @_;
22 17 my ($in, $out) = ($args{in}, $args{out});
23  
24 17 __pad_begin($which, \%args);
25 17 ▶ while (my ($index, $item) = each @$in) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each @$in) 91 17 108
26 91 push @$out, __pad_item($which, $item, \%args);
27 }
28  
29 17 [200, "OK"];
30 }
31  
32 23 ▶sub __pad_begin {
Subroutine __pad_begin: called CC=2 SCAR=6.9
33 23 my ($which, $args) = @_;
34 23 ▶ $args->{char} //= ' ';
Condition100%2/2
$args->{"char"} //= " "
l!l
1112
MC/DC100%1/1
$args->{"char"} //= " "
$args->{"char"}
Truth table100%2/2
A
A= $args->{"char"}
Aresult
11
00
35 }
36  
37 127 ▶sub __pad_item {
Subroutine __pad_item: called CC=6 SCAR=20.8
38 127 my ($which, $item, $args) = @_;
39  
40 {
41 127 ▶ last if !defined($item) || ref($item);
Branch: 1 branch
BranchTrueFalseTotal
if not defined $item or ref $item 36 91 127
Condition100%3/3
not defined $item or ref $item
l!l&&r!l&&!r
122491
MC/DC100%2/2
not defined $item or ref $item
not defined $item ref $item
Truth table100%3/3
not(A) or B
A= not defined $itemB= ref $item
ABresult
1X1
011
000
42 91 ▶ if ($args->{ansi}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($args->{'ansi'}) { } 0 91 91
elsif ($args->{'mb'}) { } 0 91 91
43 0 ▶ if ($args->{mb}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args->{'mb'}) { } 0 0 0
44 $item = ta_mbpad($item, $args->{width}, $which,
45 0 $args->{char}, $args->{trunc});
46 } else {
47 $item = ta_pad ($item, $args->{width}, $which,
48 0 $args->{char}, $args->{trunc});
49 }
50 } elsif ($args->{mb}) {
51 $item = mbpad($item, $args->{width}, $which,
52 0 $args->{char}, $args->{trunc});
53 } else {
54 $item = pad ($item, $args->{width}, $which,
55 91 $args->{char}, $args->{trunc});
56 }
57 }
58 127 return $item;
59 }
60  
61 13 1;
62 # ABSTRACT: _pad
63  
64 __END__
« Data/Unixish/cond.pm ↑ Summary Data/Unixish/splice.pm »