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.029;
2             # ABSTRACT: a callback-based FileFinder plugin
3              
4 49     49   1702 use Moose;
  49         128  
  49         471  
5             with 'Dist::Zilla::Role::FileFinder';
6              
7 49     49   358059 use Dist::Zilla::Pragmas;
  49         203  
  49         530  
8              
9 49     49   439 use namespace::autoclean;
  49         143  
  49         538  
10              
11 49     49   4821 use Moose::Util::TypeConstraints;
  49         197  
  49         722  
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 609 my ($self) = @_;
27              
28 228         7695 my $method = '_find_via_' . $self->style;
29              
30 228         1214 $self->$method;
31             }
32              
33             sub _find_via_grep {
34 127     127   375 my ($self) = @_;
35              
36 127         444 my @files = grep { $self->code->($_, $self) } @{ $self->zilla->files };
  795         22372  
  127         3757  
37 127         890 return \@files;
38             }
39              
40             sub _find_via_list {
41 101     101   351 my ($self) = @_;
42              
43 101         2957 my $code = $self->code;
44 101         601 $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.029
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) 2022 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