| 1 | # | ||||||||||
| 2 | # This file is part of Dist-Zilla-Plugin-RemovePrereqsMatching | ||||||||||
| 3 | # | ||||||||||
| 4 | # This software is Copyright (c) 2012 by Chris Weyl. | ||||||||||
| 5 | # | ||||||||||
| 6 | # This is free software, licensed under: | ||||||||||
| 7 | # | ||||||||||
| 8 | # The GNU Lesser General Public License, Version 2.1, February 1999 | ||||||||||
| 9 | # | ||||||||||
| 10 | package Dist::Zilla::Plugin::RemovePrereqsMatching; | ||||||||||
| 11 | { | ||||||||||
| 12 | 2 | $Dist::Zilla::Plugin::RemovePrereqsMatching::VERSION = '0.002'; | |||||||||
| 13 | } | ||||||||||
| 14 | |||||||||||
| 15 | # ABSTRACT: A more flexible prereq remover | ||||||||||
| 16 | |||||||||||
| 17 | 2 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 18 | 2 | ▶ | use namespace::autoclean; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 19 | 2 | ▶ | use MooseX::AttributeShortcuts; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 20 | |||||||||||
| 21 | 2 | with 'Dist::Zilla::Role::PrereqSource'; | |||||||||
| 22 | |||||||||||
| 23 | # debugging... | ||||||||||
| 24 | #use Smart::Comments '###'; | ||||||||||
| 25 | |||||||||||
| 26 | 2 | has remove_matching => ( | |||||||||
| 27 | traits => ['Array'], | ||||||||||
| 28 | is => 'rw', | ||||||||||
| 29 | isa => 'ArrayRef', | ||||||||||
| 30 | lazy => 1, | ||||||||||
| 31 | builder => 1, | ||||||||||
| 32 | |||||||||||
| 33 | handles => { | ||||||||||
| 34 | has_prereqs_to_remove => 'count', | ||||||||||
| 35 | }, | ||||||||||
| 36 | ); | ||||||||||
| 37 | 0 | ▶ | sub _build_remove_matching { [ ] } | ||||||||
|
Subroutine
_build_remove_matching: not called CC=1 SCAR=6.9
| |||||||||||
| 38 | |||||||||||
| 39 | 1 | ▶ | sub mvp_multivalue_args { 'remove_matching' } | ||||||||
|
Subroutine
mvp_multivalue_args: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 40 | |||||||||||
| 41 | |||||||||||
| 42 | 1 | ▶ | sub register_prereqs { | ||||||||
|
Subroutine
register_prereqs: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||
| 43 | 1 | my ($self) = @_; | |||||||||
| 44 | |||||||||||
| 45 | 1 | my $prereqs = $self->zilla->prereqs; | |||||||||
| 46 | 1 | my $raw = $prereqs->as_string_hash; | |||||||||
| 47 | |||||||||||
| 48 | 1 | my $regexes = $self->remove_matching; | |||||||||
| 49 | |||||||||||
| 50 | 1 | for my $p (keys %$raw) { | |||||||||
| 51 | 3 | for my $t (keys %{$raw->{$p}}) { | |||||||||
| 52 | 4 | for my $mod (keys %{$raw->{$p}->{$t}}) { | |||||||||
| 53 | |||||||||||
| 54 | RX: | ||||||||||
| 55 | 9 | for my $rx (@$regexes) { | |||||||||
| 56 | |||||||||||
| 57 | 9 | ▶ | next RX unless $mod =~ /$rx/; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 58 | |||||||||||
| 59 | 1 | $prereqs | |||||||||
| 60 | ->requirements_for($p, $t) | ||||||||||
| 61 | ->clear_requirement($mod) | ||||||||||
| 62 | ; | ||||||||||
| 63 | 1 | last RX; | |||||||||
| 64 | } | ||||||||||
| 65 | } | ||||||||||
| 66 | } | ||||||||||
| 67 | } | ||||||||||
| 68 | |||||||||||
| 69 | 1 | return; | |||||||||
| 70 | } | ||||||||||
| 71 | |||||||||||
| 72 | 2 | __PACKAGE__->meta->make_immutable; | |||||||||
| 73 | 2 | !!42; | |||||||||
| 74 | |||||||||||
| 75 | |||||||||||
| 76 | =pod | ||||||||||
| 77 | |||||||||||
| 78 | =encoding utf-8 | ||||||||||
| 79 | |||||||||||
| 80 | =for :stopwords Chris Weyl | ||||||||||
| 81 | |||||||||||
| 82 | =head1 NAME | ||||||||||
| 83 | |||||||||||
| 84 | Dist::Zilla::Plugin::RemovePrereqsMatching - A more flexible prereq remover | ||||||||||
| 85 | |||||||||||
| 86 | =head1 VERSION | ||||||||||
| 87 | |||||||||||
| 88 | This document describes version 0.002 of Dist::Zilla::Plugin::RemovePrereqsMatching - released June 18, 2012 as part of Dist-Zilla-Plugin-RemovePrereqsMatching. | ||||||||||
| 89 | |||||||||||
| 90 | =head1 SYNOPSIS | ||||||||||
| 91 | |||||||||||
| 92 | ; in your dist.ini | ||||||||||
| 93 | [RemovePrereqsMatching] | ||||||||||
| 94 | remove_matching = ^Template::Whatever::.*$ | ||||||||||
| 95 | remove_matching = ^Dist::Zilla.*$ | ||||||||||
| 96 | |||||||||||
| 97 | =head1 DESCRIPTION | ||||||||||
| 98 | |||||||||||
| 99 | This plugin builds on L<Dist::Zilla::Plugin::RemovePrereqs> to allow | ||||||||||
| 100 | prerequisites to be removed by regular expression, rather than string | ||||||||||
| 101 | equality. This can be useful when you have a C<DPAN> package consisting of a | ||||||||||
| 102 | bunch of modules under a common namespace, whose installation can be handled | ||||||||||
| 103 | by one common prerequisite specification. | ||||||||||
| 104 | |||||||||||
| 105 | =head1 METHODS | ||||||||||
| 106 | |||||||||||
| 107 | =head2 register_prereqs | ||||||||||
| 108 | |||||||||||
| 109 | We implement this method to scan the list of prerequisites assembled to date, | ||||||||||
| 110 | and remove any tat match any of the expressions given to us. | ||||||||||
| 111 | |||||||||||
| 112 | =for Pod::Coverage mvp_multivalue_args | ||||||||||
| 113 | |||||||||||
| 114 | =head1 OPTIONS | ||||||||||
| 115 | |||||||||||
| 116 | =head2 remove_matching | ||||||||||
| 117 | |||||||||||
| 118 | This option defines a regular expression that will be used to test | ||||||||||
| 119 | prerequisites for removal. We may be specified multiple times to define | ||||||||||
| 120 | multiple expressions to test prerequisites against; a prerequisite needs to | ||||||||||
| 121 | match at least one expression to be excluded. | ||||||||||
| 122 | |||||||||||
| 123 | =head1 SEE ALSO | ||||||||||
| 124 | |||||||||||
| 125 | Please see those modules/websites for more information related to this module. | ||||||||||
| 126 | |||||||||||
| 127 | =over 4 | ||||||||||
| 128 | |||||||||||
| 129 | =item * | ||||||||||
| 130 | |||||||||||
| 131 | L<Dist::Zilla::Plugin::RemovePrereqs> | ||||||||||
| 132 | |||||||||||
| 133 | =back | ||||||||||
| 134 | |||||||||||
| 135 | =head1 SOURCE | ||||||||||
| 136 | |||||||||||
| 137 | The development version is on github at L<http://github.com/RsrchBoy/dist-zilla-plugin-removeprereqsmatching> | ||||||||||
| 138 | and may be cloned from L<git://github.com/RsrchBoy/dist-zilla-plugin-removeprereqsmatching.git> | ||||||||||
| 139 | |||||||||||
| 140 | =head1 BUGS | ||||||||||
| 141 | |||||||||||
| 142 | Please report any bugs or feature requests on the bugtracker website | ||||||||||
| 143 | https://github.com/RsrchBoy/dist-zilla-plugin-removeprereqsmatching/issues | ||||||||||
| 144 | |||||||||||
| 145 | When submitting a bug or request, please include a test-file or a | ||||||||||
| 146 | patch to an existing test-file that illustrates the bug or desired | ||||||||||
| 147 | feature. | ||||||||||
| 148 | |||||||||||
| 149 | =head1 AUTHOR | ||||||||||
| 150 | |||||||||||
| 151 | Chris Weyl <cweyl@alumni.drew.edu> | ||||||||||
| 152 | |||||||||||
| 153 | =head1 COPYRIGHT AND LICENSE | ||||||||||
| 154 | |||||||||||
| 155 | This software is Copyright (c) 2012 by Chris Weyl. | ||||||||||
| 156 | |||||||||||
| 157 | This is free software, licensed under: | ||||||||||
| 158 | |||||||||||
| 159 | The GNU Lesser General Public License, Version 2.1, February 1999 | ||||||||||
| 160 | |||||||||||
| 161 | =cut | ||||||||||
| 162 | |||||||||||
| 163 | |||||||||||
| 164 | __END__ | ||||||||||