| 1 | package Text::PrettyTable; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | Text::PrettyTable - Allow for auto-fixed-width formatting of raw data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | =head1 DEPENDENCIES | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | This module doesn't require any dependencies. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 6 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 6 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 6 | ▶ | use base qw(Exporter); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 6 | our $VERSION = '0.03'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 6 | our @border = ('| ', ' | ', ' |', ' ', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | '+-', '-+-', '-+', '-', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | '+-', '-+-', '-+', '-', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | '+-', '-+-', '-+', '-'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 6 | our @borderu = ("│ ", " │ ", " │", ' ', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | '┌─', '─┬─', '─┐', '─', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | '├─', '─┼─', '─┤', '─', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | '└─', '─┴─', '─┘', '─'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 6 | our $unibox = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 6 | our $split = 100; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 6 | our $qr_escape = "[^ -~]"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 6 | our @EXPORT = qw(pretty_table); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 15 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 15 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 15 | ▶ | return bless ref($_[0]) ? $_[0] : {@_}, $class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 2 | ▶ | sub pretty_table { __PACKAGE__->tablify(@_) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pretty_table: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 1 | ▶ | sub plain_text { goto &tablify } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
plain_text: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 26 | ▶ | sub tablify { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
tablify: called CC=49 SCAR=52.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 26 | my ($self, $data, $args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 26 | ▶ | if (!ref $self) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 4 | ▶ | $self = $self->new($args || {}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$args || {}
MC/DC100%1/1
$args || {}
$args
Truth table100%2/2
A
A= $args
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | } elsif ($args) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | # Override settings in new object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 7 | my $new_p = __PACKAGE__->new({ %$self, %$args }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | # Clean call without $args | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 7 | return $new_p->tablify($data); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 19 | ▶ | local $self->{'_level'} = 1 + ($self->{'_level'} || 0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{'_level'} || 0
MC/DC0%0/1
$self->{'_level'} || 0
$self->{'_level'}
Truth table50%1/2
A
A= $self->{'_level'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 19 | ▶ | my $uni = exists($self->{'unibox'}) ? $self->{'unibox'} : $unibox; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 19 | ▶ | local $split = $self->{'split'} || $split if $self->{'_level'} == 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{'split'} || $Text::PrettyTable::split
MC/DC0%0/2
$self->{'split'} || $Text::PrettyTable::split
$self->{'split'}
$Text::PrettyTable::split
Truth table33%1/3
A || B
A= $self->{'split'}B= $Text::PrettyTable::split
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 240 | local @border = ref($uni) ? @$uni : map {utf8::decode(my $c = $_); $c} @borderu | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 19 | ▶ | and !$uni or local $qr_escape = "[^ -~".join('', @border)."]" if $uni && $self->{'_level'} == 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition54%6/11
$uni && $self->{'_level'} == 1 && ((local(@Text::PrettyTable::border) = ref $uni ? @$uni : map({utf8::decode(my $c = $_);
$c;} @borderu)) && !$uni || (local $qr_escape = '[^ -~' . join('', @border) . ']'))
$uni and $self->{"_level"} == 1
local(@border) = ref $uni ? @$uni : map({utf8::decode(my $c = $_);
$c;} @borderu) and not $uni or local $qr_escape = '[^ -~' . join("", @border) . ']'
local(@border) = ref $uni ? @$uni : map({utf8::decode(my $c = $_);
$c;} @borderu) and not $uni
MC/DC0%0/4
$uni && $self->{'_level'} == 1 && ((local(@Text::PrettyTable::border) = ref $uni ? @$uni : map({utf8::decode(my $c = $_);
$c;} @borderu)) && !$uni || (local $qr_escape = '[^ -~' . join('', @border) . ']'))
$uni
$self->{"_level"} == 1
local(@border) = ref $uni ? @$uni : map({utf8::decode(my $c = $_);
$c;} @borderu)
not $uni
Truth table20%1/5
A and B && C and not(D)
A= $uniB= $self->{"_level"} == 1C= local(@border) = ref $uni ? @$uni : map({utf8::decode(my $c = $_);
$c;} @borderu)D= not $uni
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 19 | my @bucket; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | my @title; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 19 | my @max; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 19 | my @dir; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 32 | ▶ | my $add = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=21 SCAR=39.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 32 | my ($cols, $bucket) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 32 | ▶ | if (!ref($cols)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | ▶ | for my $chunk ($split ? map {/(.{$split}|.+)/g} split /\n/, $cols : split /\n/, $cols) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | push @$bucket, $chunk; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 32 | my $i = @$bucket; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 32 | for my $j (0 .. $#$cols) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 78 | my $_split = $split; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 78 | my $val = $cols->[$j]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 78 | ▶ | if (! defined $val) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | $val = '(undef)'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | } elsif (ref $val) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 1 | ▶ | if (UNIVERSAL::isa($val, 'SCALAR')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 1 | ▶ | $val = (defined(&JSON::true) && JSON::true() eq $val) ? '(true)' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%2/6
defined &JSON::true and JSON::true() eq $val
defined &JSON::false and JSON::false() eq $val
MC/DC0%0/2
defined &JSON::true and JSON::true() eq $val
defined &JSON::true
JSON::true() eq $val
MC/DC0%0/2
defined &JSON::false and JSON::false() eq $val
defined &JSON::false
JSON::false() eq $val
Truth table33%1/3
A and B
A= defined &JSON::trueB= JSON::true() eq $val
Truth table33%1/3
A and B
A= defined &JSON::falseB= JSON::false() eq $val
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | : (defined(&JSON::false) && JSON::false() eq $val) ? '(false)' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | : "\\\"$$val\""; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | chomp($val = $self->tablify($val)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | ▶ | $_split = 0 if $_split && $val =~ /^\Q$border[4]\E/ && $val =~ /\Q$border[14]\E$/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$_split and $val =~ /^\Q$border[4]\E/ and $val =~ /\Q$border[14]\E$/
$_split and $val =~ /^\Q$border[4]\E/
MC/DC0%0/3
$_split and $val =~ /^\Q$border[4]\E/ and $val =~ /\Q$border[14]\E$/
$_split
$val =~ /^\Q$border[4]\E/
$val =~ /\Q$border[14]\E$/
Truth table0%0/4
A and B and C
A= $_splitB= $val =~ /^\Q$border[4]\E/C= $val =~ /\Q$border[14]\E$/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 78 | ▶ | $dir[$j] = 1 if $val =~ /\D/ && $bucket == \@bucket; # TODO - we could work on our alignment | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$val =~ /\D/ and $bucket == \@bucket
MC/DC100%2/2
$val =~ /\D/ and $bucket == \@bucket
$val =~ /\D/
$bucket == \@bucket
Truth table100%3/3
A and B
A= $val =~ /\D/B= $bucket == \@bucket
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 78 | my $I = $i; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 78 | ▶ | for my $chunk ($_split ? map {/(.{$_split}|.+)/g} split /\n/, $val : split /\n/, $val) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 79 | $chunk =~ s/($qr_escape)/sprintf "\\%03o", ord $1/eg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 79 | $bucket->[$I++]->[$j] = $chunk; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 79 | ▶ | $max[$j] = length($chunk) if !$max[$j] || $max[$j] < length($chunk); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not $max[$j] or $max[$j] < length $chunk
MC/DC100%2/2
not $max[$j] or $max[$j] < length $chunk
not $max[$j]
$max[$j] < length $chunk
Truth table100%3/3
not(A) or B
A= not $max[$j]B= $max[$j] < length $chunk
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 19 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 19 | ▶ | if (UNIVERSAL::isa($data, 'HASH')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 14 | my $title = $self->{'title'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 14 | ▶ | $add->($title, \@title) if $title; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | ▶ | my @keys = @{ $self->{'sort'} || [sort {($a eq 'id') ? -1 : ($b eq 'id') ? 1 : $a cmp $b } keys %$data] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition50%1/2
$self->{'sort'} || [(sort {$a eq 'id' ? -1 : ($b eq 'id' ? 1 : $a cmp $b);} keys %$data)]
MC/DC0%0/1
$self->{'sort'} || [(sort {$a eq 'id' ? -1 : ($b eq 'id' ? 1 : $a cmp $b);} keys %$data)]
$self->{'sort'}
Truth table50%1/2
A
A= $self->{'sort'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 14 | $add->([$_, $data->{$_}], \@bucket) for @keys; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 14 | ▶ | $add->(['(empty hash)'], \@bucket) if !@bucket; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | } elsif (UNIVERSAL::isa($data, 'ARRAY')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 5 | my %title; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 5 | ▶ | if ($data->[0] && ref($data->[0]) eq 'HASH' && !$self->{'collapse'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
$data->[0] and ref $data->[0] eq "HASH" and not $self->{"collapse"}
$data->[0] and ref $data->[0] eq "HASH"
MC/DC33%1/3
$data->[0] and ref $data->[0] eq "HASH" and not $self->{"collapse"}
$data->[0]
ref $data->[0] eq "HASH"
not $self->{"collapse"}
Truth table50%2/4
A and B and not(C)
A= $data->[0]B= ref $data->[0] eq "HASH"C= not $self->{"collapse"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 4 | @title{keys %$_} = () for grep {ref($_) eq 'HASH'} @$data; # find all uniques | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | ▶ | my @keys = @{ $self->{'sort'} || [sort {($a eq 'id') ? -1 : ($b eq 'id') ? 1 : $a cmp $b } keys %title] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition50%1/2
$self->{'sort'} || [(sort {$a eq 'id' ? -1 : ($b eq 'id' ? 1 : $a cmp $b);} keys %title)]
MC/DC0%0/1
$self->{'sort'} || [(sort {$a eq 'id' ? -1 : ($b eq 'id' ? 1 : $a cmp $b);} keys %title)]
$self->{'sort'}
Truth table50%1/2
A
A= $self->{'sort'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 4 | $add->(\@keys, \@title); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 4 | foreach my $row (@$data) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 12 | ▶ | if (ref($row) ne 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | $add->($row, \@bucket); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 12 | $add->([@$row{@keys}], \@bucket); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 1 | my $title = $self->{'title'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 1 | ▶ | $add->($title, \@title) if $title; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 1 | $add->([$_], \@bucket) for @$data; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 1 | ▶ | $add->(['(empty array)'], \@bucket) if !@bucket; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 19 | ▶ | my $indent = $self->{'indent'} || ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{'indent'} || ''
MC/DC0%0/1
$self->{'indent'} || ''
$self->{'indent'}
Truth table50%1/2
A
A= $self->{'indent'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 19 | my $sep = "${indent}$border[8]".join($border[9], map {$border[11] x $_} @max)."$border[10]\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 19 | ▶ | my $fmt = "${indent}$border[0]".join($border[1], map {'%'.($dir[$_] ? '-' : '').$max[$_].'s'} 0..$#max)."$border[2]\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 19 | ▶ | if (!$self->{'collapse'} and my $cols = $self->{'auto_collapse'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not $self->{"collapse"} and my $cols = $self->{"auto_collapse"}
MC/DC0%0/2
not $self->{"collapse"} and my $cols = $self->{"auto_collapse"}
not $self->{"collapse"}
my $cols = $self->{"auto_collapse"}
Truth table33%1/3
not(A) and B
A= not $self->{"collapse"}B= my $cols = $self->{"auto_collapse"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | ▶ | $cols = $ENV{'COLUMNS'} || eval { die if ! -t STDOUT; require Term::ReadKey; (Term::ReadKey::GetTerminalSize(\*STDOUT))[0] } || 80 if $cols eq '1'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/5
$ENV{'COLUMNS'} || eval {
do {
die unless -t STDOUT;
require Term::ReadKey;
(Term::ReadKey::GetTerminalSize(\*STDOUT))[0]
}
} || 80
$ENV{"COLUMNS"} or eval {
do {
die unless -t STDOUT;
require Term::ReadKey;
(Term::ReadKey::GetTerminalSize(\*STDOUT))[0]
}
}
MC/DC0%0/2
$ENV{'COLUMNS'} || eval {
do {
die unless -t STDOUT;
require Term::ReadKey;
(Term::ReadKey::GetTerminalSize(\*STDOUT))[0]
}
} || 80
$ENV{"COLUMNS"}
eval {
do {
die unless -t STDOUT;
require Term::ReadKey;
(Term::ReadKey::GetTerminalSize(\*STDOUT))[0]
}
}
Truth table0%0/3
A or B
A= $ENV{"COLUMNS"}B= eval {
do {
die unless -t STDOUT;
require Term::ReadKey;
(Term::ReadKey::GetTerminalSize(\*STDOUT))[0]
}
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | ▶ | if (length($sep) - 1 > $cols) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | local $self->{'collapse'} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | ▶ | local $self->{'_level'} if $self->{'_level'} == 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | return $self->tablify($data); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 19 | my $out = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 19 | $out .= "${indent}$border[4]".join($border[5], map {$border[7] x $_} @max)."$border[6]\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 6 | ▶ | no warnings 'uninitialized'; # because of multiline | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 19 | for my $buck (\@title, \@bucket) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 38 | for my $row (@$buck) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 33 | ▶ | if (ref $row) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 33 | $out .= sprintf($fmt, @$row); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | $out .= sprintf("$border[0]%-*s$border[2]\n", length($sep) - (length($border[0])+length($border[2])+1), $row); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 38 | ▶ | if ($buck == \@title) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 19 | ▶ | $out .= $sep if @title; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 19 | $out .= "${indent}$border[12]".join($border[13], map {$border[15] x $_} @max)."$border[14]\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 19 | ▶ | utf8::encode($out) if $self->{'_level'} == 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 19 | return $out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 6 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||