| 1 | 2 | ▶ | use v5.10; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 2 | 2 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 2 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | package Dist::Zilla::Plugin::Prereqs::AuthorDeps; | ||||||||||
| 6 | # ABSTRACT: Add Dist::Zilla authordeps to META files as develop prereqs | ||||||||||
| 7 | 2 | our $VERSION = '0.007'; | |||||||||
| 8 | |||||||||||
| 9 | 2 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 2 | ▶ | use MooseX::Types::Moose qw( HashRef ArrayRef Str ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 2 | ▶ | use List::Util qw/min/; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | 2 | ▶ | use Path::Tiny; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | |||||||||||
| 14 | 2 | ▶ | use Dist::Zilla::Util::AuthorDeps 5.021; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 15 | 2 | ▶ | use Dist::Zilla 4; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 16 | |||||||||||
| 17 | 2 | ▶ | use constant MAX_DZIL_VERSION => 5; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 18 | |||||||||||
| 19 | 2 | with 'Dist::Zilla::Role::PrereqSource'; | |||||||||
| 20 | |||||||||||
| 21 | #pod =attr phase | ||||||||||
| 22 | #pod | ||||||||||
| 23 | #pod Phase for prereqs. Defaults to 'develop'. | ||||||||||
| 24 | #pod | ||||||||||
| 25 | #pod =cut | ||||||||||
| 26 | |||||||||||
| 27 | has phase => ( | ||||||||||
| 28 | is => ro =>, | ||||||||||
| 29 | isa => Str, | ||||||||||
| 30 | lazy => 1, | ||||||||||
| 31 | 2 | ▶ | default => sub { 'develop' }, | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 32 | 2 | ); | |||||||||
| 33 | |||||||||||
| 34 | #pod =attr relation | ||||||||||
| 35 | #pod | ||||||||||
| 36 | #pod Relation type. Defaults to 'requires'. | ||||||||||
| 37 | #pod | ||||||||||
| 38 | #pod =cut | ||||||||||
| 39 | |||||||||||
| 40 | has relation => ( | ||||||||||
| 41 | is => ro =>, | ||||||||||
| 42 | isa => Str, | ||||||||||
| 43 | lazy => 1, | ||||||||||
| 44 | 1 | ▶ | default => sub { 'requires' }, | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 45 | 2 | ); | |||||||||
| 46 | |||||||||||
| 47 | #pod =attr exclude | ||||||||||
| 48 | #pod | ||||||||||
| 49 | #pod Module to exclude from prereqs. May be specified multiple times. | ||||||||||
| 50 | #pod | ||||||||||
| 51 | #pod =cut | ||||||||||
| 52 | |||||||||||
| 53 | has exclude => ( | ||||||||||
| 54 | is => ro =>, | ||||||||||
| 55 | isa => ArrayRef [Str], | ||||||||||
| 56 | lazy => 1, | ||||||||||
| 57 | 1 | ▶ | default => sub { [] } | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 58 | 2 | ); | |||||||||
| 59 | |||||||||||
| 60 | 2 | has _exclude_hash => ( | |||||||||
| 61 | is => ro =>, | ||||||||||
| 62 | isa => HashRef [Str], | ||||||||||
| 63 | lazy => 1, | ||||||||||
| 64 | builder => '_build__exclude_hash' | ||||||||||
| 65 | ); | ||||||||||
| 66 | |||||||||||
| 67 | 2 | ▶ | sub _build__exclude_hash { | ||||||||
|
Subroutine
_build__exclude_hash: called CC=1 SCAR=0.0
| |||||||||||
| 68 | 2 | my ( $self, ) = @_; | |||||||||
| 69 | 2 | return { map { ; $_ => 1 } @{ $self->exclude } }; | |||||||||
| 70 | } | ||||||||||
| 71 | |||||||||||
| 72 | 2 | ▶ | sub mvp_multivalue_args { return qw(exclude) } | ||||||||
|
Subroutine
mvp_multivalue_args: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 73 | |||||||||||
| 74 | 2 | ▶ | sub register_prereqs { | ||||||||
|
Subroutine
register_prereqs: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||
| 75 | 2 | my ($self) = @_; | |||||||||
| 76 | 2 | my $zilla = $self->zilla; | |||||||||
| 77 | 2 | my $phase = $self->phase; | |||||||||
| 78 | 2 | my $relation = $self->relation; | |||||||||
| 79 | |||||||||||
| 80 | 2 | my $authordeps = Dist::Zilla::Util::AuthorDeps::extract_author_deps('.'); | |||||||||
| 81 | |||||||||||
| 82 | 2 | for my $req (@$authordeps) { | |||||||||
| 83 | 13 | my ( $mod, $version ) = each %$req; | |||||||||
| 84 | 13 | ▶ | next if $self->_exclude_hash->{$mod}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 85 | |||||||||||
| 86 | 12 | (my $filename = $mod) =~ s{::}{/}g; | |||||||||
| 87 | 12 | ▶ | next if path($self->zilla->root, $filename.'.pm')->exists; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 88 | |||||||||||
| 89 | 11 | $zilla->register_prereqs( { phase => $phase, type => $relation }, $mod, $version ); | |||||||||
| 90 | } | ||||||||||
| 91 | |||||||||||
| 92 | $zilla->register_prereqs( | ||||||||||
| 93 | 2 | { phase => $phase, type => $relation }, | |||||||||
| 94 | "Dist::Zilla", min( MAX_DZIL_VERSION, int( Dist::Zilla->VERSION ) ), | ||||||||||
| 95 | ); | ||||||||||
| 96 | |||||||||||
| 97 | 2 | return; | |||||||||
| 98 | } | ||||||||||
| 99 | |||||||||||
| 100 | 2 | 1; | |||||||||
| 101 | |||||||||||
| 102 | |||||||||||
| 103 | # vim: ts=4 sts=4 sw=4 et: | ||||||||||
| 104 | |||||||||||
| 105 | __END__ | ||||||||||