| 1 | package Dist::Zilla::Plugin::Prereqs 6.040; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # ABSTRACT: list simple prerequisites | ||||||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 9 | ▶ | use Moose; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 9 | with 'Dist::Zilla::Role::PrereqSource'; | |||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 9 | ▶ | use Dist::Zilla::Pragmas; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 9 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||
| 11 | #pod =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||||||
| 12 | #pod | ||||||||||||||||||||||||||||||||||||||||||||||
| 13 | #pod In your F<dist.ini>: | ||||||||||||||||||||||||||||||||||||||||||||||
| 14 | #pod | ||||||||||||||||||||||||||||||||||||||||||||||
| 15 | #pod [Prereqs] | ||||||||||||||||||||||||||||||||||||||||||||||
| 16 | #pod Foo::Bar = 1.002 | ||||||||||||||||||||||||||||||||||||||||||||||
| 17 | #pod MRO::Compat = 10 | ||||||||||||||||||||||||||||||||||||||||||||||
| 18 | #pod Sub::Exporter = 0 | ||||||||||||||||||||||||||||||||||||||||||||||
| 19 | #pod | ||||||||||||||||||||||||||||||||||||||||||||||
| 20 | #pod You can specify requirements for different phases and relationships with: | ||||||||||||||||||||||||||||||||||||||||||||||
| 21 | #pod | ||||||||||||||||||||||||||||||||||||||||||||||
| 22 | #pod [Prereqs] | ||||||||||||||||||||||||||||||||||||||||||||||
| 23 | #pod -phase = test | ||||||||||||||||||||||||||||||||||||||||||||||
| 24 | #pod -relationship = recommends | ||||||||||||||||||||||||||||||||||||||||||||||
| 25 | #pod | ||||||||||||||||||||||||||||||||||||||||||||||
| 26 | #pod Fitz::Fotz = 1.23 | ||||||||||||||||||||||||||||||||||||||||||||||
| 27 | #pod Text::SoundEx = 3 | ||||||||||||||||||||||||||||||||||||||||||||||
| 28 | #pod | ||||||||||||||||||||||||||||||||||||||||||||||
| 29 | #pod Remember that if you load two Prereqs plugins, each will needs its own name, | ||||||||||||||||||||||||||||||||||||||||||||||
| 30 | #pod added like this: | ||||||||||||||||||||||||||||||||||||||||||||||
| 31 | #pod | ||||||||||||||||||||||||||||||||||||||||||||||
| 32 | #pod [Prereqs / PluginName] | ||||||||||||||||||||||||||||||||||||||||||||||
| 33 | #pod -phase = test | ||||||||||||||||||||||||||||||||||||||||||||||
| 34 | #pod -relationship = recommends | ||||||||||||||||||||||||||||||||||||||||||||||
| 35 | #pod | ||||||||||||||||||||||||||||||||||||||||||||||
| 36 | #pod Fitz::Fotz = 1.23 | ||||||||||||||||||||||||||||||||||||||||||||||
| 37 | #pod Text::SoundEx = 3 | ||||||||||||||||||||||||||||||||||||||||||||||
| 38 | #pod | ||||||||||||||||||||||||||||||||||||||||||||||
| 39 | #pod If the name is the CamelCase concatenation of a phase and relationship | ||||||||||||||||||||||||||||||||||||||||||||||
| 40 | #pod (or just a relationship), it will set those parameters implicitly. If | ||||||||||||||||||||||||||||||||||||||||||||||
| 41 | #pod you use a custom name, but it does not specify the relationship, and | ||||||||||||||||||||||||||||||||||||||||||||||
| 42 | #pod you didn't specify either C<-phase> or C<-relationship>, it throws the | ||||||||||||||||||||||||||||||||||||||||||||||
| 43 | #pod error C<No -phase or -relationship specified>. This is to prevent a | ||||||||||||||||||||||||||||||||||||||||||||||
| 44 | #pod typo that makes the name meaningless from slipping by unnoticed. | ||||||||||||||||||||||||||||||||||||||||||||||
| 45 | #pod | ||||||||||||||||||||||||||||||||||||||||||||||
| 46 | #pod The example below is equivalent to the example above, except for the name of | ||||||||||||||||||||||||||||||||||||||||||||||
| 47 | #pod the resulting plugin: | ||||||||||||||||||||||||||||||||||||||||||||||
| 48 | #pod | ||||||||||||||||||||||||||||||||||||||||||||||
| 49 | #pod [Prereqs / TestRecommends] | ||||||||||||||||||||||||||||||||||||||||||||||
| 50 | #pod Fitz::Fotz = 1.23 | ||||||||||||||||||||||||||||||||||||||||||||||
| 51 | #pod Text::SoundEx = 3 | ||||||||||||||||||||||||||||||||||||||||||||||
| 52 | #pod | ||||||||||||||||||||||||||||||||||||||||||||||
| 53 | #pod =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||
| 54 | #pod | ||||||||||||||||||||||||||||||||||||||||||||||
| 55 | #pod This module adds "fixed" prerequisites to your distribution. These are prereqs | ||||||||||||||||||||||||||||||||||||||||||||||
| 56 | #pod with a known, fixed minimum version that doesn't change based on platform or | ||||||||||||||||||||||||||||||||||||||||||||||
| 57 | #pod other conditions. | ||||||||||||||||||||||||||||||||||||||||||||||
| 58 | #pod | ||||||||||||||||||||||||||||||||||||||||||||||
| 59 | #pod You can specify prerequisites for different phases and kinds of relationships. | ||||||||||||||||||||||||||||||||||||||||||||||
| 60 | #pod In C<RuntimeRequires>, the phase is Runtime and the relationship is Requires. | ||||||||||||||||||||||||||||||||||||||||||||||
| 61 | #pod These are described in more detail in the L<CPAN::Meta | ||||||||||||||||||||||||||||||||||||||||||||||
| 62 | #pod specification|CPAN::Meta::Spec/PREREQUISITES>. | ||||||||||||||||||||||||||||||||||||||||||||||
| 63 | #pod | ||||||||||||||||||||||||||||||||||||||||||||||
| 64 | #pod The phases are: | ||||||||||||||||||||||||||||||||||||||||||||||
| 65 | #pod | ||||||||||||||||||||||||||||||||||||||||||||||
| 66 | #pod =for :list | ||||||||||||||||||||||||||||||||||||||||||||||
| 67 | #pod * configure | ||||||||||||||||||||||||||||||||||||||||||||||
| 68 | #pod * build | ||||||||||||||||||||||||||||||||||||||||||||||
| 69 | #pod * test | ||||||||||||||||||||||||||||||||||||||||||||||
| 70 | #pod * runtime | ||||||||||||||||||||||||||||||||||||||||||||||
| 71 | #pod * develop | ||||||||||||||||||||||||||||||||||||||||||||||
| 72 | #pod | ||||||||||||||||||||||||||||||||||||||||||||||
| 73 | #pod The relationship types are: | ||||||||||||||||||||||||||||||||||||||||||||||
| 74 | #pod | ||||||||||||||||||||||||||||||||||||||||||||||
| 75 | #pod =for :list | ||||||||||||||||||||||||||||||||||||||||||||||
| 76 | #pod * requires | ||||||||||||||||||||||||||||||||||||||||||||||
| 77 | #pod * recommends | ||||||||||||||||||||||||||||||||||||||||||||||
| 78 | #pod * suggests | ||||||||||||||||||||||||||||||||||||||||||||||
| 79 | #pod * conflicts | ||||||||||||||||||||||||||||||||||||||||||||||
| 80 | #pod | ||||||||||||||||||||||||||||||||||||||||||||||
| 81 | #pod If the phase is omitted, it will default to I<runtime>; thus, specifying | ||||||||||||||||||||||||||||||||||||||||||||||
| 82 | #pod "Prereqs / Recommends" in your dist.ini is equivalent to I<RuntimeRecommends>. | ||||||||||||||||||||||||||||||||||||||||||||||
| 83 | #pod | ||||||||||||||||||||||||||||||||||||||||||||||
| 84 | #pod Not all of these phases are useful for all tools, especially tools that only | ||||||||||||||||||||||||||||||||||||||||||||||
| 85 | #pod understand version 1.x CPAN::Meta files. | ||||||||||||||||||||||||||||||||||||||||||||||
| 86 | #pod | ||||||||||||||||||||||||||||||||||||||||||||||
| 87 | #pod =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 9 | has prereq_phase => ( | |||||||||||||||||||||||||||||||||||||||||||||
| 90 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||
| 91 | isa => 'Str', | ||||||||||||||||||||||||||||||||||||||||||||||
| 92 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 93 | init_arg => 'phase', | ||||||||||||||||||||||||||||||||||||||||||||||
| 94 | default => 'runtime', | ||||||||||||||||||||||||||||||||||||||||||||||
| 95 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 9 | has prereq_type => ( | |||||||||||||||||||||||||||||||||||||||||||||
| 98 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||
| 99 | isa => 'Str', | ||||||||||||||||||||||||||||||||||||||||||||||
| 100 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 101 | init_arg => 'type', | ||||||||||||||||||||||||||||||||||||||||||||||
| 102 | default => 'requires', | ||||||||||||||||||||||||||||||||||||||||||||||
| 103 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 8 | ▶ | around dump_config => sub { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 8 | my ($orig, $self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 107 | 8 | my $config = $self->$orig; | |||||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 8 | my $this_config = { | |||||||||||||||||||||||||||||||||||||||||||||
| 110 | type => $self->prereq_type, | ||||||||||||||||||||||||||||||||||||||||||||||
| 111 | phase => $self->prereq_phase, | ||||||||||||||||||||||||||||||||||||||||||||||
| 112 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 8 | $config->{'' . __PACKAGE__} = $this_config; | |||||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 8 | return $config; | |||||||||||||||||||||||||||||||||||||||||||||
| 117 | 9 | }; | |||||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||||||
| 119 | has _prereq => ( | ||||||||||||||||||||||||||||||||||||||||||||||
| 120 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||
| 121 | isa => 'HashRef', | ||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | ▶ | default => sub { {} }, | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 9 | ); | |||||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 161 | ▶ | sub mvp_aliases { return { -relationship => '-type' } } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mvp_aliases: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 161 | ▶ | around BUILDARGS => sub { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=12 SCAR=25.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 161 | my $orig = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 129 | 161 | my ($class, @arg) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 161 | my $args = $class->$orig(@arg); | |||||||||||||||||||||||||||||||||||||||||||||
| 132 | 161 | my %copy = %{ $args }; | |||||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 161 | my $zilla = delete $copy{zilla}; | |||||||||||||||||||||||||||||||||||||||||||||
| 135 | 161 | my $name = delete $copy{plugin_name}; | |||||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 161 | my @dashed = grep { /^-/ } keys %copy; | |||||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 161 | my %other; | |||||||||||||||||||||||||||||||||||||||||||||
| 140 | 161 | for my $dkey (@dashed) { | |||||||||||||||||||||||||||||||||||||||||||||
| 141 | 13 | my $key = $dkey =~ s/^-//r; | |||||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 13 | $other{ $key } = delete $copy{ $dkey }; | |||||||||||||||||||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 161 | ▶ | confess "don't try to pass -_prereq as a build arg!" if $other{_prereq}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||||||
| 148 | # Handle magic plugin names: | ||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 161 | ▶ | unless (($other{phase} and $other{type}) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$other{"phase"} and $other{"type"} or $name =~ m[ (?: \A | / ) Prereqs? \z ]ux
$other{"phase"} and $other{"type"}
MC/DC100%3/3
$other{"phase"} and $other{"type"} or $name =~ m[ (?: \A | / ) Prereqs? \z ]ux
$other{"phase"}
$other{"type"}
$name =~ m[ (?: \A | / ) Prereqs? \z ]ux
Truth table80%4/5
A and B or C
A= $other{"phase"}B= $other{"type"}C= $name =~ m[ (?: \A | / ) Prereqs? \z ]ux
| |||||||||||||||||||||||||||||||||||||||||||||||
| 150 | # plugin comes from a bundle | ||||||||||||||||||||||||||||||||||||||||||||||
| 151 | or $name =~ m! (?: \A | / ) Prereqs? \z !x) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 121 | my ($phase, $type) = $name =~ /\A | |||||||||||||||||||||||||||||||||||||||||||||
| 154 | (Build|Test|Runtime|Configure|Develop)? | ||||||||||||||||||||||||||||||||||||||||||||||
| 155 | (Requires|Recommends|Suggests|Conflicts) | ||||||||||||||||||||||||||||||||||||||||||||||
| 156 | \z/x; | ||||||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 121 | ▶ | if ($type) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 116 | ▶ | $other{phase} ||= lc $phase if defined $phase; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$other{"phase"} ||= lc $phase
MC/DC0%0/2
$other{"phase"} ||= lc $phase
$other{"phase"}
lc $phase
Truth table33%1/3
A ||= B
A= $other{"phase"}B= lc $phase
| |||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 116 | ▶ | $other{type} ||= lc $type; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$other{"type"} ||= lc $type
MC/DC0%0/2
$other{"type"} ||= lc $type
$other{"type"}
lc $type
Truth table33%1/3
A ||= B
A= $other{"type"}B= lc $type
| |||||||||||||||||||||||||||||||||||||||||||||||
| 161 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 162 | $zilla->chrome->logger->log_fatal({ prefix => "[$name] " }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 163 | "No -phase or -relationship specified") | ||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 5 | ▶ | unless $other{phase} or $other{type}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$other{"phase"} or $other{"type"}
MC/DC100%2/2
$other{"phase"} or $other{"type"}
$other{"phase"}
$other{"type"}
Truth table100%3/3
A or B
A= $other{"phase"}B= $other{"type"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||||||
| 168 | return { | ||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 160 | zilla => $zilla, | |||||||||||||||||||||||||||||||||||||||||||||
| 170 | plugin_name => $name, | ||||||||||||||||||||||||||||||||||||||||||||||
| 171 | _prereq => \%copy, | ||||||||||||||||||||||||||||||||||||||||||||||
| 172 | %other, | ||||||||||||||||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 9 | }; | |||||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 152 | ▶ | sub register_prereqs { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
register_prereqs: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 152 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||||||
| 179 | $self->zilla->register_prereqs( | ||||||||||||||||||||||||||||||||||||||||||||||
| 180 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 181 | type => $self->prereq_type, | ||||||||||||||||||||||||||||||||||||||||||||||
| 182 | phase => $self->prereq_phase, | ||||||||||||||||||||||||||||||||||||||||||||||
| 183 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 152 | %{ $self->_prereq }, | |||||||||||||||||||||||||||||||||||||||||||||
| 185 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 9 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||||||||||||||||||||
| 189 | 9 | 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||||||
| 191 | #pod =head1 SEE ALSO | ||||||||||||||||||||||||||||||||||||||||||||||
| 192 | #pod | ||||||||||||||||||||||||||||||||||||||||||||||
| 193 | #pod =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 194 | #pod | ||||||||||||||||||||||||||||||||||||||||||||||
| 195 | #pod =item * | ||||||||||||||||||||||||||||||||||||||||||||||
| 196 | #pod | ||||||||||||||||||||||||||||||||||||||||||||||
| 197 | #pod Core Dist::Zilla plugins: | ||||||||||||||||||||||||||||||||||||||||||||||
| 198 | #pod L<@Basic|Dist::Zilla::PluginBundle::Basic>, | ||||||||||||||||||||||||||||||||||||||||||||||
| 199 | #pod L<AutoPrereqs|Dist::Zilla::Plugin::AutoPrereqs>. | ||||||||||||||||||||||||||||||||||||||||||||||
| 200 | #pod | ||||||||||||||||||||||||||||||||||||||||||||||
| 201 | #pod =item * | ||||||||||||||||||||||||||||||||||||||||||||||
| 202 | #pod | ||||||||||||||||||||||||||||||||||||||||||||||
| 203 | #pod The CPAN Meta specification: L<CPAN::Meta/PREREQUISITES>. | ||||||||||||||||||||||||||||||||||||||||||||||
| 204 | #pod | ||||||||||||||||||||||||||||||||||||||||||||||
| 205 | #pod =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 206 | #pod | ||||||||||||||||||||||||||||||||||||||||||||||
| 207 | #pod =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||||||
| 209 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||