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