blib/lib/Locale/Maketext/Extract/Plugin/Xslate.pm

filter: Statementstmt 71.6% 53 / 74 Branchbran 72.2% 13 / 18 Conditioncond 50.0% 13 / 26 MC/DCmcdc 26.6% 4 / 15 Subroutinesub 100% 10 / 10 Podpod 75.0% 3 / 4 totaltotal 65.3% 96 / 147 CC 20 SCAR 34.8
CC
20
Cov
67%
walker
51.3
new
3.0
BEGIN
1.0
CRAP 32.4
↑ Summary
1 package Locale::Maketext::Extract::Plugin::Xslate;
2 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use parent qw(Locale::Maketext::Extract::Plugin::Base);
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 our $VERSION = '0.0.3';
6 2 our $DEBUG = 0;
7  
8 2 ▶use Locale::Maketext::Extract;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 $Locale::Maketext::Extract::Known_Plugins{xslate} = __PACKAGE__;
10  
11 2 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 1 ▶sub file_types {
Subroutine file_types: called CC=1 SCAR=0.0
Pod documented
14 1 qw( tt html );
15 }
16  
17 1 ▶sub new {
Subroutine new: called CC=3 SCAR=11.1
Pod documented
18 1 my($class, $args) = @_;
19 1 my $extensions = delete $args->{extensions};
20 1 ▶ my $syntax = delete $args->{syntax} || 'TTears';
Condition50%1/2
delete $args->{'syntax'} || 'TTears'
l!l
10
MC/DC0%0/1
delete $args->{'syntax'} || 'TTears'
delete $args->{'syntax'}
Truth table50%1/2
A
A= delete $args->{'syntax'}
Aresult
11
00
21 1 my $self = $class->SUPER::new($extensions);
22 1 ▶ eval "use Text::Xslate::Syntax::$syntax;"; ## no critic
Subroutine BEGIN: called CC=1 SCAR=0.0
23 1 ▶ die $@ if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 1 1
24 1 $self->{xslate_parser} = "Text::Xslate::Syntax::$syntax"->new($args);
25 1 $self;
26 }
27  
28 1 ▶sub extract {
Subroutine extract: called CC=1 SCAR=0.0
Pod documented
29 1 my($self, $data) = @_;
30 1 my $ast = $self->{xslate_parser}->parse($data);
31 1 $self->walker($ast);
32 }
33  
34 2 my $sp = '';
35 241 ▶sub walker {
Subroutine walker: called CC=18 SCAR=39.4
Pod undocumented
36 241 my($self, $ast) = @_;
37 241 ▶ $ast = [ $ast ] if $ast && ref($ast) eq 'Text::Xslate::Symbol';
Branch: 1 branch
BranchTrueFalseTotal
if $ast and ref $ast eq "Text::Xslate::Symbol" 18 223 241
Condition100%3/3
$ast and ref $ast eq "Text::Xslate::Symbol"
!ll&&!rl&&r
1863718
MC/DC100%2/2
$ast and ref $ast eq "Text::Xslate::Symbol"
$ast ref $ast eq "Text::Xslate::Symbol"
Truth table100%3/3
A and B
A= $astB= ref $ast eq "Text::Xslate::Symbol"
ABresult
0X0
100
111
38 241 ▶ return unless $ast && ref($ast) eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
unless $ast and ref $ast eq "ARRAY" 186 55 241
Condition66%2/3
$ast and ref $ast eq "ARRAY"
!ll&&!rl&&r
186055
MC/DC50%1/2
$ast and ref $ast eq "ARRAY"
$ast ref $ast eq "ARRAY"
Truth table66%2/3
A and B
A= $astB= ref $ast eq "ARRAY"
ABresult
0X0
100
111
39  
40 55 for my $sym (@{ $ast }) {
41  
42 80 ▶ if ($sym->arity eq 'call' && $sym->value eq '(') {
Branch: 1 branch
BranchTrueFalseTotal
if ($sym->arity eq "call" and $sym->value eq "(") 11 69 80
Condition66%2/3
$sym->arity eq "call" and $sym->value eq "("
!ll&&!rl&&r
69011
MC/DC50%1/2
$sym->arity eq "call" and $sym->value eq "("
$sym->arity eq "call" $sym->value eq "("
Truth table66%2/3
A and B
A= $sym->arity eq "call"B= $sym->value eq "("
ABresult
0X0
100
111
43 11 my $first = $sym->first;
44 11 ▶ if ($first && ref($first) eq 'Text::Xslate::Symbol') {
Branch: 1 branch
BranchTrueFalseTotal
if ($first and ref $first eq "Text::Xslate::Symbol") 11 0 11
Condition33%1/3
$first and ref $first eq "Text::Xslate::Symbol"
!ll&&!rl&&r
0011
MC/DC0%0/2
$first and ref $first eq "Text::Xslate::Symbol"
$first ref $first eq "Text::Xslate::Symbol"
Truth table33%1/3
A and B
A= $firstB= ref $first eq "Text::Xslate::Symbol"
ABresult
0X0
100
111
45 11 ▶ if ($first->arity eq 'variable' && $first->value eq 'l') {
Branch: 1 branch
BranchTrueFalseTotal
if ($first->arity eq "variable" and $first->value eq "l") 11 0 11
Condition33%1/3
$first->arity eq "variable" and $first->value eq "l"
!ll&&!rl&&r
0011
MC/DC0%0/2
$first->arity eq "variable" and $first->value eq "l"
$first->arity eq "variable" $first->value eq "l"
Truth table33%1/3
A and B
A= $first->arity eq "variable"B= $first->value eq "l"
ABresult
0X0
100
111
46 11 my $second = $sym->second;
47 11 ▶ if ($second && ref($second) eq 'ARRAY' && $second->[0] && ref($second->[0]) eq 'Text::Xslate::Symbol') {
Branch: 1 branch
BranchTrueFalseTotal
if ($second and ref $second eq "ARRAY" and $second->[0] and ref $second->[0] eq "Text::Xslate::Symbol") 11 0 11
Condition33%3/9
$second and ref $second eq "ARRAY" and $second->[0] and ref $second->[0] eq "Text::Xslate::Symbol"
!ll&&!rl&&r
0011
$second and ref $second eq "ARRAY" and $second->[0]
!ll&&!rl&&r
0011
$second and ref $second eq "ARRAY"
!ll&&!rl&&r
0011
MC/DC0%0/4
$second and ref $second eq "ARRAY" and $second->[0] and ref $second->[0] eq "Text::Xslate::Symbol"
$second ref $second eq "ARRAY" $second->[0] ref $second->[0] eq "Text::Xslate::Symbol"
Truth table20%1/5
A and B and C and D
A= $secondB= ref $second eq "ARRAY"C= $second->[0]D= ref $second->[0] eq "Text::Xslate::Symbol"
ABCDresult
0XXX0
10XX0
110X0
11100
11111
48 11 my $value = $second->[0];
49 11 ▶ if ($value->arity eq 'literal') {
Branch: 1 branch
BranchTrueFalseTotal
if ($value->arity eq "literal") 10 1 11
50 10 $self->add_entry($value->value, $value->line);
51 }
52 }
53 }
54 }
55 }
56  
57 80 ▶ unless ($DEBUG) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Locale::Maketext::Extract::Plugin::Xslate::DEBUG) { } 0 80 80
58 80 $self->walker($sym->first);
59 80 $self->walker($sym->second);
60 80 $self->walker($sym->third);
61 } else {
62 0 warn "$sp id: " . $sym->id;
63 0 warn "$sp line: " . $sym->line;
64 0 warn "$sp ldp: ". $sym->lbp;
65 0 warn "$sp udp: ". $sym->ubp;
66 0 warn "$sp type: ". $sym->type;
67  
68 0 warn "$sp arity: ". $sym->arity;
69 0 warn "$sp assignment: ". $sym->assignment;
70 0 warn "$sp value: ". $sym->value;
71  
72 0 warn "$sp first: " . $sym->first;
73 0 $sp .= ' ';
74 0 $self->walker($sym->first);
75 0 $sp =~ s/^.//;
76  
77 0 warn "$sp second: " . $sym->second;
78 0 $sp .= ' ';
79 0 $self->walker($sym->second);
80 0 $sp =~ s/^.//;
81  
82 0 warn "$sp third: " . $sym->third;
83 0 $sp .= ' ';
84 0 $self->walker($sym->third);
85 0 $sp =~ s/^.//;
86  
87 0 warn $sp . '----------';
88 }
89 }
90 }
91  
92 2 1;
93 __END__
↑ Summary