File Coverage

blib/lib/Dist/Zilla/Plugin/ShareDir.pm
Criterion Covered Total %
statement 18 18 100.0
branch 2 2 100.0
condition n/a
subroutine 5 5 100.0
pod 0 2 0.0
total 25 27 92.5


line stmt bran cond sub pod time code
1             package Dist::Zilla::Plugin::ShareDir 6.030;
2             # ABSTRACT: install a directory's contents as "ShareDir" content
3              
4 11     11   7699 use Moose;
  11         37  
  11         108  
5              
6 11     11   77504 use Dist::Zilla::Pragmas;
  11         33  
  11         102  
7              
8 11     11   88 use namespace::autoclean;
  11         27  
  11         89  
9              
10             #pod =head1 SYNOPSIS
11             #pod
12             #pod In your F<dist.ini>:
13             #pod
14             #pod [ShareDir]
15             #pod dir = share
16             #pod
17             #pod If no C<dir> is provided, the default is F<share>.
18             #pod
19             #pod =cut
20              
21             has dir => (
22             is => 'ro',
23             isa => 'Str',
24             default => 'share',
25             );
26              
27             sub find_files {
28 14     14 0 46 my ($self) = @_;
29              
30 14         586 my $dir = $self->dir;
31             my $files = [
32 124         386 grep { index($_->name, "$dir/") == 0 }
33 14         40 @{ $self->zilla->files }
  14         435  
34             ];
35             }
36              
37             sub share_dir_map {
38 14     14 0 65 my ($self) = @_;
39 14         98 my $files = $self->find_files;
40 14 100       168 return unless @$files;
41              
42 5         158 return { dist => $self->dir };
43             }
44              
45             with 'Dist::Zilla::Role::ShareDir';
46             __PACKAGE__->meta->make_immutable;
47             1;
48              
49             __END__
50              
51             =pod
52              
53             =encoding UTF-8
54              
55             =head1 NAME
56              
57             Dist::Zilla::Plugin::ShareDir - install a directory's contents as "ShareDir" content
58              
59             =head1 VERSION
60              
61             version 6.030
62              
63             =head1 SYNOPSIS
64              
65             In your F<dist.ini>:
66              
67             [ShareDir]
68             dir = share
69              
70             If no C<dir> is provided, the default is F<share>.
71              
72             =head1 PERL VERSION
73              
74             This module should work on any version of perl still receiving updates from
75             the Perl 5 Porters. This means it should work on any version of perl released
76             in the last two to three years. (That is, if the most recently released
77             version is v5.40, then this module should work on both v5.40 and v5.38.)
78              
79             Although it may work on older versions of perl, no guarantee is made that the
80             minimum required version will not be increased. The version may be increased
81             for any reason, and there is no promise that patches will be accepted to lower
82             the minimum required perl.
83              
84             =head1 AUTHOR
85              
86             Ricardo SIGNES 😏 <cpan@semiotic.systems>
87              
88             =head1 COPYRIGHT AND LICENSE
89              
90             This software is copyright (c) 2023 by Ricardo SIGNES.
91              
92             This is free software; you can redistribute it and/or modify it under
93             the same terms as the Perl 5 programming language system itself.
94              
95             =cut