scripts/yatt.info

filter: Statementstmt 56.2% 72 / 128 Branchbran 23.8% 10 / 42 Conditioncond 11.1% 1 / 9 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 76.9% 20 / 26 Podpod n/a totaltotal 48.8% 103 / 211 CC 28 SCAR 27.1
CC
28
Cov
46%
show_isa_tree
56.0
list_target_dirs
30.0
is_in_template_dir
20.0
CRAP 15.1
« blib/lib/YATT/Lite/Util/FindMethods.pm ↑ Summary blib/lib/YATT/Lite/WebMVC0/Partial/Session.pm »
1 #!/usr/bin/env perl
2 # -*- coding: utf-8 -*-
3 #----------------------------------------
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use warnings qw(FATAL all NONFATAL misc);
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use constant DEBUG_LIB => $ENV{DEBUG_YATT_CLI_LIB};
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use FindBin; BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=3 SCAR=14.2
8 1 ▶ if (-r (my $libFn = "$FindBin::RealBin/libdir.pl")) {
Branch: 2 branches
BranchTrueFalseTotal
if (-r (my $libFn = "$FindBin::RealBin/libdir.pl")) { } 1 0 1
elsif ($FindBin::RealBin =~ m[/local/bin$ ]x) { } 0 0 0
9 1 print STDERR "# using $libFn\n" if DEBUG_LIB;
10 1 do $libFn
11 }
12 elsif ($FindBin::RealBin =~ m{/local/bin$ }x) {
13 0 print STDERR "# using local/lib/perl5\n" if DEBUG_LIB;
14 0 require lib;
15 0 lib->import($FindBin::RealBin . "/../lib/perl5");
16 }
17 else {
18 0 print STDERR "# No special libdir\n" if DEBUG_LIB;
19 }
20 }
21 sub MY () {__PACKAGE__}
22 #----------------------------------------
23  
24 1 ▶use mro 'c3'; # XXX: Not fully compatible.
Subroutine BEGIN: called CC=1 SCAR=0.0
25 1 ▶use parent qw/YATT::Lite::Object/;
Subroutine BEGIN: called CC=1 SCAR=0.0
26 1 ▶use YATT::Lite::MFields qw/dispatcher
Subroutine BEGIN: called CC=1 SCAR=0.0
27 dir
28 linear
29 from
30 1 /;
31  
32 1 ▶use YATT::Lite::Util qw/globref look_for_globref lexpand/;
Subroutine BEGIN: called CC=1 SCAR=0.0
33 1 ▶use YATT::Lite::Util::CmdLine qw/run/;
Subroutine BEGIN: called CC=1 SCAR=0.0
34  
35  
36 1 ▶use YATT::Lite;
Subroutine BEGIN: called CC=1 SCAR=0.0
37 1 ▶use YATT::Lite::Factory;
Subroutine BEGIN: called CC=1 SCAR=0.0
38 1 ▶use YATT::Lite::LRXML;
Subroutine BEGIN: called CC=1 SCAR=0.0
39 1 ▶use YATT::Lite::Core;
Subroutine BEGIN: called CC=1 SCAR=0.0
40 1 ▶use YATT::Lite::CGen::Perl;
Subroutine BEGIN: called CC=1 SCAR=0.0
41  
42 1 ▶use YATT::Lite::Walker;
Subroutine BEGIN: called CC=1 SCAR=0.0
43  
44 {
45 1 ▶ my $disp = YATT::Lite::Factory->load_factory_offline
Branch: 1 branch
BranchTrueFalseTotal
my $disp = "YATT::Lite::Factory"->load_factory_offline or die "Can't find YATT app script!\n" 1 0 1
46 or die "Can't find YATT app script!\n";
47  
48 1 my MY $cmd = MY->new;
49 1 $cmd->{dispatcher} = $disp;
50  
51 1 $cmd->run(\@ARGV);
52 }
53  
54 1 ▶sub cmd_isa {
Subroutine cmd_isa: called CC=5 SCAR=27.4
55 1 (my MY $self, my (@path)) = @_;
56  
57 1 my $disp = $self->{dispatcher};
58  
59 1 ▶ if (not @path) {
Branch: 1 branch
BranchTrueFalseTotal
if (not @path) { } 1 0 1
60 1 $self->show_isa(dispatcher => ref $disp);
61 } else {
62 0 foreach my $path (@path) {
63 0 my ($dir, $file) = do {
64 0 ▶ if (-d $path) {
Branch: 1 branch
BranchTrueFalseTotal
if (-d $path) { } 0 0 0
65 0 ($path)
66 } else {
67 0 (File::Basename::dirname($path), File::Basename::basename($path));
68 }
69 };
70 0 my $dh = $disp->get_dirhandler($dir);
71  
72 0 ▶ if (defined $file) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $file) { } 0 0 0
73 0 my ($part, $sub, $pkg) = $dh->open_trans->find_part_handler($file);
74 0 $self->show_isa(File => $pkg);
75 # my ($tmpl) = $dh->open_trans->find_file($file);
76 # $self->show_isa(File => $tmpl->cget('entns'));
77 } else {
78 0 $self->show_isa(DirApp => ref $dh);
79 }
80 }
81 }
82 }
83  
84 1 ▶sub show_isa {
Subroutine show_isa: called CC=5 SCAR=20.4
85 1 (my MY $self, my ($title, $class)) = @_;
86 1 ▶ if ($self->{linear}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'linear'}) { } 1 0 1
87 1 print "$title=$class\n";
88 1 foreach my $super (@{mro::get_linear_isa($class)}) {
89 12 my $fn = $self->get_class_filename($super);
90 12 ▶ print " ", $super, "\t", $fn ? "[$fn]" : "", "\n";
Branch: 1 branch
BranchTrueFalseTotal
$fn ? : 1 11 12
91 }
92 } else {
93 0 print $class;
94 0 ▶ if (my $fn = $self->get_class_filename($class)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $fn = $self->get_class_filename($class)) 0 0 0
95 0 print "\t[$fn]";
96 }
97 0 print "\n";
98 0 $self->show_isa_tree(0, {}, *{globref($class, 'ISA')}{ARRAY});
99 }
100 }
101  
102 0 ▶sub show_isa_tree {
Subroutine show_isa_tree: not called CC=7 SCAR=40.3
103 0 (my MY $self, my ($depth, $seen, $supers)) = @_;
104 0 $depth++;
105 0 foreach my $super (@$supers) {
106 0 my $cnt = $seen->{$super}++;
107 0 ▶ print " " x $depth, $cnt ? "*" : " ", $super;
Branch: 1 branch
BranchTrueFalseTotal
$cnt ? : 0 0 0
108 0 ▶ if (my $fn = $self->get_class_filename($super)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $fn = $self->get_class_filename($super)) 0 0 0
109 0 print "\t[$fn]";
110 }
111 0 print "\n";
112 0 ▶ next if $cnt;
Branch: 1 branch
BranchTrueFalseTotal
if $cnt 0 0 0
113 0 ▶ my $sym = look_for_globref($super, 'ISA')
Branch: 1 branch
BranchTrueFalseTotal
my $sym = look_for_globref($super, "ISA") or next 0 0 0
114 or next;
115 0 my $isa = *{$sym}{ARRAY}
116 0 ▶ or next;
Branch: 1 branch
BranchTrueFalseTotal
my $isa = *{$sym;}{"ARRAY"} or next 0 0 0
117 0 $self->show_isa_tree($depth, $seen, $isa);
118 }
119 }
120  
121 12 ▶sub get_class_filename {
Subroutine get_class_filename: called CC=4 SCAR=14.0
122 12 (my MY $self, my ($cls, $default)) = @_;
123 12 ▶ my $fnsym = look_for_globref($cls, 'filename')
Branch: 1 branch
BranchTrueFalseTotal
my $fnsym = look_for_globref($cls, "filename") or return $default 3 9 12
124 or return $default;
125 3 my $sub = *{$fnsym}{CODE}
126 3 ▶ or return $default;
Branch: 1 branch
BranchTrueFalseTotal
my $sub = *{$fnsym;}{"CODE"} or return $default 1 2 3
127 1 ▶ $sub->() // $default;
Condition33%1/3
&$sub() // $default
l!l&&r!l&&!r
100
MC/DC0%0/2
&$sub() // $default
&$sub() $default
Truth table33%1/3
A // B
A= &$sub()B= $default
ABresult
1X1
011
000
128 }
129  
130 0 ▶sub is_in_template_dir {
Subroutine is_in_template_dir: not called CC=4 SCAR=30.0
131 0 (my MY $self, my $path) = @_;
132 0 foreach my $dir (lexpand($self->{dispatcher}->{tmpldirs})) {
133 0 ▶ if (length $dir <= length $path
Branch: 1 branch
BranchTrueFalseTotal
if (length $dir <= length $path and substr($dir, 0, length $path) eq $path) 0 0 0
Condition0%0/3
length $dir <= length $path and substr($dir, 0, length $path) eq $path
!ll&&!rl&&r
000
MC/DC0%0/2
length $dir <= length $path and substr($dir, 0, length $path) eq $path
length $dir <= length $path substr($dir, 0, length $path) eq $path
Truth table0%0/3
A and B
A= length $dir <= length $pathB= substr($dir, 0, length $path) eq $path
ABresult
0X0
100
111
134 and substr($dir, 0, length $path) eq $path) {
135 0 return 1;
136 }
137 }
138 0 return 0;
139 }
140  
141 0 ▶sub list_target_dirs {
Subroutine list_target_dirs: not called CC=5 SCAR=34.0
142 0 (my MY $self, my $dirSpec) = @_;
143  
144 0 ▶ if ($dirSpec) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dirSpec) { } 0 0 0
145 0 $self->rel2abs($dirSpec)
146 } else {
147 0 my $cwd = Cwd::getcwd;
148 0 ▶ if ($self->is_in_template_dir($cwd)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->is_in_template_dir($cwd)) { } 0 0 0
149 0 $cwd;
150 } else {
151 0 ▶ $self->{dispatcher}->cget('doc_root') // do {
Condition0%0/3
$self->{"dispatcher"}->cget("doc_root") // do { if (my $dir = $self->{"dispatcher"}->cget("per_role_docroot")) { [glob("$dir/[a-z]*")]; } else { Carp::croak("doc_root is empty!"); } }
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"dispatcher"}->cget("doc_root") // do { if (my $dir = $self->{"dispatcher"}->cget("per_role_docroot")) { [glob("$dir/[a-z]*")]; } else { Carp::croak("doc_root is empty!"); } }
$self->{"dispatcher"}->cget("doc_root") do { if (my $dir = $self->{"dispatcher"}->cget("per_role_docroot")) { [glob("$dir/[a-z]*")]; } else { Carp::croak("doc_root is empty!"); } }
Truth table0%0/3
A // B
A= $self->{"dispatcher"}->cget("doc_root")B= do { if (my $dir = $self->{"dispatcher"}->cget("per_role_docroot")) { [glob("$dir/[a-z]*")]; } else { Carp::croak("doc_root is empty!"); } }
ABresult
1X1
011
000
152 0 ▶ if (my $dir = $self->{dispatcher}->cget('per_role_docroot')) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $dir = $self->{'dispatcher'}->cget('per_role_docroot')) { } 0 0 0
153 0 [glob("$dir/[a-z]*")];
154 } else {
155 0 Carp::croak "doc_root is empty!"
156 }
157 }
158 }
159 }
160 }
161  
162 0 ▶sub cmd_list_widgets {
Subroutine cmd_list_widgets: not called CC=2 SCAR=17.9
163 0 (my MY $self, my ($widgetNameGlob)) = @_;
164  
165 0 my $cwdOrFileList = $self->list_target_dirs($self->{from});
166  
167 0 require Text::Glob;
168  
169 walk(
170 factory => $self->{dispatcher},
171 from => $cwdOrFileList,
172 ($widgetNameGlob ? (
173 (name_match => Text::Glob::glob_to_regex($widgetNameGlob))
174 ) : ()),
175 0 ▶ widget => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
176 0 my ($args) = @_;
177 0 print ":$args->{name}\n";
178 },
179 0 ▶ item => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
180 0 my ($args) = @_;
181 0 print "# ", $args->{tree}->cget('path'), "\n";
182 },
183 0 ▶ );
Branch: 1 branch
BranchTrueFalseTotal
$widgetNameGlob ? : 0 0 0
184  
185 # $yatt->get_trans->list_items
186 # $yatt->get_trans->find_file('index')
187 # $yatt->get_trans->find_file('index')->list_parts
188 }
« blib/lib/YATT/Lite/Util/FindMethods.pm ↑ Summary blib/lib/YATT/Lite/WebMVC0/Partial/Session.pm »