Permalink
Browse files

Fix synopsis name parsing a bit.

It was acceptin 's02' but not 's02-bits'.
  • Loading branch information...
hinrik committed Jul 5, 2009
1 parent e4a2902 commit af59b19c82f04e3b57eac63f24b7f97ab2497bce
Showing with 14 additions and 9 deletions.
  1. +3 −0 Changes
  2. +8 −8 lib/App/Grok.pm
  3. +3 −1 t/04_targets/02_synopsis.t
View
@@ -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)
View
@@ -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;
@@ -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;
}
@@ -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.