File Coverage

blib/lib/Dist/Zilla/Plugin/ModuleShareDirs.pm
Criterion Covered Total %
statement 13 23 56.5
branch 2 2 100.0
condition n/a
subroutine 4 5 80.0
pod 0 2 0.0
total 19 32 59.3


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