File Coverage

blib/lib/Dist/Zilla/Plugin/RemovePrereqs.pm
Criterion Covered Total %
statement 24 24 100.0
branch n/a
condition n/a
subroutine 8 8 100.0
pod 0 3 0.0
total 32 35 91.4


line stmt bran cond sub pod time code
1             package Dist::Zilla::Plugin::RemovePrereqs 6.037;
2             # ABSTRACT: a plugin to remove gathered prereqs
3              
4 2     2   2749 use Moose;
  2         6  
  2         24  
5             with 'Dist::Zilla::Role::PrereqSource';
6              
7 2     2   16582 use Dist::Zilla::Pragmas;
  2         5  
  2         20  
8              
9 2     2   16 use namespace::autoclean;
  2         6  
  2         20  
10              
11 2     2   236 use MooseX::Types::Moose qw(ArrayRef);
  2         5  
  2         25  
12 2     2   12169 use MooseX::Types::Perl qw(ModuleName);
  2         7  
  2         17  
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     2 0 378 sub mvp_multivalue_args { qw(modules_to_remove) }
34              
35             sub mvp_aliases {
36 2     2 0 318 return { remove => 'modules_to_remove' }
37             }
38              
39             has modules_to_remove => (
40             is => 'ro',
41             isa => ArrayRef[ ModuleName ],
42             required => 1,
43             );
44              
45             around dump_config => sub {
46             my ($orig, $self) = @_;
47             my $config = $self->$orig;
48              
49             my $this_config = {
50             modules_to_remove => [ sort @{ $self->modules_to_remove } ],
51             };
52              
53             $config->{'' . __PACKAGE__} = $this_config;
54              
55             return $config;
56             };
57              
58             my @phases = qw(configure build test runtime develop);
59             my @types = qw(requires recommends suggests conflicts);
60              
61             sub register_prereqs {
62 2     2 0 5 my ($self) = @_;
63              
64 2         55 my $prereqs = $self->zilla->prereqs;
65              
66 2         6 for my $p (@phases) {
67 10         261 for my $t (@types) {
68 40         911 for my $m (@{ $self->modules_to_remove }) {
  40         877  
69 60         719 $prereqs->requirements_for($p, $t)->clear_requirement($m);
70             }
71             }
72             }
73             }
74              
75             __PACKAGE__->meta->make_immutable;
76             1;
77              
78             __END__
79              
80             =pod
81              
82             =encoding UTF-8
83              
84             =head1 NAME
85              
86             Dist::Zilla::Plugin::RemovePrereqs - a plugin to remove gathered prereqs
87              
88             =head1 VERSION
89              
90             version 6.037
91              
92             =head1 SYNOPSIS
93              
94             In your F<dist.ini>:
95              
96             [RemovePrereqs]
97             remove = Foo::Bar
98             remove = MRO::Compat
99              
100             This will remove any prerequisite of any type from any prereq phase. This is
101             useful for eliminating incorrectly detected prereqs.
102              
103             =head1 PERL VERSION
104              
105             This module should work on any version of perl still receiving updates from
106             the Perl 5 Porters. This means it should work on any version of perl
107             released in the last two to three years. (That is, if the most recently
108             released version is v5.40, then this module should work on both v5.40 and
109             v5.38.)
110              
111             Although it may work on older versions of perl, no guarantee is made that the
112             minimum required version will not be increased. The version may be increased
113             for any reason, and there is no promise that patches will be accepted to
114             lower the minimum required perl.
115              
116             =head1 SEE ALSO
117              
118             Dist::Zilla plugins:
119             L<Prereqs|Dist::Zilla::Plugin::Prereqs>,
120             L<AutoPrereqs|Dist::Zilla::Plugin::AutoPrereqs>.
121              
122             =head1 AUTHOR
123              
124             Ricardo SIGNES 😏 <cpan@semiotic.systems>
125              
126             =head1 COPYRIGHT AND LICENSE
127              
128             This software is copyright (c) 2026 by Ricardo SIGNES.
129              
130             This is free software; you can redistribute it and/or modify it under
131             the same terms as the Perl 5 programming language system itself.
132              
133             =cut