VideoHost/Video/Storage.pm

filter: Statementstmt 34.0% 16 / 47 Branchbran 0.0% 0 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 50.0% 4 / 8 Podpod 0.0% 0 / 4 totaltotal 28.1% 20 / 71 CC 10 SCAR 29.7
CC
10
Cov
27%
video_dirs
42.0
check_errors
12.0
find_by_short_name
12.0
CRAP 19.4
↑ Summary VideoHost/Video.pm »
1 package App::VideoHost::Video::Storage;
2 {
3 1 $App::VideoHost::Video::Storage::VERSION = '0.143310'; # TRIAL
4 }
5  
6 # ABSTRACT: Manage a list of L<App::VideoHost::Video>s
7  
8 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use File::Spec;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 1 ▶use App::VideoHost::Video;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 1 ▶use Carp qw/croak/;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 1 has 'directory' => ( is => 'rw' );
16  
17 0 ▶sub check_errors {
Subroutine check_errors: not called CC=3 SCAR=24.8
Pod undocumented
18 0 my $self = shift;
19  
20 0 my @errors;
21 0 foreach my $video ($self->list) {
22 eval
23 0 { $video->check; 1; }
24 0 ▶ or do {
Branch: 1 branch
BranchTrueFalseTotal
eval { do { $video->check; 1 } } or do { my $error = $@; chomp $error; push @errors, $video->directory . ": $error" } 0 0 0
25 0 my $error = $@;
26 0 chomp $error;
27 0 push @errors, $video->directory . ": $error";
28 }
29 }
30 0 return @errors;
31 }
32  
33 0 ▶sub video_dirs {
Subroutine video_dirs: not called CC=6 SCAR=37.4
Pod undocumented
34 0 my $self = shift;
35 0 my $dir = $self->directory;
36  
37 0 ▶ croak "no directory provided" unless $dir;
Branch: 1 branch
BranchTrueFalseTotal
unless $dir 0 0 0
38 0 ▶ croak "directory $dir does not exist" unless -d $self->directory;
Branch: 1 branch
BranchTrueFalseTotal
unless -d $self->directory 0 0 0
39  
40 0 my @potential_dirs = glob File::Spec->catdir($dir, "*");
41 0 my @dirs;
42 0 foreach (@potential_dirs) {
43 0 ▶ next if /^\./;
Branch: 1 branch
BranchTrueFalseTotal
if /^\./ 0 0 0
44 0 ▶ next if ! -d;
Branch: 1 branch
BranchTrueFalseTotal
unless -d $_ 0 0 0
45 0 push @dirs, $_;
46 }
47
48 0 return @dirs;
49 }
50  
51 0 ▶sub list {
Subroutine list: not called CC=1 SCAR=6.9
Pod undocumented
52 0 my $self = shift;
53 0 return reverse sort { $a->metadata('date') cmp $b->metadata('date') }
54 0 map { App::VideoHost::Video->new(directory => $_) }
55 $self->video_dirs;
56 }
57  
58 0 ▶sub find_by_short_name {
Subroutine find_by_short_name: not called CC=3 SCAR=24.8
Pod undocumented
59 0 my $self = shift;
60 0 my $title = shift;
61 0 foreach ($self->list) {
62 0 ▶ if ($title eq $_->short_name) {
Branch: 1 branch
BranchTrueFalseTotal
if ($title eq $_->short_name) 0 0 0
63 0 return $_;
64 }
65 }
66 0 return;
67  
68 }
69  
70 1 1;
71  
72 __END__
↑ Summary VideoHost/Video.pm »