File Coverage

blib/lib/Dist/Zilla/Plugin/CheckMetaResources.pm
Criterion Covered Total %
statement 31 31 100.0
branch 4 4 100.0
condition n/a
subroutine 8 8 100.0
pod 0 1 0.0
total 43 44 97.7


line stmt bran cond sub pod time code
1 1     1   1204744 use 5.008001;
  1         3  
  1         35  
2 1     1   5 use strict;
  1         1  
  1         29  
3 1     1   4 use warnings;
  1         1  
  1         59  
4              
5             package Dist::Zilla::Plugin::CheckMetaResources;
6             # ABSTRACT: Ensure META includes resources
7             our $VERSION = '0.001'; # VERSION
8              
9             # Dependencies
10 1     1   4 use Dist::Zilla 4 ();
  1         18  
  1         18  
11 1     1   4 use autodie 2.00;
  1         17  
  1         7  
12 1     1   3617 use Moose 0.99;
  1         20  
  1         10  
13 1     1   5400 use namespace::autoclean 0.09;
  1         19  
  1         7  
14              
15             # extends, roles, attributes, etc.
16              
17             has [qw/repository bugtracker/] => (
18             is => 'ro',
19             isa => 'Bool',
20             default => 1,
21             );
22              
23             has homepage => (
24             is => 'ro',
25             isa => 'Bool',
26             default => 0,
27             );
28              
29             with 'Dist::Zilla::Role::BeforeRelease';
30              
31             # methods
32              
33             sub before_release {
34 5     5 0 632581 my $self = shift;
35 5         413 my $dm = $self->zilla->distmeta;
36              
37 5         305 $self->log("Checking META resources");
38              
39 5         2451 my @keys = qw/repository bugtracker homepage/;
40 5 100       19 my @errors = grep { $self->$_ && ! exists $dm->{resources}{$_} } @keys;
  15         684  
41              
42 5 100       20 if ( ! @errors ) {
43 3         16 $self->log("META resources OK");
44             }
45             else {
46 2         15 $self->log_fatal("META resources not specified: @errors");
47             }
48              
49 3         749 return;
50             }
51              
52             __PACKAGE__->meta->make_immutable;
53              
54             1;
55              
56              
57             # vim: ts=2 sts=2 sw=2 et:
58              
59             __END__
60             =pod
61              
62             =head1 NAME
63              
64             Dist::Zilla::Plugin::CheckMetaResources - Ensure META includes resources
65              
66             =head1 VERSION
67              
68             version 0.001
69              
70             =head1 SYNOPSIS
71              
72             # in dist.ini
73              
74             [CheckMetaResources]
75              
76             =head1 DESCRIPTION
77              
78             This is a "before release" L<Dist::Zilla> plugin that ensures that your META file
79             will contain some "resources" data.
80              
81             By default, it requires you to have at least 'repository' and 'bugtracker'
82             sections, but 'homepage' is optional.
83              
84             You can toggle any of these checks on or off. For example:
85              
86             [CheckMetaResources]
87             repository = 1
88             bugtracker = 0
89             homepage = 1
90              
91             =for Pod::Coverage before_release
92              
93             =head1 SEE ALSO
94              
95             =over 4
96              
97             =item *
98              
99             L<Dist::Zilla>
100              
101             =item *
102              
103             L<Dist::Zilla::Plugin::MetaResources>
104              
105             =item *
106              
107             L<Dist::Zilla::Plugin::GithubMetas>
108              
109             =item *
110              
111             L<Dist::Zilla::Plugin::AutoMetaResources>
112              
113             =item *
114              
115             ... and plenty more (search metacpan.org for "dist zilla plugin meta")
116              
117             =back
118              
119             =for :stopwords cpan testmatrix url annocpan anno bugtracker rt cpants kwalitee diff irc mailto metadata placeholders metacpan
120              
121             =head1 SUPPORT
122              
123             =head2 Bugs / Feature Requests
124              
125             Please report any bugs or feature requests through the issue tracker
126             at L<http://rt.cpan.org/Public/Dist/Display.html?Name=Dist-Zilla-Plugin-CheckMetaResources>.
127             You will be notified automatically of any progress on your issue.
128              
129             =head2 Source Code
130              
131             This is open source software. The code repository is available for
132             public review and contribution under the terms of the license.
133              
134             L<https://github.com/dagolden/dist-zilla-plugin-checkmetaresources>
135              
136             git clone https://github.com/dagolden/dist-zilla-plugin-checkmetaresources.git
137              
138             =head1 AUTHOR
139              
140             David Golden <dagolden@cpan.org>
141              
142             =head1 COPYRIGHT AND LICENSE
143              
144             This software is Copyright (c) 2012 by David Golden.
145              
146             This is free software, licensed under:
147              
148             The Apache License, Version 2.0, January 2004
149              
150             =cut
151