| File-Corresponding documentation | Contained in the File-Corresponding distribution. |
File::Corresponding::Group - A group of File::Profile objects
A group of File::Profile objects which define which files belong together.
Name/description of this File Group. It should describe what's common between the files in the group.
Array ref with File::Profile objects that make up the group.
Find files corresponding to $file (given the config in ->file_profiles) and return found @$files.
Return two item list with the $file_fragment and first profile that matches $file, or an empty list if there is no match.
| File-Corresponding documentation | Contained in the File-Corresponding distribution. |
package File::Corresponding::Group; use Moose; use Data::Dumper; use File::Path; use Path::Class; use Moose::Autobox; use File::Corresponding::File::Profile;
has 'name' => (is => 'ro', isa => 'Str', default => "");
has 'file_profiles' => ( is => 'rw', isa => 'ArrayRef[File::Corresponding::File::Profile]', default => sub { [] }, );
sub corresponding { my $self = shift; my ($file) = @_; my ($file_base, $fragment, $matching_profile) = $self->matching_file_fragment_profile($file); $matching_profile or return []; my $found_files = $self->file_profiles ->grep(sub { $_ != $matching_profile }) ->map(sub { $_->new_found_if_file_exists( $matching_profile, $file_base, $fragment, ) }); return $found_files; }
sub matching_file_fragment_profile { my $self = shift; my ($file) = @_; for my $profile ($self->file_profiles->flatten) { my ($file_base, $file_fragment) = $profile->matching_file_fragment($file); $file_base and return ($file_base, $file_fragment, $profile); } return (); } 1; __END__