View/Excel/Template/Plus.pm

filter: Statementstmt 80.3% 49 / 61 Branchbran 37.5% 3 / 8 Conditioncond 30.3% 10 / 33 MC/DCmcdc 0.0% 0 / 17 Subroutinesub 91.6% 11 / 12 Podpod 100% 5 / 5 totaltotal 57.3% 78 / 136 CC 18 SCAR 24.4
CC
18
Cov
61%
process
22.2
new
14.4
get_template_params
6.0
CRAP 11.4
↑ Summary Helper/View/Excel/Template/Plus.pm »
1 package Catalyst::View::Excel::Template::Plus;
2  
3 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 4 ▶use MRO::Compat;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 4 ▶use Excel::Template::Plus;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 4 ▶use Scalar::Util 'blessed';
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 4 ▶use Catalyst::Exception;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 4 our $VERSION = '0.04';
13 4 our $AUTHORITY = 'cpan:STEVAN';
14  
15 4 ▶use base 'Catalyst::View';
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 4 __PACKAGE__->mk_accessors(qw[
18 etp_engine
19 etp_config
20 etp_params
21 ]);
22  
23 2 ▶sub new {
Subroutine new: called CC=9 SCAR=26.7
Pod documented
24 2 my($class, $c, $args) = @_;
25 2 my $self = $class->next::method($c, $args);
26  
27 2 my $config = $c->config->{'View::Excel::Template::Plus'};
28  
29 2 ▶ $args->{etp_engine} ||= $config->{etp_engine} || 'TT';
Condition40%2/5
$args->{"etp_engine"} ||= $config->{"etp_engine"} || "TT"
l!l&&r!l&&!r
020
$config->{'etp_engine'} || 'TT'
l!l
02
MC/DC0%0/2
$args->{"etp_engine"} ||= $config->{"etp_engine"} || "TT"
$args->{"etp_engine"} $config->{'etp_engine'}
Truth table0%0/3
A ||= B
A= $args->{"etp_engine"}B= $config->{'etp_engine'}
ABresult
1X1
011
000
30 2 ▶ $args->{etp_config} ||= $config->{etp_config} || {};
Condition40%2/5
$args->{"etp_config"} ||= $config->{"etp_config"} || {}
l!l&&r!l&&!r
020
$config->{'etp_config'} || {}
l!l
20
MC/DC0%0/2
$args->{"etp_config"} ||= $config->{"etp_config"} || {}
$args->{"etp_config"} $config->{'etp_config'}
Truth table33%1/3
A ||= B
A= $args->{"etp_config"}B= $config->{'etp_config'}
ABresult
1X1
011
000
31 2 ▶ $args->{etp_params} ||= $config->{etp_params} || {};
Condition40%2/5
$args->{"etp_params"} ||= $config->{"etp_params"} || {}
l!l&&r!l&&!r
020
$config->{'etp_params'} || {}
l!l
02
MC/DC0%0/2
$args->{"etp_params"} ||= $config->{"etp_params"} || {}
$args->{"etp_params"} $config->{'etp_params'}
Truth table0%0/3
A ||= B
A= $args->{"etp_params"}B= $config->{'etp_params'}
ABresult
1X1
011
000
32  
33 2 $self->etp_engine($args->{etp_engine});
34 2 $self->etp_config($args->{etp_config});
35 2 $self->etp_params($args->{etp_params});
36  
37 2 ▶ if ( defined $self->config->{TEMPLATE_EXTENSION} && $self->config->{TEMPLATE_EXTENSION} !~ /\./ ){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->config->{"TEMPLATE_EXTENSION"} and not $self->config->{"TEMPLATE_EXTENSION"} =~ /\./) 0 2 2
Condition33%1/3
defined $self->config->{"TEMPLATE_EXTENSION"} and not $self->config->{"TEMPLATE_EXTENSION"} =~ /\./
!ll&&!rl&&r
200
MC/DC0%0/2
defined $self->config->{"TEMPLATE_EXTENSION"} and not $self->config->{"TEMPLATE_EXTENSION"} =~ /\./
defined $self->config->{"TEMPLATE_EXTENSION"} not $self->config->{"TEMPLATE_EXTENSION"} =~ /\./
Truth table33%1/3
A and not(B)
A= defined $self->config->{"TEMPLATE_EXTENSION"}B= not $self->config->{"TEMPLATE_EXTENSION"} =~ /\./
ABresult
0X0
100
111
38 0 $c->log->warn(qq/Missing . (dot) in TEMPLATE_EXTENSION ( $class ), the attitude has changed with version 0.02./);
39 }
40  
41 2 return $self;
42 }
43  
44 2 ▶sub process {
Subroutine process: called CC=8 SCAR=31.0
Pod documented
45 2 my $self = shift;
46 2 my $c = shift;
47 2 my @args = @_;
48  
49 2 my $template = $self->get_template_filename($c);
50  
51 2 ▶ (defined $template)
Branch: 1 branch
BranchTrueFalseTotal
defined $template or die "No template specified for rendering" 2 0 2
52 || die 'No template specified for rendering';
53  
54 2 ▶ my $etp_engine = $c->stash->{etp_engine} || $self->etp_engine;
Condition33%1/3
$c->stash->{'etp_engine'} || $self->etp_engine
l!l&&r!l&&!r
020
MC/DC0%0/2
$c->stash->{'etp_engine'} || $self->etp_engine
$c->stash->{'etp_engine'} $self->etp_engine
Truth table33%1/3
A || B
A= $c->stash->{'etp_engine'}B= $self->etp_engine
ABresult
1X1
011
000
55 2 ▶ my $etp_config = $c->stash->{etp_config} || $self->etp_config;
Condition33%1/3
$c->stash->{'etp_config'} || $self->etp_config
l!l&&r!l&&!r
020
MC/DC0%0/2
$c->stash->{'etp_config'} || $self->etp_config
$c->stash->{'etp_config'} $self->etp_config
Truth table33%1/3
A || B
A= $c->stash->{'etp_config'}B= $self->etp_config
ABresult
1X1
011
000
56 2 ▶ my $etp_params = $c->stash->{etp_params} || $self->etp_params;
Condition33%1/3
$c->stash->{'etp_params'} || $self->etp_params
l!l&&r!l&&!r
020
MC/DC0%0/2
$c->stash->{'etp_params'} || $self->etp_params
$c->stash->{'etp_params'} $self->etp_params
Truth table33%1/3
A || B
A= $c->stash->{'etp_params'}B= $self->etp_params
ABresult
1X1
011
000
57  
58 2 my $excel = $self->create_template_object($c => (
59 engine => $etp_engine,
60 template => $template,
61 config => $etp_config,
62 params => $etp_params,
63 ));
64  
65 0 $excel->param( $self->get_template_params($c) );
66  
67 # handle Content-Type
68 0 $c->response->content_type('application/x-msexcel');
69  
70 # handle Content-Disposition
71 0 ▶ my $excel_filename = $c->stash->{excel_filename} || 'excel.xls';
Condition0%0/2
$c->stash->{'excel_filename'} || 'excel.xls'
l!l
00
MC/DC0%0/1
$c->stash->{'excel_filename'} || 'excel.xls'
$c->stash->{'excel_filename'}
Truth table0%0/2
A
A= $c->stash->{'excel_filename'}
Aresult
11
00
72 0 ▶ $excel_filename .= '.xls' unless ($excel_filename =~ /\.xls$/i);
Branch: 1 branch
BranchTrueFalseTotal
unless $excel_filename =~ /\.xls$/i 0 0 0
73  
74 0 ▶ my $excel_disposition = $c->stash->{excel_disposition} || 'inline';
Condition0%0/2
$c->stash->{'excel_disposition'} || 'inline'
l!l
00
MC/DC0%0/1
$c->stash->{'excel_disposition'} || 'inline'
$c->stash->{'excel_disposition'}
Truth table0%0/2
A
A= $c->stash->{'excel_disposition'}
Aresult
11
00
75 0 $c->response->headers->header("Content-Disposition"
76 => qq{$excel_disposition; filename="$excel_filename"});
77  
78 0 $c->response->body($excel->output);
79 }
80  
81 2 ▶sub create_template_object {
Subroutine create_template_object: called CC=1 SCAR=0.0
Pod documented
82 2 my ($self, $c, %options) = @_;
83 2 Excel::Template::Plus->new( %options );
84 }
85  
86 2 ▶sub get_template_filename {
Subroutine get_template_filename: called CC=2 SCAR=7.2
Pod documented
87 2 my ($self, $c) = @_;
88 $c->stash->{template}
89 ||
90 2 ▶ ($c->action . '.xml' . $self->config->{TEMPLATE_EXTENSION});
Branch: 1 branch
BranchTrueFalseTotal
$c->stash->{"template"} or $c->action . '.xml' . $self->config->{"TEMPLATE_EXTENSION"} 2 0 2
91 }
92  
93 0 ▶sub get_template_params {
Subroutine get_template_params: not called CC=2 SCAR=17.9
Pod documented
94 0 my ($self, $c) = @_;
95 0 ▶ my $cvar = $self->config->{CATALYST_VAR} || 'c';
Condition0%0/2
$self->config->{'CATALYST_VAR'} || 'c'
l!l
00
MC/DC0%0/1
$self->config->{'CATALYST_VAR'} || 'c'
$self->config->{'CATALYST_VAR'}
Truth table0%0/2
A
A= $self->config->{'CATALYST_VAR'}
Aresult
11
00
96 0 return ( $cvar => $c, %{ $c->stash } );
97 }
98  
99 4 1;
100  
101 __END__
↑ Summary Helper/View/Excel/Template/Plus.pm »