blib/lib/Template/Plugin/Transformator.pm

filter: Statementstmt 77.1% 27 / 35 Branchbran 25.0% 1 / 4 Conditioncond 20.0% 2 / 10 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 85.7% 6 / 7 Podpod 0.0% 0 / 2 totaltotal 56.2% 36 / 64 CC 7 SCAR 17.2
CC
7
Cov
61%
filter
12.0
init
6.4
BEGIN
1.0
CRAP 5.6
↑ Summary
1 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 package Template::Plugin::Transformator;
5  
6 # ABSTRACT: TemplateToolkit plugin for Net::NodeTransformator
7  
8 1 ▶use Net::NodeTransformator;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use Template::Plugin::Filter;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use base qw( Template::Plugin::Filter );
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 1 our $VERSION = '0.001'; # VERSION
13  
14 4 ▶sub init {
Subroutine init: called CC=5 SCAR=18.5
Pod undocumented
15 4 my $self = shift;
16  
17 $self->{config} =
18 4 ▶ $self->{_CONTEXT}->{CONFIG}->{PLUGIN_CONFIG}->{Transformator} || {};
Condition50%1/2
$self->{'_CONTEXT'}{'CONFIG'}{'PLUGIN_CONFIG'}{'Transformator'} || {}
l!l
04
MC/DC0%0/1
$self->{'_CONTEXT'}{'CONFIG'}{'PLUGIN_CONFIG'}{'Transformator'} || {}
$self->{'_CONTEXT'}{'CONFIG'}{'PLUGIN_CONFIG'}{'Transformator'}
Truth table50%1/2
A
A= $self->{'_CONTEXT'}{'CONFIG'}{'PLUGIN_CONFIG'}{'Transformator'}
Aresult
11
00
19  
20 4 my %config = %{ $self->{_CONFIG} };
21 4 my @args = @{ $self->{_ARGS} };
22  
23 4 ▶ my $name = $config{name} || 'Transformator';
Condition50%1/2
$config{'name'} || 'Transformator'
l!l
04
MC/DC0%0/1
$config{'name'} || 'Transformator'
$config{'name'}
Truth table50%1/2
A
A= $config{'name'}
Aresult
11
00
24  
25 4 $self->{_DYNAMIC} = 1;
26  
27 4 $self->install_filter($name);
28  
29 $self->{nnt} =
30 $self->{config}->{connect}
31 ? Net::NodeTransformator->new( $self->{config}->{connect} )
32 4 ▶ : Net::NodeTransformator->standalone;
Branch: 1 branch
BranchTrueFalseTotal
$self->{'config'}{'connect'} ? : 0 4 4
33  
34 0 ▶ $self->{engine} = $config{engine} || $args[0];
Condition0%0/3
$config{'engine'} || $args[0]
l!l&&r!l&&!r
000
MC/DC0%0/2
$config{'engine'} || $args[0]
$config{'engine'} $args[0]
Truth table0%0/3
A || B
A= $config{'engine'}B= $args[0]
ABresult
1X1
011
000
35  
36 0 return $self;
37 }
38  
39 0 ▶sub filter {
Subroutine filter: not called CC=3 SCAR=24.8
Pod undocumented
40 0 my ( $self, $text, $args, $conf ) = @_;
41  
42 0 my %config = %$conf;
43  
44 my $nnt =
45 $config{connect}
46 ? Net::NodeTransformator->new( $config{connect} )
47 0 ▶ : $self->{nnt};
Branch: 1 branch
BranchTrueFalseTotal
$config{'connect'} ? : 0 0 0
48  
49 0 my $engine = $self->{engine};
50 0 ▶ $engine ||= shift @$args;
Condition0%0/3
$engine ||= shift @$args
l!l&&r!l&&!r
000
MC/DC0%0/2
$engine ||= shift @$args
$engine shift @$args
Truth table0%0/3
A ||= B
A= $engineB= shift @$args
ABresult
1X1
011
000
51  
52 0 $text = $nnt->transform( $engine, $text, $conf );
53 }
54  
55 1 1;
56  
57 __END__
↑ Summary