lib/CGI/Application/Plugin/TT/Any.pm

filter: Statementstmt 97.6% 41 / 42 Branchbran 66.6% 4 / 6 Conditioncond 40.0% 4 / 10 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 100% 9 / 9 Podpod 100% 1 / 1 totaltotal 79.7% 59 / 74 CC 9 SCAR 13.7
CC
9
Cov
84%
tt_obj
7.3
import
4.0
BEGIN
1.0
CRAP 3.9
↑ Summary
1 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 package CGI::Application::Plugin::TT::Any;
5 2 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 $CGI::Application::Plugin::TT::Any::VERSION = '0.110080';
7 }
8  
9 # ABSTRACT: load CGI::Application::Plugin::TT with any TT-compatible class
10  
11  
12 2 ▶use Class::Load 'load_class';
Subroutine BEGIN: called CC=1 SCAR=0.0
13 2 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 2 require CGI::Application::Plugin::TT;
16  
17 2 ▶sub import {
Subroutine import: called CC=4 SCAR=13.9
18 2 my $pkg = shift;
19 2 my $callpkg = caller;
20 {
21 2 ▶ no warnings 'redefine';
Subroutine BEGIN: called CC=1 SCAR=0.0
22 2 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
23 2 for (qw( tt_obj )) {
24 2 my %target = %{"$callpkg\::"};
25 2 ▶ die "CGI::Application::Plugin::TT needs to be loaded first" if !$target{$_};
Branch: 1 branch
BranchTrueFalseTotal
unless $target{$_} 1 1 2
26 1 *{"$callpkg\::$_"} = \&{$_};
27 }
28 }
29 1 ▶ return if !@_;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 1 0 1
30 0 return $callpkg->tt_config( @_ );
31 }
32  
33 1 ▶sub tt_obj {
Subroutine tt_obj: called CC=6 SCAR=19.9
Pod documented
34 1 my $self = shift;
35  
36 1 my ($tt, $options, $frompkg) = CGI::Application::Plugin::TT::_get_object_or_options($self);
37  
38 1 ▶ return $tt if $tt;
Branch: 1 branch
BranchTrueFalseTotal
if $tt 0 1 1
39  
40 1 ▶ my $tt_options = $options->{TEMPLATE_OPTIONS} || {};
Condition50%1/2
$options->{'TEMPLATE_OPTIONS'} || {}
l!l
10
MC/DC0%0/1
$options->{'TEMPLATE_OPTIONS'} || {}
$options->{'TEMPLATE_OPTIONS'}
Truth table50%1/2
A
A= $options->{'TEMPLATE_OPTIONS'}
Aresult
11
00
41 1 ▶ my $class = delete $tt_options->{CLASS} || 'Template';
Condition50%1/2
delete $tt_options->{'CLASS'} || 'Template'
l!l
01
MC/DC0%0/1
delete $tt_options->{'CLASS'} || 'Template'
delete $tt_options->{'CLASS'}
Truth table50%1/2
A
A= delete $tt_options->{'CLASS'}
Aresult
11
00
42 1 load_class $class;
43  
44 1 ▶ $tt = $class->new( $tt_options ) || carp "Can't load Template";
Condition33%1/3
$class->new($tt_options) || carp(q[Can't load Template])
l!l&&r!l&&!r
100
MC/DC0%0/2
$class->new($tt_options) || carp(q[Can't load Template])
$class->new($tt_options) carp(q[Can't load Template])
Truth table33%1/3
A || B
A= $class->new($tt_options)B= carp(q[Can't load Template])
ABresult
1X1
011
000
45  
46 1 ▶ CGI::Application::Plugin::TT::_set_object( $frompkg||$self, $tt );
Condition33%1/3
$frompkg || $self
l!l&&r!l&&!r
010
MC/DC0%0/2
$frompkg || $self
$frompkg $self
Truth table33%1/3
A || B
A= $frompkgB= $self
ABresult
1X1
011
000
47  
48 1 return $tt;
49 }
50  
51 2 1;
52  
53 __END__
↑ Summary