File Coverage

blib/lib/Dist/Zilla/Plugin/Prereqs/AuthorDeps.pm
Criterion Covered Total %
statement 42 42 100.0
branch 2 2 100.0
condition n/a
subroutine 12 12 100.0
pod 0 2 0.0
total 56 58 96.5


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