| 1 | package Dist::Zilla::Plugin::ShareDir 6.040; | ||||||||||
| 2 | # ABSTRACT: install a directory's contents as "ShareDir" content | ||||||||||
| 3 | |||||||||||
| 4 | 11 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 11 | ▶ | use Dist::Zilla::Pragmas; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 11 | ▶ | use namespace::autoclean; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 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 | 11 | has dir => ( | |||||||||
| 22 | is => 'ro', | ||||||||||
| 23 | isa => 'Str', | ||||||||||
| 24 | default => 'share', | ||||||||||
| 25 | ); | ||||||||||
| 26 | |||||||||||
| 27 | 14 | ▶ | sub find_files { | ||||||||
|
Subroutine
find_files: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 28 | 14 | my ($self) = @_; | |||||||||
| 29 | |||||||||||
| 30 | 14 | my $dir = $self->dir; | |||||||||
| 31 | my $files = [ | ||||||||||
| 32 | 124 | grep { index($_->name, "$dir/") == 0 } | |||||||||
| 33 | 14 | @{ $self->zilla->files } | |||||||||
| 34 | ]; | ||||||||||
| 35 | } | ||||||||||
| 36 | |||||||||||
| 37 | 14 | ▶ | sub share_dir_map { | ||||||||
|
Subroutine
share_dir_map: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||
| 38 | 14 | my ($self) = @_; | |||||||||
| 39 | 14 | my $files = $self->find_files; | |||||||||
| 40 | 14 | ▶ | return unless @$files; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 41 | |||||||||||
| 42 | 5 | return { dist => $self->dir }; | |||||||||
| 43 | } | ||||||||||
| 44 | |||||||||||
| 45 | 11 | with 'Dist::Zilla::Role::ShareDir'; | |||||||||
| 46 | 11 | __PACKAGE__->meta->make_immutable; | |||||||||
| 47 | 11 | 1; | |||||||||
| 48 | |||||||||||
| 49 | __END__ | ||||||||||