| 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"
$config->{'etp_engine'} || 'TT'
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'}
| |||||||||||||||||||||||||||||
| 30 | 2 | ▶ | $args->{etp_config} ||= $config->{etp_config} || {}; | ||||||||||||||||||||||||||
|
Condition40%2/5
$args->{"etp_config"} ||= $config->{"etp_config"} || {}
$config->{'etp_config'} || {}
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'}
| |||||||||||||||||||||||||||||
| 31 | 2 | ▶ | $args->{etp_params} ||= $config->{etp_params} || {}; | ||||||||||||||||||||||||||
|
Condition40%2/5
$args->{"etp_params"} ||= $config->{"etp_params"} || {}
$config->{'etp_params'} || {}
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'}
| |||||||||||||||||||||||||||||
| 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
Condition33%1/3
defined $self->config->{"TEMPLATE_EXTENSION"} and not $self->config->{"TEMPLATE_EXTENSION"} =~ /\./
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"} =~ /\./
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
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
| |||||||||||||||||||||||||||||
| 55 | 2 | ▶ | my $etp_config = $c->stash->{etp_config} || $self->etp_config; | ||||||||||||||||||||||||||
|
Condition33%1/3
$c->stash->{'etp_config'} || $self->etp_config
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
| |||||||||||||||||||||||||||||
| 56 | 2 | ▶ | my $etp_params = $c->stash->{etp_params} || $self->etp_params; | ||||||||||||||||||||||||||
|
Condition33%1/3
$c->stash->{'etp_params'} || $self->etp_params
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
| |||||||||||||||||||||||||||||
| 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'
MC/DC0%0/1
$c->stash->{'excel_filename'} || 'excel.xls'
$c->stash->{'excel_filename'}
Truth table0%0/2
A
A= $c->stash->{'excel_filename'}
| |||||||||||||||||||||||||||||
| 72 | 0 | ▶ | $excel_filename .= '.xls' unless ($excel_filename =~ /\.xls$/i); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | 0 | ▶ | my $excel_disposition = $c->stash->{excel_disposition} || 'inline'; | ||||||||||||||||||||||||||
|
Condition0%0/2
$c->stash->{'excel_disposition'} || 'inline'
MC/DC0%0/1
$c->stash->{'excel_disposition'} || 'inline'
$c->stash->{'excel_disposition'}
Truth table0%0/2
A
A= $c->stash->{'excel_disposition'}
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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'
MC/DC0%0/1
$self->config->{'CATALYST_VAR'} || 'c'
$self->config->{'CATALYST_VAR'}
Truth table0%0/2
A
A= $self->config->{'CATALYST_VAR'}
| |||||||||||||||||||||||||||||
| 96 | 0 | return ( $cvar => $c, %{ $c->stash } ); | |||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | 4 | 1; | |||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | __END__ | ||||||||||||||||||||||||||||