File Coverage

blib/lib/Dist/Zilla/Plugin/Test/CPAN/Meta/JSON.pm
Criterion Covered Total %
statement 26 26 100.0
branch 4 4 100.0
condition n/a
subroutine 6 6 100.0
pod 0 2 0.0
total 36 38 94.7


line stmt bran cond sub pod time code
1             package Dist::Zilla::Plugin::Test::CPAN::Meta::JSON;
2 1     1   510279 use strict;
  1         6  
  1         29  
3 1     1   4 use warnings;
  1         1  
  1         41  
4             # ABSTRACT: release tests for your META.json
5             our $VERSION = '0.004'; # VERSION
6              
7 1     1   3 use Moose;
  1         1318  
  1         8  
8             extends 'Dist::Zilla::Plugin::InlineFiles';
9             with 'Dist::Zilla::Role::FilePruner';
10             with 'Dist::Zilla::Role::PrereqSource';
11              
12              
13             sub prune_files {
14 2     2 0 44381 my $self = shift;
15              
16             # Bail if we find META.json
17 2         4 my $METAjson = 'META.json';
18 2         3 foreach my $file (@{ $self->zilla->files }) {
  2         49  
19 4 100       102 return if $file->name eq $METAjson;
20             }
21              
22             # If META.json wasn't found, then prune out the test
23 1         26 my $test_filename = 'xt/release/meta-json.t';
24 1         1 foreach my $file (@{ $self->zilla->files }) {
  1         21  
25 2 100       48 next unless $file->name eq $test_filename;
26              
27 1         43 $self->zilla->prune_file($file);
28 1         55 $self->log_debug([ '%s not found; pruning %s', $METAjson, $file->name ]);
29             }
30 1         103 return;
31             }
32              
33             # Register the release test prereq as a "develop requires"
34             # so it will be listed in "dzil listdeps --author"
35             sub register_prereqs {
36 2     2 0 1437 my ($self) = @_;
37              
38 2         47 $self->zilla->register_prereqs(
39             {
40             type => 'requires',
41             phase => 'develop',
42             },
43             'Test::CPAN::Meta::JSON' => '0.16',
44             );
45             }
46              
47              
48             __PACKAGE__->meta->make_immutable;
49 1     1   3979 no Moose;
  1         1  
  1         3  
50              
51             1;
52              
53             =pod
54              
55             =encoding UTF-8
56              
57             =head1 NAME
58              
59             Dist::Zilla::Plugin::Test::CPAN::Meta::JSON - release tests for your META.json
60              
61             =head1 VERSION
62              
63             version 0.004
64              
65             =head1 SYNOPSIS
66              
67             In C<dist.ini>:
68              
69             [Test::CPAN::Meta::JSON]
70              
71             =head1 DESCRIPTION
72              
73             This is an extension of L<Dist::Zilla::Plugin::InlineFiles>, providing the
74             following file if F<META.json> is in your dist:
75              
76             xt/release/meta-json.t - a standard Test::CPAN::Meta::JSON test
77              
78             See L<Test::CPAN::Meta::JSON> for what this test does.
79              
80             =for Pod::Coverage prune_files register_prereqs
81              
82             =for test_synopsis 1;
83             __END__
84              
85             =head1 AVAILABILITY
86              
87             The project homepage is L<http://p3rl.org/Dist::Zilla::Plugin::Test::CPAN::Meta::JSON>.
88              
89             The latest version of this module is available from the Comprehensive Perl
90             Archive Network (CPAN). Visit L<http://www.perl.com/CPAN/> to find a CPAN
91             site near you, or see L<https://metacpan.org/module/Dist::Zilla::Plugin::Test::CPAN::Meta::JSON/>.
92              
93             =head1 SOURCE
94              
95             The development version is on github at L<http://github.com/doherty/Dist-Zilla-Plugin-Test-CPAN-Meta-JSON>
96             and may be cloned from L<git://github.com/doherty/Dist-Zilla-Plugin-Test-CPAN-Meta-JSON.git>
97              
98             =head1 BUGS AND LIMITATIONS
99              
100             You can make new bug reports, and view existing ones, through the
101             web interface at L<https://github.com/doherty/Dist-Zilla-Plugin-Test-CPAN-Meta-JSON/issues>.
102              
103             =head1 AUTHOR
104              
105             Mike Doherty <doherty@cpan.org>
106              
107             =head1 COPYRIGHT AND LICENSE
108              
109             This software is copyright (c) 2011 by Mike Doherty.
110              
111             This is free software; you can redistribute it and/or modify it under
112             the same terms as the Perl 5 programming language system itself.
113              
114             =cut
115              
116             __DATA__
117             __[ xt/release/meta-json.t ]__
118             #!perl
119              
120             use Test::CPAN::Meta::JSON;
121             meta_json_ok();