Galileo/File.pm

filter: Statementstmt 96.7% 30 / 31 Branchbran 75.0% 6 / 8 Conditioncond 100% 2 / 2 MC/DCmcdc 100% 1 / 1 Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 1 totaltotal 91.8% 45 / 49 CC 6 SCAR 11.0
CC
6
Cov
93%
_get_list
5.0
list
2.0
BEGIN
1.0
CRAP 3.0
« Galileo/Admin.pm ↑ Summary Galileo/Menu.pm »
1 package Galileo::File;
2 1 ▶use Mojo::Base 'Mojolicious::Controller';
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 1 ▶use File::Next;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use File::Spec;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 2 ▶sub list {
Subroutine list: called CC=2 SCAR=7.0
Pod undocumented
8 2 my $self = shift;
9 2 my $dir = $self->upload_path;
10  
11 2 ▶ my $iter = -d $dir ? File::Next::files( $dir ) : undef;
Branch: 1 branch
BranchTrueFalseTotal
-d $dir ? : 2 0 2
12  
13 4 ▶ $self->on( json => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
14 4 my ($ws, $data) = @_;
15 4 my $list = _get_list( $iter, $dir, $data->{limit} );
16 4 $ws->send({ json => $list });
17 2 });
18 }
19  
20 4 ▶sub _get_list {
Subroutine _get_list: called CC=5 SCAR=16.1
21 4 my ($iter, $dir, $limit) = @_;
22  
23 4 ▶ unless ( defined $iter ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $iter) 0 4 4
24 0 return +{files => [], finished => \1};
25 }
26  
27 4 ▶ $limit ||= 20;
Condition100%2/2
$limit ||= 20
l!l
31
MC/DC100%1/1
$limit ||= 20
$limit
Truth table100%2/2
A
A= $limit
Aresult
11
00
28  
29 4 my @files;
30 4 my $finished = \0;
31  
32 4 while ( 1 ) {
33 8 ▶ last unless $limit--;
Branch: 1 branch
BranchTrueFalseTotal
unless $limit-- 2 6 8
34  
35 6 my $file = $iter->();
36 6 ▶ unless (defined $file) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $file) 2 4 6
37 2 $finished = \1;
38 2 last;
39 }
40  
41 4 push @files, File::Spec->abs2rel($file, $dir);
42 }
43  
44 4 return +{ files => [sort @files], finished => $finished };
45 }
46  
47 1 1;
48  
« Galileo/Admin.pm ↑ Summary Galileo/Menu.pm »