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.037;
2             # ABSTRACT: install a directory's contents as "ShareDir" content
3              
4 11     11   9268 use Moose;
  11         27  
  11         123  
5              
6 11     11   84021 use Dist::Zilla::Pragmas;
  11         41  
  11         107  
7              
8 11     11   85 use namespace::autoclean;
  11         31  
  11         145  
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 38 my ($self) = @_;
29              
30 14         657 my $dir = $self->dir;
31             my $files = [
32 124         457 grep { index($_->name, "$dir/") == 0 }
33 14         32 @{ $self->zilla->files }
  14         494  
34             ];
35             }
36              
37             sub share_dir_map {
38 14     14 0 44 my ($self) = @_;
39 14         89 my $files = $self->find_files;
40 14 100       123 return unless @$files;
41              
42 5         172 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.037
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
76             released in the last two to three years. (That is, if the most recently
77             released version is v5.40, then this module should work on both v5.40 and
78             v5.38.)
79              
80             Although it may work on older versions of perl, no guarantee is made that the
81             minimum required version will not be increased. The version may be increased
82             for any reason, and there is no promise that patches will be accepted to
83             lower the minimum required perl.
84              
85             =head1 AUTHOR
86              
87             Ricardo SIGNES 😏 <cpan@semiotic.systems>
88              
89             =head1 COPYRIGHT AND LICENSE
90              
91             This software is copyright (c) 2026 by Ricardo SIGNES.
92              
93             This is free software; you can redistribute it and/or modify it under
94             the same terms as the Perl 5 programming language system itself.
95              
96             =cut