« 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 93 | my $type = $line->[$j]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 93 | ▶ | my $value = $line->[$j + 1] || ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$$line[$j + 1] || ''
MC/DC100%1/1
$$line[$j + 1] || ''
$$line[$j + 1]
Truth table100%2/2
A
A= $$line[$j + 1]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 93 | ▶ | if ($value) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 53 | $value =~ s/^\s*//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 93 | ▶ | if ($multiline) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 25 | ▶ | if ($type eq 'expr' || $type eq 'escp' || $type eq 'line') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$type eq "expr" or $type eq "escp" or $type eq "line"
$type eq "expr" or $type eq "escp"
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"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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 . ' '
$type eq "expr" || $type eq "escp" and $value
$type eq "expr" or $type eq "escp"
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 . ' '
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
Condition50%1/2
$$line[$j + 2] || ''
MC/DC0%0/1
$$line[$j + 2] || ''
$$line[$j + 2]
Truth table50%1/2
A
A= $$line[$j + 2]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
$type eq "expr" || $type eq "escp" and $value
$type eq "expr" or $type eq "escp"
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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | && $value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | && $value =~ $self->helper_re) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 2 | $args = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 93 | ▶ | if ($args && !$multiline) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$args and not $multiline
MC/DC100%2/2
$args and not $multiline
$args
not $multiline
Truth table100%3/3
A and not(B)
A= $argsB= not $multiline
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 17 | my ($lexem) = (eval $args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 17 | ▶ | push @$lexemes, $lexem if $lexem; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 17 | $args = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 8 | return $lexemes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 4 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||