I'm implementing a store where the list of files is read from a manifest file. I ended up copying find_files and modifying the definition of the iterator to
my @manifest = $self->path->child('MANIFEST')->lines( { chomp => 1 } );
my $iter = sub { return @manifest ? Path::Tiny::path(shift @manifest ) : undef }
Instead of duplicating find_files, it'd be cleaner to separate the generation of the original list of files from the filtering of the files. That's what this PR does. It adds a files method which returns an iterator. With this, my code now looks like:
package StatoclesX::Role::Store::Manifest;
use Moo::Role;
around files => sub {
my ( $orig, $self ) = @_;
my @manifest = $self->path->child('MANIFEST')->lines( { chomp => 1 } );
sub { return @manifest ? Path::Tiny::path(shift @manifest ) : undef }
};
1;
Coverage increased (+0.01%) to 92.078% when pulling 1280cefc4989fd2a48974fd668726759a0206dbd on djerius:store-files into 2445fda405a571c88dacd7a48c6286cbb2492648 on preaction:master.
I'm implementing a store where the list of files is read from a manifest file. I ended up copying
find_files
and modifying the definition of the iterator toInstead of duplicating
find_files
, it'd be cleaner to separate the generation of the original list of files from the filtering of the files. That's what this PR does. It adds afiles
method which returns an iterator. With this, my code now looks like: