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