| 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
| |||||||||||
| 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
| |||||||||||
| 38 | 0 | ▶ | croak "directory $dir does not exist" unless -d $self->directory; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 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
| |||||||||||
| 44 | 0 | ▶ | next if ! -d; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 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
| |||||||||||
| 63 | 0 | return $_; | |||||||||
| 64 | } | ||||||||||
| 65 | } | ||||||||||
| 66 | 0 | return; | |||||||||
| 67 | |||||||||||
| 68 | } | ||||||||||
| 69 | |||||||||||
| 70 | 1 | 1; | |||||||||
| 71 | |||||||||||
| 72 | __END__ | ||||||||||