Skip to content

Commit

Permalink
Fix synopsis name parsing a bit.
Browse files Browse the repository at this point in the history
It was acceptin 's02' but not 's02-bits'.
  • Loading branch information
hinrik committed Jul 5, 2009
1 parent e4a2902 commit af59b19
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
3 changes: 3 additions & 0 deletions Changes
@@ -1,3 +1,6 @@
0.11
- Fix bug which was causing it to only accept 's02' but not 's02-bits'

0.10 Thu Jul 2 16:49:16 GMT 2009
- Add 'pod' output format for Pod 5, and u-/--unformatted
- Rename -f/--format to -o/--output like perldoc(1)
Expand Down
16 changes: 8 additions & 8 deletions lib/App/Grok.pm
Expand Up @@ -190,14 +190,7 @@ sub find_synopsis {
my ($self, $syn) = @_;
my $dir = catdir($self->{share_dir}, 'Spec');

if ($syn =~ /^S\d+$/i) {
my @synopses = map { (splitpath($_))[2] } glob "$dir/*.pod";
my $found = first { /$syn/i } @synopses;

return if !defined $found;
return catfile($dir, $found);
}
elsif (my ($section) = $syn =~ /^S32-(\S+)$/i) {
if (my ($section) = $syn =~ /^S32-(\S+)$/i) {
my $S32_dir = catdir($dir, 'S32-setting-library');
my @sections = map { (splitpath($_))[2] } glob "$S32_dir/*.pod";
my $found = first { /$section/i } @sections;
Expand All @@ -206,6 +199,13 @@ sub find_synopsis {
return catfile($S32_dir, $found);
}
}
elsif ($syn =~ /^S\d+/i) {
my @synopses = map { (splitpath($_))[2] } glob "$dir/*.pod";
my $found = first { /\Q$syn/i } @synopses;

return if !defined $found;
return catfile($dir, $found);
}

return;
}
Expand Down
4 changes: 3 additions & 1 deletion t/04_targets/02_synopsis.t
@@ -1,15 +1,17 @@
use strict;
use warnings;
use File::Spec::Functions 'catfile';
use Test::More tests => 3;
use Test::More tests => 4;

$ENV{GROK_SHAREDIR} = 'share';
my $grok = catfile('script', 'grok');

my $s02 = qx/$^X $grok s02/;
my $s04 = qx/$^X $grok s04-control/;
my $s26 = qx/$^X $grok s26/;
my $s32_except = qx/$^X $grok s32-except/;

like($s02, qr/Synopsis 2/, "Got S02");
like($s04, qr/Synopsis 4/, "Got S04");
like($s26, qr/Synopsis 26/, "Got S26");
like($s32_except, qr/Synopsis 32: Setting Library - Exception/, "Got S32-exception");

0 comments on commit af59b19

Please sign in to comment.