| 1 | package Dist::Zilla::Plugin::RemovePrereqs 6.040; | ||
| 2 | # ABSTRACT: a plugin to remove gathered prereqs | ||
| 3 | |||
| 4 | 2 | ▶ | use Moose; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 2 | with 'Dist::Zilla::Role::PrereqSource'; | |
| 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 | 2 | ▶ | use MooseX::Types::Moose qw(ArrayRef); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 12 | 2 | ▶ | use MooseX::Types::Perl qw(ModuleName); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 13 | |||
| 14 | #pod =head1 SYNOPSIS | ||
| 15 | #pod | ||
| 16 | #pod In your F<dist.ini>: | ||
| 17 | #pod | ||
| 18 | #pod [RemovePrereqs] | ||
| 19 | #pod remove = Foo::Bar | ||
| 20 | #pod remove = MRO::Compat | ||
| 21 | #pod | ||
| 22 | #pod This will remove any prerequisite of any type from any prereq phase. This is | ||
| 23 | #pod useful for eliminating incorrectly detected prereqs. | ||
| 24 | #pod | ||
| 25 | #pod =head1 SEE ALSO | ||
| 26 | #pod | ||
| 27 | #pod Dist::Zilla plugins: | ||
| 28 | #pod L<Prereqs|Dist::Zilla::Plugin::Prereqs>, | ||
| 29 | #pod L<AutoPrereqs|Dist::Zilla::Plugin::AutoPrereqs>. | ||
| 30 | #pod | ||
| 31 | #pod =cut | ||
| 32 | |||
| 33 | 2 | ▶ | sub mvp_multivalue_args { qw(modules_to_remove) } |
|
Subroutine
mvp_multivalue_args: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 34 | |||
| 35 | 2 | ▶ | sub mvp_aliases { |
|
Subroutine
mvp_aliases: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 36 | 2 | return { remove => 'modules_to_remove' } | |
| 37 | } | ||
| 38 | |||
| 39 | 2 | has modules_to_remove => ( | |
| 40 | is => 'ro', | ||
| 41 | isa => ArrayRef[ ModuleName ], | ||
| 42 | required => 1, | ||
| 43 | ); | ||
| 44 | |||
| 45 | 0 | ▶ | around dump_config => sub { |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 46 | 0 | my ($orig, $self) = @_; | |
| 47 | 0 | my $config = $self->$orig; | |
| 48 | |||
| 49 | my $this_config = { | ||
| 50 | 0 | modules_to_remove => [ sort @{ $self->modules_to_remove } ], | |
| 51 | }; | ||
| 52 | |||
| 53 | 0 | $config->{'' . __PACKAGE__} = $this_config; | |
| 54 | |||
| 55 | 0 | return $config; | |
| 56 | 2 | }; | |
| 57 | |||
| 58 | 2 | my @phases = qw(configure build test runtime develop); | |
| 59 | 2 | my @types = qw(requires recommends suggests conflicts); | |
| 60 | |||
| 61 | 2 | ▶ | sub register_prereqs { |
|
Subroutine
register_prereqs: called CC=4 SCAR=13.9
Pod
undocumented
| |||
| 62 | 2 | my ($self) = @_; | |
| 63 | |||
| 64 | 2 | my $prereqs = $self->zilla->prereqs; | |
| 65 | |||
| 66 | 2 | for my $p (@phases) { | |
| 67 | 10 | for my $t (@types) { | |
| 68 | 40 | for my $m (@{ $self->modules_to_remove }) { | |
| 69 | 60 | $prereqs->requirements_for($p, $t)->clear_requirement($m); | |
| 70 | } | ||
| 71 | } | ||
| 72 | } | ||
| 73 | } | ||
| 74 | |||
| 75 | 2 | __PACKAGE__->meta->make_immutable; | |
| 76 | 2 | 1; | |
| 77 | |||
| 78 | __END__ | ||