File Coverage

blib/lib/Dist/Zilla/Plugin/CheckEmacsChangeLog.pm
Criterion Covered Total %
statement 7 9 77.7
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 10 12 83.3


line stmt bran cond sub pod time code
1             #-----------------------------------------------------------------
2             # Dist::Zilla::Plugin::CheckEmacsChangeLog
3             # Author: Martin Senger <martin.senger@gmail.com>
4             # For copyright and disclaimer se below.
5             #
6             # ABSTRACT: Check missing version in ChangeLog
7             # PODNAME: Dist::Zilla::Plugin::CheckEmacsChangeLog
8             #-----------------------------------------------------------------
9 1     1   23726 use strict;
  1         3  
  1         34  
10 1     1   4 use warnings;
  1         2  
  1         64  
11             package Dist::Zilla::Plugin::CheckEmacsChangeLog;
12             our $VERSION = '0.0.2'; # VERSION
13              
14 1     1   443 use Moose;
  0            
  0            
15             extends 'Dist::Zilla::Plugin::CheckChangeLog';
16              
17             has filename => (
18             is => 'ro',
19             isa => 'Str',
20             default => 'ChangeLog',
21             );
22              
23             sub check_file_for_version {
24             my ( $self, $content, $version ) = @_;
25              
26             $SIG{__DIE__} = sub {
27             my $msg = shift;
28             $msg =~ s{CheckChangeLog}{CheckEmacsChangeLog}g;
29             die $msg;
30             };
31              
32             use Tie::STDOUT
33             print => sub {
34             print map { my $m = $_; $m =~ s{CheckChangeLog}{CheckEmacsChangeLog}g; $m } @_;
35             };
36              
37             my @lines = split( /\n/, $content );
38             foreach (@lines) {
39              
40             # no blanket lines
41             next unless /\S/;
42              
43             # seen it?
44             return 1 if /\Q$version\E/;
45             }
46             return 0;
47             }
48              
49             1;
50              
51              
52             =pod
53              
54             =head1 NAME
55              
56             Dist::Zilla::Plugin::CheckEmacsChangeLog - Check missing version in ChangeLog
57              
58             =head1 VERSION
59              
60             version 0.0.2
61              
62             =head1 SYNOPSIS
63              
64             # dist.ini
65             [CheckEmacsChangeLog]
66              
67             # or
68             [CheckEmacsChangeLog]
69             filename = another.file.name
70              
71             =head1 DESCRIPTION
72              
73             It is a simple extension of L<Dist::Zilla::Plugin::CheckChangeLog>
74             allowing to check that a sentence about a new version was added to a
75             file C<ChangeLog> in your project. It differs from the
76             L<Dist::Zilla::Plugin::CheckChangeLog> by expecting the format of the
77             C<ChangeLog> file being the one used by the Emacs's ChangeLog
78             mode. Which means, for example, this one:
79              
80             2012-03-03 Martin Senger <martin.senger&#64;gmail.com>
81             * Version 0.0.1 released
82              
83             =head1 ATTRIBUTES
84              
85             There is one optional attribute C<filename> allowing to change the
86             file name with the logs:
87              
88             [CheckEmacsChangeLog]
89             filename = another.file.name
90              
91             The main reason for having this attribute is that it has a default
92             value C<ChangeLog> (suitable for Emacs) which is different from the
93             one used in the original L<Dist::Zilla::Plugin::CheckChangeLog>.
94              
95             =head1 AUTHOR
96              
97             Martin Senger <martin.senger@gmail.com>
98              
99             =head1 COPYRIGHT AND LICENSE
100              
101             This software is copyright (c) 2013 by Martin Senger, CBRC-KAUST (Computational Biology Research Center; King Abdullah University of Science and Technology) All Rights Reserved..
102              
103             This is free software; you can redistribute it and/or modify it under
104             the same terms as the Perl 5 programming language system itself.
105              
106             =cut
107              
108              
109             __END__
110