| 1 | package Document::Maker::Source::FileScan; | ||
| 2 | |||
| 3 | use Moose; | ||
| 4 | |||
| 5 | use Scalar::Util qw/blessed/; | ||
| 6 | use Document::Maker::FileFinder::Query; | ||
| 7 | |||
| 8 | with map { "Document::Maker::Role::$_" } qw/Component Dependency/; | ||
| 9 | |||
| 10 | has finder => qw/is ro required 1/, handles => [qw/found fresh freshness/]; | ||
| 11 | |||
| 12 | sub BUILD { | ||
| 13 | my $self = shift; | ||
| 14 | my $finder = $self->finder; | ||
| 15 | return if blessed $finder; | ||
| 16 | if (Document::Maker::FileFinder::Query->recognize($finder)) { | ||
| 17 | $self->{finder} = Document::Maker::FileFinder::Query->new(query => $finder); | ||
| 18 | } | ||
| 19 | } | ||
| 20 | |||
| 21 | sub make { | ||
| 22 | my $self = shift; | ||
| 23 | for my $found (@{ $self->found }) { | ||
| 24 | next if -e $found; | ||
| 25 | $self->log->debug("Don't know how to make: ", $found) and return 0 unless $self->maker->make($found); | ||
| 26 | } | ||
| 27 | } | ||
| 28 | |||
| 29 | |||
| 30 | 1; |