12 open(my $fh, '<', shift) || return;
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) {
25 $extracted=~s/^\S.+?$//m; # wipe out non code lines in pod
26 my $begin_end = qr[begin|end]x;
27 $extracted=~s/\n^=$begin_end testinfo\n\n//smg; # remove test block
35 sub normalize_indent {
36 my $extracted = shift || return;
37 if($extracted=~m/([ \t]+)(\S+)/) {
38 $extracted=~s/^$1//gsm;
45 sub create_test_string {
46 my $extracted = shift || return;
49 use warnings FATAL => 'all';
50 use Test::More qw(no_plan);
55 sub create_test_path_from_lib {
56 my $module_name = shift;
57 $module_name =~s/\.pm$//;
58 return File::Spec->catfile($Bin, '..', 't', 'synopsis', lc($module_name).'.t');
61 sub create_or_update_test_file {
62 my ($target, $synopsis_string) = @_;
63 return unless $synopsis_string && $target;
64 print "Writing $target\n";
65 open my $syn_test, '>', $target
66 or die "Couldn't open $target - you screwed something up. Go fix it.\n";
67 print $syn_test $synopsis_string;
72 create_test_path_from_lib $_;
77 slurp_file $File::Find::name;
78 create_or_update_test_file
83 find(\&wanted, File::Spec->catfile($Bin, '..', 'lib'));