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