12 open(my $fh, '<', shift);
13 if(my $whole_file = <$fh>) {
20 sub extract_synopsis {
21 my $string = shift || return;
22 my $head_or_cut = qr[head|cut]x;
23 if($string=~m/^=head1 SYNOPSIS\n(.*?)^=$head_or_cut/sm) {
30 sub normalize_indent {
31 my $extracted = shift || return;
33 if($extracted=~m/([ \t]+)(\S+)/) {
34 $extracted=~s/^$1//gsm;
41 sub create_test_string {
42 my $extracted = shift || return;
45 use warnings FATAL => 'all';
46 use Test::More qw(no_plan);
51 sub create_test_path_from_lib {
52 my $module_name = shift;
53 $module_name =~s/\.pm$//;
54 return File::Spec->catfile($Bin, '..', 't', 'synopsis', lc($module_name).'.t');
57 sub create_or_update_test {
58 my ($string, $target) = @_;
59 return unless $string && $target;
60 print "Writing $target\n";
61 open my $syn_test, '>', $target
62 or die "Couldn't open $target - you screwed something up. Go fix it.\n";
63 print $syn_test $string;
67 return unless $_=~/pm$/;
72 slurp_file $File::Find::name;
74 create_or_update_test(
76 create_test_path_from_lib($_),
78 }, File::Spec->catfile($Bin, '..', 'lib'));