| 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'
MC/DC0%0/1
delete $args->{'syntax'} || 'TTears'
delete $args->{'syntax'}
Truth table50%1/2
A
A= delete $args->{'syntax'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
Condition100%3/3
$ast and ref $ast eq "Text::Xslate::Symbol"
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"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 241 | ▶ | return unless $ast && ref($ast) eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$ast and ref $ast eq "ARRAY"
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"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 55 | for my $sym (@{ $ast }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 80 | ▶ | if ($sym->arity eq 'call' && $sym->value eq '(') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$sym->arity eq "call" and $sym->value eq "("
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 "("
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 11 | my $first = $sym->first; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 11 | ▶ | if ($first && ref($first) eq 'Text::Xslate::Symbol') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$first and ref $first eq "Text::Xslate::Symbol"
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"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 11 | ▶ | if ($first->arity eq 'variable' && $first->value eq 'l') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$first->arity eq "variable" and $first->value eq "l"
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"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
Condition33%3/9
$second and ref $second eq "ARRAY" and $second->[0] and ref $second->[0] eq "Text::Xslate::Symbol"
$second and ref $second eq "ARRAY" and $second->[0]
$second and ref $second eq "ARRAY"
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"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 11 | my $value = $second->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 11 | ▶ | if ($value->arity eq 'literal') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 10 | $self->add_entry($value->value, $value->line); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 80 | ▶ | unless ($DEBUG) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||