11 local (@ARGV, $/) = ($_[0]); <>
14 sub extract_synopsis {
15 my $string = shift || return;
16 my $head_or_cut = qr[head|cut]x;
17 if($string=~m/^=head1 SYNOPSIS\n(.*?)^=$head_or_cut/sm) {
19 my $begin_end = qr[begin|end]x;
20 $extracted=~s/\n^=$begin_end testinfo\n\n//smg; # remove test block
21 $extracted=~s/^\S.+?$//smg; # wipe out non code lines in pod
28 sub normalize_indent {
29 my $extracted = shift || return;
30 if($extracted=~m/([ \t]+)(\S+)/) {
31 $extracted=~s/^$1//gsm;
38 sub create_test_string {
39 my $extracted = shift || return;
42 use warnings FATAL => 'all';
43 use Test::More qw(no_plan);
48 sub create_test_path_from_lib {
49 my $module_name = shift;
50 $module_name =~s/\.pm$//;
51 return File::Spec->catfile($Bin, '..', 't', 'synopsis', lc($module_name).'.t');
54 sub create_or_update_test_file {
55 my ($target, $synopsis_string) = @_;
56 return unless $synopsis_string && $target;
57 print "Writing $target\n";
58 open my $syn_test, '>', $target
59 or die "Couldn't open $target - you screwed something up. Go fix it.\n";
60 print $syn_test $synopsis_string;
65 create_test_path_from_lib $_;
70 slurp_file $File::Find::name;
71 create_or_update_test_file
76 find(\&wanted, File::Spec->catfile($Bin, '..', 'lib'));