| 1 | # Copyright (C) 2003-2007, G. Allen Morris III, all rights reserved | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 8 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | package Data::Tabular::Config::Output; | ||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | sub new | ||||||||||||||||||||||||||||
| 7 | 10 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=9 SCAR=29.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 8 | 10 | my $caller = shift; | |||||||||||||||||||||||||||
| 9 | 10 | ▶ | my $class = ref($caller) || $caller; | ||||||||||||||||||||||||||
|
Condition33%1/3
ref $caller || $caller
MC/DC0%0/2
ref $caller || $caller
ref $caller
$caller
Truth table33%1/3
A || B
A= ref $callerB= $caller
| |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 10 | my $self = bless { @_ }, $class; | |||||||||||||||||||||||||||
| 12 | 10 | $self->{caller} = join(':', caller); | |||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 10 | ▶ | $self->{xls} ||= {}; | ||||||||||||||||||||||||||
|
Condition50%1/2
$self->{"xls"} ||= {}
MC/DC0%0/1
$self->{"xls"} ||= {}
$self->{"xls"}
Truth table50%1/2
A
A= $self->{"xls"}
| |||||||||||||||||||||||||||||
| 15 | 10 | ▶ | $self->{html} ||= {}; | ||||||||||||||||||||||||||
|
Condition50%1/2
$self->{"html"} ||= {}
MC/DC0%0/1
$self->{"html"} ||= {}
$self->{"html"}
Truth table50%1/2
A
A= $self->{"html"}
| |||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 10 | ▶ | if ($self->{titles}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 18 | 0 | for my $column (keys %{$self->{titles}}) { | |||||||||||||||||||||||||||
| 19 | 0 | ▶ | if ($self->{columns}{$column}{title} and $self->{columns}{$column}{title} ne $self->{titles}->{$column}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{"columns"}{$column}{"title"} and $self->{"columns"}{$column}{"title"} ne $self->{"titles"}{$column}
MC/DC0%0/2
$self->{"columns"}{$column}{"title"} and $self->{"columns"}{$column}{"title"} ne $self->{"titles"}{$column}
$self->{"columns"}{$column}{"title"}
$self->{"columns"}{$column}{"title"} ne $self->{"titles"}{$column}
Truth table0%0/3
A and B
A= $self->{"columns"}{$column}{"title"}B= $self->{"columns"}{$column}{"title"} ne $self->{"titles"}{$column}
| |||||||||||||||||||||||||||||
| 20 | 8 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 21 | 0 | die Dumper $self; | |||||||||||||||||||||||||||
| 22 | } | ||||||||||||||||||||||||||||
| 23 | 0 | $self->{columns}{$column}{title} = $self->{titles}->{$column}; | |||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 10 | ▶ | die 'No column list' unless $self->column_list; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 28 | 10 | $self; | |||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | sub column_list | ||||||||||||||||||||||||||||
| 32 | 10 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
column_list: called CC=2 SCAR=8.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 33 | 10 | my $self = shift; | |||||||||||||||||||||||||||
| 34 | 0 | ▶ | wantarray ? @{$self->{headers}} : $self->{headers}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | sub col_id | ||||||||||||||||||||||||||||
| 38 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
col_id: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 39 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 40 | 0 | my $col_name = shift; | |||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 0 | my $x = 0; | |||||||||||||||||||||||||||
| 43 | 0 | for my $col ($self->column_list) { | |||||||||||||||||||||||||||
| 44 | 0 | ▶ | if ($col eq $col_name) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 45 | 0 | return $x; | |||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | 0 | $x++; | |||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||
| 49 | 0 | die "Unknown column $col_name"; | |||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | sub title | ||||||||||||||||||||||||||||
| 53 | 102 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
title: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 54 | 102 | my $self = shift; | |||||||||||||||||||||||||||
| 55 | 102 | my $column_name = shift; | |||||||||||||||||||||||||||
| 56 | 102 | ▶ | $self->{columns}->{$column_name}->{title} || $column_name; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | sub html_column_attributes | ||||||||||||||||||||||||||||
| 60 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
html_column_attributes: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 61 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 62 | 0 | my $column_name = shift; | |||||||||||||||||||||||||||
| 63 | my $ret = { | ||||||||||||||||||||||||||||
| 64 | 0 | ▶ | %{$self->{columns}->{$column_name}->{html_attributes} || {}}, | ||||||||||||||||||||||||||
|
Condition0%0/2
$self->{'columns'}{$column_name}{'html_attributes'} || {}
MC/DC0%0/1
$self->{'columns'}{$column_name}{'html_attributes'} || {}
$self->{'columns'}{$column_name}{'html_attributes'}
Truth table0%0/2
A
A= $self->{'columns'}{$column_name}{'html_attributes'}
| |||||||||||||||||||||||||||||
| 65 | }; | ||||||||||||||||||||||||||||
| 66 | 0 | $ret->{align} = 'right'; | |||||||||||||||||||||||||||
| 67 | 0 | ▶ | if (my $width = $self->{columns}->{$column_name}->{width}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 68 | 0 | ▶ | die if defined $ret->{width}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 69 | 0 | $ret->{width} = $width; | |||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||
| 71 | 0 | return $ret; | |||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | sub xls_width | ||||||||||||||||||||||||||||
| 75 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
xls_width: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 76 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 77 | 0 | my $column_name = shift; | |||||||||||||||||||||||||||
| 78 | 0 | ▶ | $self->{columns}->{$column_name}->{xls}->{width} || $self->{xls}->{width} || 10; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{"columns"}{$column_name}{"xls"}{"width"} or $self->{"xls"}{"width"}
MC/DC0%0/2
$self->{"columns"}{$column_name}{"xls"}{"width"} or $self->{"xls"}{"width"}
$self->{"columns"}{$column_name}{"xls"}{"width"}
$self->{"xls"}{"width"}
Truth table0%0/3
A or B
A= $self->{"columns"}{$column_name}{"xls"}{"width"}B= $self->{"xls"}{"width"}
| |||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | sub xls_title_format | ||||||||||||||||||||||||||||
| 82 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
xls_title_format: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 83 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 84 | 0 | my $column_name = shift; | |||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | 0 | $self->{columns}->{$column_name}->{xls}->{title_format}; | |||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | sub align | ||||||||||||||||||||||||||||
| 90 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
align: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 91 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 92 | 0 | my $column_name = shift; | |||||||||||||||||||||||||||
| 93 | 0 | $self->{columns}->{$column_name}->{align}; | |||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | sub headers | ||||||||||||||||||||||||||||
| 97 | 262 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
headers: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 98 | 262 | my $self = shift; | |||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | 262 | @{$self->{headers}}; | |||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | sub html_attribute_string | ||||||||||||||||||||||||||||
| 104 | 2 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
html_attribute_string: called CC=4 SCAR=14.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 105 | 2 | my $self = shift; | |||||||||||||||||||||||||||
| 106 | 2 | my $attributes = { | |||||||||||||||||||||||||||
| 107 | border => 1, | ||||||||||||||||||||||||||||
| 108 | }; | ||||||||||||||||||||||||||||
| 109 | 2 | my $na = $self->{html}->{attributes}; | |||||||||||||||||||||||||||
| 110 | 2 | for my $attribute (sort keys %$na) { | |||||||||||||||||||||||||||
| 111 | 0 | $attributes->{$attribute} = $na->{$attribute}; | |||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | 2 | my $ret = ''; | |||||||||||||||||||||||||||
| 115 | 2 | for my $attribute (sort keys %$attributes) { | |||||||||||||||||||||||||||
| 116 | 2 | ▶ | next unless $attributes->{$attribute}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 117 | 2 | $ret .= qq| $attribute="| . $attributes->{$attribute} . qq|"|; | |||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | 2 | $ret; | |||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||
| 123 | sub test_xls_attribute | ||||||||||||||||||||||||||||
| 124 | 3 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
test_xls_attribute: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 125 | 3 | my $self = shift; | |||||||||||||||||||||||||||
| 126 | 3 | my $attribute = shift; | |||||||||||||||||||||||||||
| 127 | 3 | return $self->{xls}->{$attribute}; | |||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||
| 130 | sub table | ||||||||||||||||||||||||||||
| 131 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
table: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 132 | 0 | shift->{title}; | |||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||
| 135 | sub set_type | ||||||||||||||||||||||||||||
| 136 | 6 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
set_type: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 137 | 6 | my $self = shift; | |||||||||||||||||||||||||||
| 138 | 6 | my $args = { @_ }; | |||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||
| 140 | 6 | $self->{types}->{$args->{name}} = $args->{type}; | |||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||
| 142 | 6 | undef; | |||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||
| 145 | sub type | ||||||||||||||||||||||||||||
| 146 | 320 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
type: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 147 | 320 | my $self = shift; | |||||||||||||||||||||||||||
| 148 | 320 | my $name = shift; | |||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||
| 150 | 320 | ▶ | $self->{types}->{$name} || 'text'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||
| 153 | sub set_column_format | ||||||||||||||||||||||||||||
| 154 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
set_column_format: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 155 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 156 | 0 | my %args = @_; | |||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||
| 158 | 0 | for my $key (keys %args) { | |||||||||||||||||||||||||||
| 159 | 0 | $self->{format}{$key} = $args{$key}; | |||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||
| 163 | sub get_column_format | ||||||||||||||||||||||||||||
| 164 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
get_column_format: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 165 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 166 | 0 | ▶ | my $column = shift or die 'need name'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||
| 168 | 0 | ▶ | $self->{format}{$column} || '%s'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||
| 171 | sub format | ||||||||||||||||||||||||||||
| 172 | 102 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
format: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 173 | 102 | 'bob'; | |||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||
| 176 | sub set_use_functions | ||||||||||||||||||||||||||||
| 177 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
set_use_functions: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 178 | 0 | warn "set_use_functions"; | |||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||
| 181 | sub get_use_functions | ||||||||||||||||||||||||||||
| 182 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
get_use_functions: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 183 | 0 | warn "get_use_functions"; | |||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||
| 186 | 8 | 1; | |||||||||||||||||||||||||||
| 187 | __END__ | ||||||||||||||||||||||||||||