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