blib/lib/App/MaMGal/Maker.pm untested

filter: Statementstmt 0.0% 0 / 34 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 7 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 0.0% 0 / 9 Podpod 0.0% 0 / 4 totaltotal 0.0% 0 / 63 CC 4 SCAR 20.8
CC
4
Cov
0%
_make_any
20.0
init
2.0
make_without_roots
2.0
CRAP 8.0
1 # mamgal - a program for creating static image galleries
2 # Copyright 2007, 2008 Marcin Owsiany <marcin@owsiany.pl>
3 # See the README file for license information
4 # The runner module
5 package App::MaMGal::Maker;
6 use strict;
7 use warnings;
8 use base 'App::MaMGal::Base';
9 use Carp;
10 use App::MaMGal::Entry::Dir;
11  
12 sub init
13 {
14 my $self = shift;
15 my $entry_factory = shift or croak "Need an entry factory arg";
16 ref $entry_factory and $entry_factory->isa('App::MaMGal::EntryFactory') or croak "Arg is not an EntryFactory, but a [$entry_factory]";
17 $self->{entry_factory} = $entry_factory;
18 }
19  
20 sub make_without_roots
21 {
22 my $self = shift;
23 return $self->_make_any(0, @_);
24 }
25  
26 sub make_roots
27 {
28 my $self = shift;
29 return $self->_make_any(1, @_);
30 }
31  
32 sub _make_any
33 {
34 my $self = shift;
35 my $dirs_are_roots = shift;
36 # TODO: replace with croak after cmdline parsing is added
37 die "Argument required.\n" unless @_;
38  
39 my @dirs = map {
40 my $d = $self->{entry_factory}->create_entry_for($_);
41 App::MaMGal::SystemException->throw(message => '%s: not a directory.', objects => [$_]) unless $d->isa('App::MaMGal::Entry::Dir');
42 $d->set_root(1) if $dirs_are_roots;
43 $d
44 } @_;
45 $_->make foreach @dirs;
46  
47 return 1;
48 }
49  
50 1;