File Coverage

blib/lib/Test/NoSmartComments.pm
Criterion Covered Total %
statement 30 30 100.0
branch 1 2 50.0
condition n/a
subroutine 9 9 100.0
pod 2 2 100.0
total 42 43 97.6


line stmt bran cond sub pod time code
1             #
2             # This file is part of Test-NoSmartComments
3             #
4             # This software is Copyright (c) 2011 by Chris Weyl.
5             #
6             # This is free software, licensed under:
7             #
8             # The GNU Lesser General Public License, Version 2.1, February 1999
9             #
10             package Test::NoSmartComments;
11             BEGIN {
12 2     2   56936 $Test::NoSmartComments::AUTHORITY = 'cpan:RSRCHBOY';
13             }
14             BEGIN {
15 2     2   34 $Test::NoSmartComments::VERSION = '0.004';
16             }
17              
18             # ABSTRACT: Make sure no Smart::Comments escape into the wild
19              
20 2     2   17 use strict;
  2         3  
  2         71  
21 2     2   11 use warnings;
  2         3  
  2         83  
22              
23 2     2   13 use base 'Test::Builder::Module';
  2         6  
  2         262  
24              
25             my $CLASS = __PACKAGE__;
26              
27 2     2   2091 use Module::ScanDeps;
  2         119454  
  2         215  
28 2     2   2561 use ExtUtils::Manifest qw( maniread );
  2         17565  
  2         663  
29              
30             our @EXPORT = qw{ no_smart_comments_in no_smart_comments_in_all };
31              
32              
33             sub no_smart_comments_in_all {
34 1     1 1 1150 my $tb = $CLASS->builder;
35 1         17 my $manifest = maniread();
36 1         154 my @files = sort grep { m!^lib/.*\.pm$! } keys %$manifest;
  2         16  
37 1         3 local $Test::Builder::Level = $Test::Builder::Level + 1;
38 1         5 no_smart_comments_in($_) for @files;
39              
40 1         8 return;
41             }
42              
43             sub no_smart_comments_in {
44 4     4 1 1282 my $file = shift @_;
45 4         39 my $tb = $CLASS->builder;
46             #my $tb = __PACKAGE__->builder;
47              
48 4 50       140 $tb->diag("No such file: $file") unless -f $file;
49              
50 4         24 my $dep = scan_deps(files => [ $file ], recurse => 0);
51 4         30624 $tb->ok(!exists $dep->{'Smart/Comments.pm'}, "$file w/o Smart::Comments");
52 4         2528 return;
53             }
54              
55             1;
56              
57              
58              
59             =pod
60              
61             =head1 NAME
62              
63             Test::NoSmartComments - Make sure no Smart::Comments escape into the wild
64              
65             =head1 VERSION
66              
67             version 0.004
68              
69             =head1 SYNOPSIS
70              
71             use Test::More;
72             eval "use Test::NoSmartComments";
73             plan skip_all => 'Test::NoSmartComments required for checking comment IQ'
74             if $@ ;
75              
76             no_smart_comments_in;
77             done_testing;
78              
79             =head1 DESCRIPTION
80              
81             Ls are great. However, letting smart comments escape into the
82             wilds of the CPAN is just dumb.
83              
84             This package provides a simple way to test for smart comments _before_ they
85             get away!
86              
87             =head1 FUNCTIONS
88              
89             =head2 no_smart_comments_in($file)
90              
91             Called with a file name, this function scans it for the use of
92             L.
93              
94             =head2 no_smart_comments_in_all()
95              
96             no_smart_comments_in_all() scans the MANIFEST for all matching qr!^lib/.*.pm$!
97             and issues a pass or fail for each.
98              
99             =head1 SEE ALSO
100              
101             L, L
102              
103             =head1 AUTHOR
104              
105             Chris Weyl
106              
107             =head1 COPYRIGHT AND LICENSE
108              
109             This software is Copyright (c) 2011 by Chris Weyl.
110              
111             This is free software, licensed under:
112              
113             The GNU Lesser General Public License, Version 2.1, February 1999
114              
115             =cut
116              
117              
118             __END__