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.030;
2             # ABSTRACT: a callback-based FileFinder plugin
3              
4 49     49   1544 use Moose;
  49         141  
  49         449  
5             with 'Dist::Zilla::Role::FileFinder';
6              
7 49     49   356634 use Dist::Zilla::Pragmas;
  49         167  
  49         471  
8              
9 49     49   475 use namespace::autoclean;
  49         151  
  49         569  
10              
11 49     49   4989 use Moose::Util::TypeConstraints;
  49         156  
  49         690  
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 652 my ($self) = @_;
27              
28 228         7705 my $method = '_find_via_' . $self->style;
29              
30 228         1178 $self->$method;
31             }
32              
33             sub _find_via_grep {
34 127     127   335 my ($self) = @_;
35              
36 127         449 my @files = grep { $self->code->($_, $self) } @{ $self->zilla->files };
  795         22152  
  127         3736  
37 127         788 return \@files;
38             }
39              
40             sub _find_via_list {
41 101     101   332 my ($self) = @_;
42              
43 101         3083 my $code = $self->code;
44 101         549 $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.030
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 released
68             in the last two to three years. (That is, if the most recently released
69             version is v5.40, then this module should work on both v5.40 and v5.38.)
70              
71             Although it may work on older versions of perl, no guarantee is made that the
72             minimum required version will not be increased. The version may be increased
73             for any reason, and there is no promise that patches will be accepted to lower
74             the minimum required perl.
75              
76             =head1 AUTHOR
77              
78             Ricardo SIGNES 😏 <cpan@semiotic.systems>
79              
80             =head1 COPYRIGHT AND LICENSE
81              
82             This software is copyright (c) 2023 by Ricardo SIGNES.
83              
84             This is free software; you can redistribute it and/or modify it under
85             the same terms as the Perl 5 programming language system itself.
86              
87             =cut