| 1 | package Dist::Zilla::Plugin::MetaNoIndex 6.040; | ||
| 2 | # ABSTRACT: Stop CPAN from indexing stuff | ||
| 3 | |||
| 4 | 2 | ▶ | use Moose; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 2 | with 'Dist::Zilla::Role::MetaProvider'; | |
| 6 | |||
| 7 | 2 | ▶ | use Dist::Zilla::Pragmas; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | |||
| 9 | 2 | ▶ | use namespace::autoclean; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 10 | |||
| 11 | #pod =encoding utf8 | ||
| 12 | #pod | ||
| 13 | #pod =head1 SYNOPSIS | ||
| 14 | #pod | ||
| 15 | #pod In your F<dist.ini>: | ||
| 16 | #pod | ||
| 17 | #pod [MetaNoIndex] | ||
| 18 | #pod | ||
| 19 | #pod directory = t/author | ||
| 20 | #pod directory = examples | ||
| 21 | #pod | ||
| 22 | #pod file = lib/Foo.pm | ||
| 23 | #pod | ||
| 24 | #pod package = My::Module | ||
| 25 | #pod | ||
| 26 | #pod namespace = My::Module | ||
| 27 | #pod | ||
| 28 | #pod =head1 DESCRIPTION | ||
| 29 | #pod | ||
| 30 | #pod This plugin allows you to prevent PAUSE/CPAN from indexing files you don't | ||
| 31 | #pod want indexed. This is useful if you build test classes or example classes | ||
| 32 | #pod that are used for those purposes only, and are not part of the distribution. | ||
| 33 | #pod It does this by adding a C<no_index> block to your F<META.json> (or | ||
| 34 | #pod F<META.yml>) file in your distribution. | ||
| 35 | #pod | ||
| 36 | #pod =for Pod::Coverage mvp_aliases mvp_multivalue_args | ||
| 37 | #pod | ||
| 38 | #pod =cut | ||
| 39 | |||
| 40 | 2 | my %ATTR_ALIAS = ( | |
| 41 | directories => [ qw(directory dir folder) ], | ||
| 42 | files => [ qw(file) ], | ||
| 43 | packages => [ qw(package class module) ], | ||
| 44 | namespaces => [ qw(namespace) ], | ||
| 45 | ); | ||
| 46 | |||
| 47 | 1 | ▶ | sub mvp_aliases { |
|
Subroutine
mvp_aliases: called CC=3 SCAR=11.0
Pod
undocumented
| |||
| 48 | 1 | my %alias_for; | |
| 49 | |||
| 50 | 1 | for my $key (keys %ATTR_ALIAS) { | |
| 51 | 4 | $alias_for{ $_ } = $key for @{ $ATTR_ALIAS{$key} }; | |
| 52 | } | ||
| 53 | |||
| 54 | 1 | return \%alias_for; | |
| 55 | } | ||
| 56 | |||
| 57 | 1 | ▶ | sub mvp_multivalue_args { return keys %ATTR_ALIAS } |
|
Subroutine
mvp_multivalue_args: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 58 | |||
| 59 | #pod =attr directories | ||
| 60 | #pod | ||
| 61 | #pod Exclude folders and everything in them, for example: F<author.t> | ||
| 62 | #pod | ||
| 63 | #pod Aliases: C<folder>, C<dir>, C<directory> | ||
| 64 | #pod | ||
| 65 | #pod =attr files | ||
| 66 | #pod | ||
| 67 | #pod Exclude a specific file, for example: F<lib/Foo.pm> | ||
| 68 | #pod | ||
| 69 | #pod Alias: C<file> | ||
| 70 | #pod | ||
| 71 | #pod =attr packages | ||
| 72 | #pod | ||
| 73 | #pod Exclude by package name, for example: C<My::Package> | ||
| 74 | #pod | ||
| 75 | #pod Aliases: C<class>, C<module>, C<package> | ||
| 76 | #pod | ||
| 77 | #pod =attr namespaces | ||
| 78 | #pod | ||
| 79 | #pod Exclude everything under a specific namespace, for example: C<My::Package> | ||
| 80 | #pod | ||
| 81 | #pod Alias: C<namespace> | ||
| 82 | #pod | ||
| 83 | #pod B<NOTE:> This will not exclude the package C<My::Package>, only everything | ||
| 84 | #pod under it like C<My::Package::Foo>. | ||
| 85 | #pod | ||
| 86 | #pod =cut | ||
| 87 | |||
| 88 | 2 | for my $attr (keys %ATTR_ALIAS) { | |
| 89 | 8 | has $attr => ( | |
| 90 | is => 'ro', | ||
| 91 | isa => 'ArrayRef[Str]', | ||
| 92 | init_arg => $attr, | ||
| 93 | predicate => "_has_$attr", | ||
| 94 | ); | ||
| 95 | } | ||
| 96 | |||
| 97 | #pod =method metadata | ||
| 98 | #pod | ||
| 99 | #pod Returns a reference to a hash containing the distribution's no_index metadata. | ||
| 100 | #pod | ||
| 101 | #pod =cut | ||
| 102 | |||
| 103 | 1 | ▶ | sub metadata { |
|
Subroutine
metadata: called CC=1 SCAR=0.0
Pod
documented
| |||
| 104 | 1 | my $self = shift; | |
| 105 | return { | ||
| 106 | no_index => { | ||
| 107 | 4 | map {; my $reader = $_->[0]; ($_->[1] => [ sort @{ $self->$reader } ]) } | |
| 108 | 4 | grep {; my $pred = "_has_$_->[0]"; $self->$pred } | |
| 109 | 1 | map {; [ $_ => $ATTR_ALIAS{$_}[0] ] } | |
| 110 | keys %ATTR_ALIAS | ||
| 111 | } | ||
| 112 | }; | ||
| 113 | } | ||
| 114 | |||
| 115 | 2 | __PACKAGE__->meta->make_immutable; | |
| 116 | 2 | 1; | |
| 117 | |||
| 118 | #pod =head1 SEE ALSO | ||
| 119 | #pod | ||
| 120 | #pod Dist::Zilla roles: L<MetaProvider|Dist::Zilla::Role::MetaProvider>. | ||
| 121 | #pod | ||
| 122 | #pod =cut | ||
| 123 | |||
| 124 | __END__ | ||