blib/lib/YATT/Lite/CLI/GenPerl.pm

filter: Statementstmt 93.0% 40 / 43 Branchbran 87.5% 7 / 8 Conditioncond 100% 3 / 3 MC/DCmcdc 100% 2 / 2 Subroutinesub 100% 8 / 8 Podpod 0.0% 0 / 1 totaltotal 92.3% 60 / 65 CC 7 SCAR 10.5
CC
7
Cov
93%
main
5.0
__ANON__
3.0
BEGIN
1.0
CRAP 2.9
« blib/lib/YATT/Lite/CLI/Render.pm ↑ Summary blib/lib/YATT/Lite/Partial/AppPath.pm »
1 package YATT::Lite::CLI::GenPerl; sub MY () {__PACKAGE__}
2 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 4 ▶use warnings qw(FATAL all NONFATAL misc);
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use mro 'c3';
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 4 ▶use parent qw(YATT::Lite::CLI);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 4 ▶use YATT::Lite::MFields qw/all/;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 4 ▶use YATT::Lite::Entities qw/*SYS/;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 4 require File::Spec;
12  
13 #========================================
14 # yatt.genperl [--all] FILE...
15 #
16 # Emits the perl code YATT::Lite generates for each template
17 # (the jspc-style offline entry to the transpiler).
18 # --all also emits the generated code of dependencies (base templates,
19 # widgets in other files); by default only the target (depth == 1).
20 #
21 # Note: open_trans/find_product are still VFS-internal API. They are
22 # shared with the language server (Inspector), so they are candidates
23 # for a future $site->compile facade - tracked in GH-270.
24 #========================================
25  
26 5 ▶sub main {
Subroutine main: called CC=5 SCAR=16.2
Pod undocumented
27 5 my ($self, @files) = @_;
28 5 my $nerror = 0;
29 5 foreach my $fn (@files) {
30 5 my $abs = YATT::Lite::Util::normalize_fs_path(File::Spec->rel2abs($fn));
31 5 ▶ unless (-e $abs) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-e $abs) 1 4 5
32 # Note: VFS find_file would lazily create a Template object even
33 # for a missing file, so test the filesystem here.
34 1 warn "No such file: $fn\n";
35 1 $nerror++;
36 1 next;
37 }
38 4 my $site = $self->site_for($abs);
39 4 local $SYS = $site;
40 4 my ($dh, $name) = $site->resolve_file($abs);
41 4 $dh->fconfigure_encoding(\*STDOUT, \*STDERR);
42 4 my $trans = $dh->open_trans;
43 4 ▶ my $tmpl = $trans->find_file($name) or do {
Branch: 1 branch
BranchTrueFalseTotal
my $tmpl = $trans->find_file($name) or do { warn "No such file: $fn\n"; ++$nerror; next } 4 0 4
44 0 warn "No such file: $fn\n";
45 0 $nerror++;
46 0 next;
47 };
48 $trans->find_product
49 9 ▶ (perl => $tmpl, sink => sub {
Subroutine __ANON__: called CC=3 SCAR=11.0
50 9 my ($info, @script) = @_;
51 9 ▶ print @script if $self->{all} || $info->{depth} == 1;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"all"} or $info->{"depth"} == 1 5 4 9
Condition100%3/3
$self->{"all"} or $info->{"depth"} == 1
l!l&&r!l&&!r
234
MC/DC100%2/2
$self->{"all"} or $info->{"depth"} == 1
$self->{"all"} $info->{"depth"} == 1
Truth table100%3/3
A or B
A= $self->{"all"}B= $info->{"depth"} == 1
ABresult
1X1
011
000
52 9 eval {
53 # Generated scripts must be evaluated even when not printed,
54 # so that entity definitions materialize for dependent
55 # templates. Errors in generated code are yatt.lint's job,
56 # not ours - hence the bare eval.
57 9 YATT::Lite::Util::ckeval(@script);
58 };
59 4 });
60 }
61 5 ▶ $nerror ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$nerror ? : 1 4 5
62 }
63  
64 4 1;
« blib/lib/YATT/Lite/CLI/Render.pm ↑ Summary blib/lib/YATT/Lite/Partial/AppPath.pm »