Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Various fixes suggested by Pod::Coverage and Perl::Critic
  • Loading branch information
hinrik committed Jul 1, 2009
1 parent 5a0d6ae commit bb28e42
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
17 changes: 14 additions & 3 deletions lib/App/Grok.pm
Expand Up @@ -49,6 +49,8 @@ sub run {
my $output = $self->render_file($target, $opt{format});
$self->_print($output);
}

return;
}

sub _get_options {
Expand All @@ -68,6 +70,8 @@ sub _get_options {
warn "Too few arguments\n";
pod2usage();
}

return;
}

sub target_index {
Expand All @@ -90,7 +94,7 @@ sub detect_source {
my ($self, $file) = @_;

open my $handle, '<', $file or die "Can't open $file";
my $contents = do { local $/; scalar <$handle> };
my $contents = do { local $/ = undef; scalar <$handle> };
close $handle;

my ($first_pod) = $contents =~ /(^=(?!encoding)\S+)/m;
Expand All @@ -109,7 +113,7 @@ sub find_target {
my ($self, $arg) = @_;

my $target = $self->find_synopsis($arg);
$target = $self->find_file($arg) if !defined $target;
$target = $self->find_module_or_program($arg) if !defined $target;

return if !defined $target;
return $target;
Expand Down Expand Up @@ -139,7 +143,7 @@ sub find_synopsis {
return;
}

sub find_file {
sub find_module_or_program {
my ($self, $file) = @_;

# TODO: do a grand search
Expand Down Expand Up @@ -173,6 +177,8 @@ sub _print {
: system $pager . qq{ '$temp'}
;
}

return;
}

1;
Expand Down Expand Up @@ -221,6 +227,11 @@ Takes the name (or a substring of a name) of a Synopsis as an argument.
Returns a path to a matching file if one is found, otherwise returns nothing.
Note: this method is called by L<C<find_target>|/find_target>.
=head2 C<find_module_or_program>
Takes the name of a module or a program. Returns a path to a matching file
if one is found, otherwise returns nothing.
=head2 C<render_file>
Takes two arguments, a filename and the name of an output format. Returns
Expand Down
1 change: 1 addition & 0 deletions lib/App/Grok/Pod5.pm
Expand Up @@ -29,6 +29,7 @@ sub render {
open my $out_fh, '>', \$pod or die "Can't open output filehandle: $!";
binmode $out_fh, ':utf8';
$formatter->new->parse_from_file($file, $out_fh);
close $out_fh;
return $pod;
}

Expand Down
3 changes: 3 additions & 0 deletions script/grok
@@ -1,6 +1,9 @@
#!/usr/bin/env perl

package grok;
use strict;
use warnings;

use App::Grok;
my $grok = App::Grok->new();
$grok->run();
Expand Down

0 comments on commit bb28e42

Please sign in to comment.