Dist::Zilla::Plugin::FinderCode - a callback-based FileFinder plugin


Dist-Zilla documentation Contained in the Dist-Zilla distribution.

Index


Code Index:

NAME

Top

Dist::Zilla::Plugin::FinderCode - a callback-based FileFinder plugin

VERSION

Top

version 4.200008

AUTHOR

Top

Ricardo SIGNES <rjbs@cpan.org>

COPYRIGHT AND LICENSE

Top


Dist-Zilla documentation Contained in the Dist-Zilla distribution.

package Dist::Zilla::Plugin::FinderCode;
BEGIN {
  $Dist::Zilla::Plugin::FinderCode::VERSION = '4.200008';
}
use Moose;
with 'Dist::Zilla::Role::FileFinder';
# ABSTRACT: a callback-based FileFinder plugin

use Moose::Autobox;
use Moose::Util::TypeConstraints;
use namespace::autoclean;

has code => (
  is  => 'ro',
  isa => 'CodeRef',
  required => 1,
);

has style => (
  is  => 'ro',
  isa => enum([ qw(grep list) ]),
  required => 1,
);

sub find_files {
  my ($self) = @_;

  my $method = '_find_via_' . $self->style;

  $self->$method;
}

sub _find_via_grep {
  my ($self) = @_;

  my @files = grep { $self->code->($_, $self) } $self->zilla->files->flatten;
  return \@files;
}

sub _find_via_list {
  my ($self) = @_;

  my $code = $self->code;
  $self->$code;
}

1;

__END__