File Coverage

blib/lib/Dist/Zilla/Plugin/FinderCode.pm
Criterion Covered Total %
statement 23 23 100.0
branch n/a
condition n/a
subroutine 7 7 100.0
pod 0 1 0.0
total 30 31 96.7


line stmt bran cond sub pod time code
1             package Dist::Zilla::Plugin::FinderCode 6.037;
2             # ABSTRACT: a callback-based FileFinder plugin
3              
4 49     49   1912 use Moose;
  49         121  
  49         506  
5             with 'Dist::Zilla::Role::FileFinder';
6              
7 49     49   381881 use Dist::Zilla::Pragmas;
  49         128  
  49         536  
8              
9 49     49   381 use namespace::autoclean;
  49         128  
  49         976  
10              
11 49     49   4847 use Moose::Util::TypeConstraints;
  49         127  
  49         625  
12              
13             has code => (
14             is => 'ro',
15             isa => 'CodeRef',
16             required => 1,
17             );
18              
19             has style => (
20             is => 'ro',
21             isa => enum([ qw(grep list) ]),
22             required => 1,
23             );
24              
25             sub find_files {
26 228     228 0 673 my ($self) = @_;
27              
28 228         10083 my $method = '_find_via_' . $self->style;
29              
30 228         1142 $self->$method;
31             }
32              
33             sub _find_via_grep {
34 127     127   342 my ($self) = @_;
35              
36 127         269 my @files = grep { $self->code->($_, $self) } @{ $self->zilla->files };
  795         28742  
  127         4970  
37 127         945 return \@files;
38             }
39              
40             sub _find_via_list {
41 101     101   355 my ($self) = @_;
42              
43 101         3862 my $code = $self->code;
44 101         475 $self->$code;
45             }
46              
47             __PACKAGE__->meta->make_immutable;
48             1;
49              
50             __END__
51              
52             =pod
53              
54             =encoding UTF-8
55              
56             =head1 NAME
57              
58             Dist::Zilla::Plugin::FinderCode - a callback-based FileFinder plugin
59              
60             =head1 VERSION
61              
62             version 6.037
63              
64             =head1 PERL VERSION
65              
66             This module should work on any version of perl still receiving updates from
67             the Perl 5 Porters. This means it should work on any version of perl
68             released in the last two to three years. (That is, if the most recently
69             released version is v5.40, then this module should work on both v5.40 and
70             v5.38.)
71              
72             Although it may work on older versions of perl, no guarantee is made that the
73             minimum required version will not be increased. The version may be increased
74             for any reason, and there is no promise that patches will be accepted to
75             lower the minimum required perl.
76              
77             =head1 AUTHOR
78              
79             Ricardo SIGNES 😏 <cpan@semiotic.systems>
80              
81             =head1 COPYRIGHT AND LICENSE
82              
83             This software is copyright (c) 2026 by Ricardo SIGNES.
84              
85             This is free software; you can redistribute it and/or modify it under
86             the same terms as the Perl 5 programming language system itself.
87              
88             =cut