Skip to content

Commit

Permalink
Rewrite t/synopsis.t to work without Pod::Eventual::Simple
Browse files Browse the repository at this point in the history
Simplify the pod parser to remove the dependency.
We control what we're parsing so simple should be sufficient.
  • Loading branch information
rwstauner committed Nov 14, 2011
1 parent 4230416 commit 228f152
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
2 changes: 2 additions & 0 deletions Changes
Expand Up @@ -2,6 +2,8 @@ Revision history for DBIx::RoboQuery

{{$NEXT}}

- Rewrite t/synopsis.t to work without Pod::Eventual::Simple

0.016 2011-10-28T03:27:23Z

- Fix heredoc in Synopis POD (and fix synopsis tests)
Expand Down
33 changes: 18 additions & 15 deletions t/synopsis.t
Expand Up @@ -7,8 +7,8 @@ use DBIx::RoboQuery;
# try to keep things a little organized... script near the top, helper subs at the bottom

# don't make these prereqs for the distribution, but we need them for this author test
my ($dbd, $pod_parser) = qw(SQLite Pod::Eventual::Simple);
foreach my $req ( 'DBI', "DBD::$dbd", $pod_parser ){
my $dbd = 'SQLite';
foreach my $req ( 'DBI', "DBD::$dbd" ){
eval "require $req";
plan skip_all => "$req required for this test"
if $@;
Expand Down Expand Up @@ -74,24 +74,27 @@ sub arbitrary_date_function { '2000-01-01' }

# use actual SYNOPSIS
sub get_synopsis_pod {
my $pod = '';
my @paras = @{Pod::Eventual::Simple->read_file($INC{'DBIx/RoboQuery.pm'})};
my $pm = $INC{'DBIx/RoboQuery.pm'};

open my $fh, '<', $pm
or die "Failed to open '$pm': $!";

# incredibly basic pod parser
my $in_synopsis = 0;
foreach my $para (@paras){
if( $para->{type} eq 'command' ){
#print STDERR Dumper($para);
if( $para->{command} eq 'head1' && $para->{content} =~ /SYNOPSIS/ ){
$in_synopsis = 1;
}
# the next command after =head1 SYNOPSIS ends the synopsis
elsif( $in_synopsis && $para->{command} ){
last;
}
my $pod = '';
while( <$fh> ){
# specifically ignore the =for test_synopsis b/c we've already defined my $dbh
if( /^=head1 SYNOPSIS/ ){
$in_synopsis = 1;
}
elsif( $in_synopsis && /^=\w+/ ){
last;
}
elsif( $in_synopsis ){
$pod .= $para->{content};
$pod .= $_;
}
}

$pod =~ s/^ //mg;
return $pod;
}

0 comments on commit 228f152

Please sign in to comment.