File Coverage

blib/lib/Dist/Zilla/Plugin/Prereqs/AuthorDeps.pm
Criterion Covered Total %
statement 36 36 100.0
branch 2 2 100.0
condition n/a
subroutine 10 10 100.0
pod 0 2 0.0
total 48 50 96.0


line stmt bran cond sub pod time code
1 2     2   3963616 use v5.10;
  2         9  
2 2     2   12 use strict;
  2         4  
  2         58  
3 2     2   10 use warnings;
  2         4  
  2         140  
4              
5             package Dist::Zilla::Plugin::Prereqs::AuthorDeps;
6             # ABSTRACT: Add Dist::Zilla authordeps to META files as develop prereqs
7             our $VERSION = '0.005'; # from Dist-Zilla-Plugin-Prereqs-AuthorDeps-0.005.tar.gz
8              
9 2     2   10 use Moose;
  2         5  
  2         18  
10 2     2   14224 use MooseX::Types::Moose qw( HashRef ArrayRef Str );
  2         6  
  2         36  
11              
12 2     2   13725 use Dist::Zilla::Util::AuthorDeps 5.021;
  2         2719  
  2         85  
13 2     2   15 use Dist::Zilla 4;
  2         44  
  2         869  
14              
15             with 'Dist::Zilla::Role::PrereqSource';
16              
17             #pod =attr phase
18             #pod
19             #pod Phase for prereqs. Defaults to 'develop'.
20             #pod
21             #pod =cut
22              
23             has phase => (
24             is => ro =>,
25             isa => Str,
26             lazy => 1,
27             default => sub { 'develop' },
28             );
29              
30             #pod =attr relation
31             #pod
32             #pod Relation type. Defaults to 'requires'.
33             #pod
34             #pod =cut
35              
36             has relation => (
37             is => ro =>,
38             isa => Str,
39             lazy => 1,
40             default => sub { 'requires' },
41             );
42              
43             #pod =attr exclude
44             #pod
45             #pod Module to exclude from prereqs. May be specified multiple times.
46             #pod
47             #pod =cut
48              
49             has exclude => (
50             is => ro =>,
51             isa => ArrayRef [Str],
52             lazy => 1,
53             default => sub { [] }
54             );
55              
56             has _exclude_hash => (
57             is => ro =>,
58             isa => HashRef [Str],
59             lazy => 1,
60             builder => '_build__exclude_hash'
61             );
62              
63             sub _build__exclude_hash {
64 2     2   5 my ( $self, ) = @_;
65 2         4 return { map { ; $_ => 1 } @{ $self->exclude } };
  1         62  
  2         96  
66             }
67              
68 2     2 0 506 sub mvp_multivalue_args { return qw(exclude) }
69              
70             sub register_prereqs {
71 2     2 0 918121 my ($self) = @_;
72 2         87 my $zilla = $self->zilla;
73 2         130 my $phase = $self->phase;
74 2         94 my $relation = $self->relation;
75              
76 2         12 my $authordeps = Dist::Zilla::Util::AuthorDeps::extract_author_deps( '.' );
77              
78 2         9554 for my $req (@$authordeps) {
79 12         2228 my ( $mod, $version ) = each %$req;
80 12 100       674 next if $self->_exclude_hash->{$mod};
81 11         80 $zilla->register_prereqs( { phase => $phase, type => $relation }, $mod, $version );
82             }
83              
84             $zilla->register_prereqs(
85 2         480 { phase => $phase, type => $relation },
86             "Dist::Zilla", int( Dist::Zilla->VERSION ),
87             );
88              
89 2         574 return;
90             }
91              
92             1;
93              
94              
95             # vim: ts=4 sts=4 sw=4 et:
96              
97             __END__
98              
99             =pod
100              
101             =encoding UTF-8
102              
103             =head1 NAME
104              
105             Dist::Zilla::Plugin::Prereqs::AuthorDeps - Add Dist::Zilla authordeps to META files as develop prereqs
106              
107             =head1 VERSION
108              
109             version 0.005
110              
111             =head1 SYNOPSIS
112              
113             # in dist.ini:
114              
115             [Prereqs::AuthorDeps]
116              
117             =head1 DESCRIPTION
118              
119             This adds L<Dist::Zilla> itself and the result of the C<dzil authordeps>
120             command to the 'develop' phase prerequisite list.
121              
122             =head1 ATTRIBUTES
123              
124             =head2 phase
125              
126             Phase for prereqs. Defaults to 'develop'.
127              
128             =head2 relation
129              
130             Relation type. Defaults to 'requires'.
131              
132             =head2 exclude
133              
134             Module to exclude from prereqs. May be specified multiple times.
135              
136             =for Pod::Coverage mvp_multivalue_args register_prereqs
137              
138             =head1 SEE ALSO
139              
140             L<Dist::Zilla::Plugin::Prereqs::Plugins> is similar but puts all plugins after
141             expanding any bundles into prerequisites, which is a much longer list that you
142             would get from C<dzil authordeps>.
143              
144             =for :stopwords cpan testmatrix url annocpan anno bugtracker rt cpants kwalitee diff irc mailto metadata placeholders metacpan
145              
146             =head1 SUPPORT
147              
148             =head2 Bugs / Feature Requests
149              
150             Please report any bugs or feature requests through the issue tracker
151             at L<https://github.com/dagolden/Dist-Zilla-Plugin-Prereqs-AuthorDeps/issues>.
152             You will be notified automatically of any progress on your issue.
153              
154             =head2 Source Code
155              
156             This is open source software. The code repository is available for
157             public review and contribution under the terms of the license.
158              
159             L<https://github.com/dagolden/Dist-Zilla-Plugin-Prereqs-AuthorDeps>
160              
161             git clone https://github.com/dagolden/Dist-Zilla-Plugin-Prereqs-AuthorDeps.git
162              
163             =head1 AUTHOR
164              
165             David Golden <dagolden@cpan.org>
166              
167             =head1 CONTRIBUTOR
168              
169             =for stopwords Karen Etheridge
170              
171             Karen Etheridge <ether@cpan.org>
172              
173             =head1 COPYRIGHT AND LICENSE
174              
175             This software is Copyright (c) 2013 by David Golden.
176              
177             This is free software, licensed under:
178              
179             The Apache License, Version 2.0, January 2004
180              
181             =cut