MojoX/I18N/Lexemes.pm

filter: Statementstmt 100% 50 / 50 Branchbran 88.8% 16 / 18 Conditioncond 83.8% 26 / 31 MC/DCmcdc 66.6% 10 / 15 Subroutinesub 100% 9 / 9 Podpod 100% 1 / 1 totaltotal 90.3% 112 / 124 CC 22 SCAR 28.1
CC
22
Cov
93%
parse
22.4
BEGIN
1.0
BEGIN
1.0
CRAP 16.7
« Mojolicious/Command/generate/lexicon.pm ↑ Summary Mojolicious/Command/Author/generate/lexicon.pm »
1 package MojoX::I18N::Lexemes;
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 base 'Mojo::Base';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 4 our $VERSION = 0.995;
9  
10 4 ▶use Mojo::Template;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 4 ▶use Mojo::Server;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 3 ▶__PACKAGE__->attr(renderer => sub { Mojo::Template->new });
Subroutine __ANON__: called CC=1 SCAR=0.0
14 3 ▶__PACKAGE__->attr(helper => sub {'l'});
Subroutine __ANON__: called CC=1 SCAR=0.0
15 2 ▶__PACKAGE__->attr(helper_re => sub {qr/l\s*(\([^\)]+\))/});
Subroutine __ANON__: called CC=1 SCAR=0.0
16  
17 8 ▶sub parse {
Subroutine parse: called CC=22 SCAR=31.1
Pod documented
18 8 my ($self, $template) = @_;
19  
20 8 my $mt = $self->renderer;
21 8 $mt->parse($template);
22  
23 8 my $lexemes = [];
24  
25 8 my $multiline = 0;
26 8 my $args = '';
27 8 foreach my $line (@{$mt->tree}) {
28 93 ▶ for (my $j = 0; $j < @{$line}; $j += 2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($j < @{$line;}) 93 93 186
29 93 my $type = $line->[$j];
30 93 ▶ my $value = $line->[$j + 1] || '';
Condition100%2/2
$$line[$j + 1] || ''
l!l
5340
MC/DC100%1/1
$$line[$j + 1] || ''
$$line[$j + 1]
Truth table100%2/2
A
A= $$line[$j + 1]
Aresult
11
00
31 93 ▶ if ($value) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value) 53 40 93
32 53 $value =~ s/^\s*//;
33 }
34  
35 93 ▶ if ($multiline) {
Branch: 3 branches
BranchTrueFalseTotal
if ($multiline) { } 25 68 93
elsif ($type eq 'expr' || $type eq 'escp' and $value and substr($value, 0, length($self->helper) + 1) eq $self->helper . ' ') { } 15 53 68
elsif ($type eq 'expr' || $type eq 'escp' and $value and $value =~ $self->helper_re) { } 2 102 104
36 25 ▶ if ($type eq 'expr' || $type eq 'escp' || $type eq 'line') {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq 'expr' or $type eq 'escp' or $type eq 'line') { } 10 15 25
Condition100%6/6
$type eq "expr" or $type eq "escp" or $type eq "line"
l!l&&r!l&&!r
5515
$type eq "expr" or $type eq "escp"
l!l&&r!l&&!r
2320
MC/DC100%3/3
$type eq "expr" or $type eq "escp" or $type eq "line"
$type eq "expr" $type eq "escp" $type eq "line"
Truth table100%4/4
A or B or C
A= $type eq "expr"B= $type eq "escp"C= $type eq "line"
ABCresult
1XX1
01X1
0011
0000
37 10 $args .= $value;
38 }
39 else {
40 15 $multiline = 0;
41 }
42 }
43 ▶ elsif (($type eq 'expr' or $type eq 'escp')
Condition88%8/9
$type eq "expr" || $type eq "escp" and $value and substr($value, 0, length($self->helper) + 1) eq $self->helper . ' '
!ll&&!rl&&r
51215
$type eq "expr" || $type eq "escp" and $value
!ll&&!rl&&r
51017
$type eq "expr" or $type eq "escp"
l!l&&r!l&&!r
9851
MC/DC75%3/4
$type eq "expr" || $type eq "escp" and $value and substr($value, 0, length($self->helper) + 1) eq $self->helper . ' '
$type eq "expr" $type eq "escp" $value substr($value, 0, length($self->helper) + 1) eq $self->helper . ' '
Truth table57%4/7
A or B and C and D
A= $type eq "expr"B= $type eq "escp"C= $valueD= substr($value, 0, length($self->helper) + 1) eq $self->helper . ' '
ABCDresult
00XX0
1X0X0
010X0
1X100
01100
1X111
01111
44 && $value
45 && substr($value, 0, length($self->helper) + 1) eq
46 $self->helper . ' ')
47 {
48  
49 15 $args = substr $value, length($self->helper) + 1;
50  
51 15 ▶ unless (($line->[$j + 2] || '') eq 'text') {
Branch: 1 branch
BranchTrueFalseTotal
unless (($$line[$j + 2] || "") eq "text") 15 0 15
Condition50%1/2
$$line[$j + 2] || ''
l!l
015
MC/DC0%0/1
$$line[$j + 2] || ''
$$line[$j + 2]
Truth table50%1/2
A
A= $$line[$j + 2]
Aresult
11
00
52  
53 15 $multiline = 1;
54 }
55  
56 }
57 ▶ elsif (($type eq 'expr' or $type eq 'escp')
Condition66%6/9
$type eq "expr" || $type eq "escp" and $value and $value =~ $self->helper_re
!ll&&!rl&&r
5102
$type eq "expr" || $type eq "escp" and $value
!ll&&!rl&&r
5102
$type eq "expr" or $type eq "escp"
l!l&&r!l&&!r
2051
MC/DC25%1/4
$type eq "expr" || $type eq "escp" and $value and $value =~ $self->helper_re
$type eq "expr" $type eq "escp" $value $value =~ $self->helper_re
Truth table28%2/7
A or B and C and D
A= $type eq "expr"B= $type eq "escp"C= $valueD= $value =~ $self->helper_re
ABCDresult
00XX0
1X0X0
010X0
1X100
01100
1X111
01111
58 && $value
59 && $value =~ $self->helper_re)
60 {
61 2 $args = $1;
62 }
63  
64 93 ▶ if ($args && !$multiline) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args and not $multiline) 17 76 93
Condition100%3/3
$args and not $multiline
!ll&&!rl&&r
512517
MC/DC100%2/2
$args and not $multiline
$args not $multiline
Truth table100%3/3
A and not(B)
A= $argsB= not $multiline
ABresult
0X0
100
111
65 17 my ($lexem) = (eval $args);
66 17 ▶ push @$lexemes, $lexem if $lexem;
Branch: 1 branch
BranchTrueFalseTotal
if $lexem 17 0 17
67  
68 17 $args = '';
69 }
70  
71 }
72 }
73 8 return $lexemes;
74 }
75  
76 4 1;
77 __END__
« Mojolicious/Command/generate/lexicon.pm ↑ Summary Mojolicious/Command/Author/generate/lexicon.pm »