File Coverage

blib/lib/Dist/Zilla/Plugin/Test/CPAN/Changes.pm
Criterion Covered Total %
statement 29 29 100.0
branch 1 2 50.0
condition n/a
subroutine 7 7 100.0
pod 0 2 0.0
total 37 40 92.5


line stmt bran cond sub pod time code
1             package Dist::Zilla::Plugin::Test::CPAN::Changes;
2 1     1   1992956 use strict;
  1         2  
  1         35  
3 1     1   4 use warnings;
  1         2  
  1         48  
4             # ABSTRACT: release tests for your changelog
5             our $VERSION = '0.011'; # VERSION
6              
7 1     1   3 use Moose;
  1         2  
  1         7  
8 1     1   4721 use Data::Section -setup;
  1         2  
  1         12  
9             with
10             'Dist::Zilla::Role::FileGatherer',
11             'Dist::Zilla::Role::PrereqSource';
12              
13              
14             has changelog => (
15             is => 'ro',
16             isa => 'Str',
17             predicate => 'has_changelog',
18             default => 'Changes',
19             );
20              
21             around dump_config => sub
22             {
23             my ($orig, $self) = @_;
24             my $config = $self->$orig;
25              
26             $config->{+__PACKAGE__} = {
27             $self->has_changelog ? ( changelog => $self->Changes ) : (),
28             blessed($self) ne __PACKAGE__
29             ? ( version => (defined __PACKAGE__->VERSION ? __PACKAGE__->VERSION : 'dev') )
30             : (),
31             };
32             return $config;
33             };
34              
35              
36             sub gather_files {
37 2     2 0 55135 my $self = shift;
38              
39 2         589 require Dist::Zilla::File::InMemory;
40              
41 2         66270 for my $file (qw( xt/release/cpan-changes.t )){
42 2         4 my $content = ${$self->section_data($file)};
  2         13  
43              
44 2         684 my $changes_filename = $self->changelog;
45              
46 2         11 $content =~ s/CHANGESFILENAME/$changes_filename/;
47 2         12 $content =~ s/PLUGIN/ref($self)/e;
  2         8  
48 2 50       9 $content =~ s/VERSION/$self->VERSION || '<self>'/e;
  2         28  
49              
50 2         56 $self->add_file( Dist::Zilla::File::InMemory->new(
51             name => $file,
52             content => $content,
53             ));
54             }
55             }
56              
57             # Register the release test prereq as a "develop requires"
58             # so it will be listed in "dzil listdeps --author"
59             sub register_prereqs {
60 2     2 0 4439 my ($self) = @_;
61              
62 2         65 $self->zilla->register_prereqs(
63             {
64             type => 'requires',
65             phase => 'develop',
66             },
67             # Latest known release of Test::CPAN::Changes
68             # because CPAN authors must use the latest if we want
69             # this check to be relevant
70             'Test::CPAN::Changes' => '0.19',
71             );
72             }
73              
74              
75              
76              
77              
78             __PACKAGE__->meta->make_immutable;
79 1     1   750 no Moose;
  1         1  
  1         6  
80              
81             =pod
82              
83             =encoding UTF-8
84              
85             =head1 NAME
86              
87             Dist::Zilla::Plugin::Test::CPAN::Changes - release tests for your changelog
88              
89             =head1 VERSION
90              
91             version 0.011
92              
93             =for test_synopsis BEGIN { die "SKIP: synopsis isn't perl code" }
94              
95             =head1 SYNOPSIS
96              
97             In C<dist.ini>:
98              
99             [Test::CPAN::Changes]
100              
101             =head1 DESCRIPTION
102              
103             This is an extension of L<Dist::Zilla::Plugin::InlineFiles>, providing the
104             following file:
105              
106             xt/release/cpan-changes.t - a standard Test::CPAN::Changes test
107              
108             See L<Test::CPAN::Changes> for what this test does.
109              
110             =head2 Alternate changelog filenames
111              
112             L<CPAN::Changes::Spec> specifies that the changelog will be called 'Changes' -
113             if you want to use a different filename for whatever reason, do:
114              
115             [Test::CPAN::Changes]
116             changelog = CHANGES
117              
118             and that file will be tested instead.
119              
120             =for Pod::Coverage gather_files register_prereqs
121              
122             =head1 AVAILABILITY
123              
124             The project homepage is L<http://metacpan.org/release/Dist-Zilla-Plugin-Test-CPAN-Changes/>.
125              
126             The latest version of this module is available from the Comprehensive Perl
127             Archive Network (CPAN). Visit L<http://www.perl.com/CPAN/> to find a CPAN
128             site near you, or see L<https://metacpan.org/module/Dist::Zilla::Plugin::Test::CPAN::Changes/>.
129              
130             =head1 SOURCE
131              
132             The development version is on github at L<http://github.com/doherty/Dist-Zilla-Plugin-Test-CPAN-Changes>
133             and may be cloned from L<git://github.com/doherty/Dist-Zilla-Plugin-Test-CPAN-Changes.git>
134              
135             =head1 BUGS AND LIMITATIONS
136              
137             You can make new bug reports, and view existing ones, through the
138             web interface at L<https://github.com/doherty/Dist-Zilla-Plugin-Test-CPAN-Changes/issues>.
139              
140             =head1 AUTHOR
141              
142             Mike Doherty <doherty@cpan.org>
143              
144             =head1 COPYRIGHT AND LICENSE
145              
146             This software is copyright (c) 2011 by Mike Doherty.
147              
148             This is free software; you can redistribute it and/or modify it under
149             the same terms as the Perl 5 programming language system itself.
150              
151             =cut
152              
153             __DATA__
154             __[ xt/release/cpan-changes.t ]__
155             use strict;
156             use warnings;
157              
158             # this test was generated with PLUGIN VERSION
159              
160             use Test::More 0.96 tests => 1;
161             use Test::CPAN::Changes;
162             subtest 'changes_ok' => sub {
163             changes_file_ok('CHANGESFILENAME');
164             };