File Coverage

blib/lib/Test/DBICSchemaLoaderDigest.pm
Criterion Covered Total %
statement 30 30 100.0
branch 4 4 100.0
condition n/a
subroutine 7 7 100.0
pod 1 1 100.0
total 42 42 100.0


line stmt bran cond sub pod time code
1             #
2             # This file is part of Test-DBICSchemaLoaderDigest
3             #
4             # This software is copyright (c) 2012 by Tokuhiro Matsuno Etokuhirom@gmail.comE.
5             #
6             # This is free software; you can redistribute it and/or modify it under
7             # the same terms as the Perl 5 programming language system itself.
8             #
9             package Test::DBICSchemaLoaderDigest;
10             {
11             $Test::DBICSchemaLoaderDigest::VERSION = '0.04';
12             }
13 5     5   146367 use strict;
  5         17  
  5         186  
14 5     5   26 use warnings;
  5         10  
  5         137  
15 5     5   119 use 5.00800;
  5         18  
  5         178  
16 5     5   27 use base qw/Exporter/;
  5         14  
  5         869  
17 5     5   34 use Test::More;
  5         9  
  5         29  
18 5     5   1448 use Digest::MD5 ();
  5         10  
  5         2053  
19             our @EXPORT = qw/test_dbic_schema_loader_digest/;
20              
21             our $MARK_RE = qr{^(# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:)([A-Za-z0-9/+]{22})\n};
22              
23             sub test_dbic_schema_loader_digest {
24 4     4 1 65 my $fname = shift;
25              
26 4 100       265 open my $fh, '<', $fname or die "$fname $!";
27              
28 3         11 my $buf = '';
29 3         123 while ( my $line = <$fh> ) {
30 31 100       130 if ( $line =~ $MARK_RE ) {
31 2         11 $buf .= $1;
32 2         34 is Digest::MD5::md5_base64( $buf ), $2, "$fname is valid";
33 2         1703 close $fh;
34 2         13 return;
35             }
36             else {
37 29         109 $buf .= $line;
38             }
39             }
40 1         11 close $fh;
41              
42 1         7 ok undef, "md5sum not found: $fname";
43             }
44              
45             # ABSTRACT: test the DBIC::Schema::Loader's MD5 sum
46              
47             1;
48              
49              
50             =pod
51              
52             =for :stopwords Tokuhiro Matsuno Etokuhirom@gmail.comE Chris Weyl
53             AAAAHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
54              
55             =head1 NAME
56              
57             Test::DBICSchemaLoaderDigest - test the DBIC::Schema::Loader's MD5 sum
58              
59             =head1 VERSION
60              
61             This document describes version 0.04 of Test::DBICSchemaLoaderDigest - released June 30, 2012 as part of Test-DBICSchemaLoaderDigest.
62              
63             =head1 SYNOPSIS
64              
65             use Test::More tests => 1;
66             use Test::DBICSchemaLoaderDigest;
67             test_dbic_schema_loader_digest('lib/Proj/Schema/Foo.pm');
68              
69             =head1 DESCRIPTION
70              
71             Hey DBIC::Schema::Loader dumps follow code:
72              
73             # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:2lkIltTa9Ey3fExXmUB/gw
74              
75             But, some programmer MODIFY THE ABOVE OF
76             THIS CODE!!!!!!!!!! AAAAHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH!!!
77              
78             This module tests for manual changes to the forbidden zone. If you use this
79             test, you can stop this problem before it becomes a real problem.
80              
81             =encoding utf8
82              
83             =head1 METHODS
84              
85             =head2 test_dbic_schema_loader_digest('lib/Proj/Schema/Foo.pm')
86              
87             Check the MD5 sum.
88              
89             =head1 CODE COVERAGE
90              
91             ---------------------------- ------ ------ ------ ------ ------ ------ ------
92             File stmt bran cond sub pod time total
93             ---------------------------- ------ ------ ------ ------ ------ ------ ------
94             ...DBICSchemaLoaderDigest.pm 100.0 100.0 n/a 100.0 100.0 100.0 100.0
95             Total 100.0 100.0 n/a 100.0 100.0 100.0 100.0
96             ---------------------------- ------ ------ ------ ------ ------ ------ ------
97              
98             =head1 SEE ALSO
99              
100             Please see those modules/websites for more information related to this module.
101              
102             =over 4
103              
104             =item *
105              
106             L
107              
108             =back
109              
110             =head1 SOURCE
111              
112             The development version is on github at L
113             and may be cloned from L
114              
115             =head1 BUGS
116              
117             Please report any bugs or feature requests on the bugtracker website
118             https://github.com/RsrchBoy/test-dbicschemaloaderdigest/issues
119              
120             When submitting a bug or request, please include a test-file or a
121             patch to an existing test-file that illustrates the bug or desired
122             feature.
123              
124             =head1 AUTHORS
125              
126             =over 4
127              
128             =item *
129              
130             Tokuhiro Matsuno Etokuhirom@gmail.comE
131              
132             =item *
133              
134             Chris Weyl
135              
136             =back
137              
138             =head1 COPYRIGHT AND LICENSE
139              
140             This software is copyright (c) 2012 by Tokuhiro Matsuno Etokuhirom@gmail.comE.
141              
142             This is free software; you can redistribute it and/or modify it under
143             the same terms as the Perl 5 programming language system itself.
144              
145             =cut
146              
147              
148             __END__