We need a VERSION, tidy up Pod some
[catagits/CatalystX-HelpText.git] / lib / CatalystX / HelpText / Script / SearchUndocumentedHelpText.pm
CommitLineData
eb8ff5ad 1package CatalystX::HelpText::Script::SearchUndocumentedHelpText;
2use Moose;
3use Moose::Autobox;
4use MooseX::Types::Path::Class qw/ Dir /;
5use MooseX::Types::Moose qw/Str Undef/;
6use File::Find;
7use Data::Dumper;
8use Getopt::Long::Descriptive; # Force GLD as we override bits..
9use namespace::autoclean;
10
11has help_files_path => (
12 is => 'ro',
13 isa => Dir,
14 coerce => 1,
15 required => 1,
16 handles => {
17 _get_file => 'file',
18 }
19);
20
21has template_search_dir => (
22 is => 'ro',
23 isa => Str,
24 default => './',
25);
26
27has filename_pattern => (
28 is => 'ro',
29 isa => Str,
30 default => '\.(html|tt)$',
31);
32
33has help_files_ext => (
34 is => 'ro',
35 isa => Str|Undef,
36 default => 'html',
37);
38
39sub run {
40 my ($self) = @_;
41 my $filename_pattern = $self->filename_pattern;
42 my %helpkeys = ();
43 find(
44 {
45 wanted => sub {
46 my $filename = $File::Find::name;
47 return unless -f $filename;
48 return unless $filename =~ /$filename_pattern/;
49
50 #warn $filename;
51 open(FILE, $filename) or warn "Can't open $filename\n" && return;
52 while (<FILE>) {
53 if (my ($key) = m/help_text\('(.*)'\)/o) {
54 $helpkeys{$key} = 1;
55 }
56 }
57 close(FILE);
58 },
59 bydepth => 1
60 }, $self->template_search_dir->flatten);
61
62 my @notfound = ();
63 foreach (keys %helpkeys) {
64 my $file = $self->_get_file($_);
65 $file .= "." . $self->help_files_ext if defined($self->help_files_ext);
66 push (@notfound, $file) unless (-e $file);
67 }
68 print "\nMissing Help Text files:\n" if (scalar @notfound);
69 print " - $_\n" for (@notfound);
70}
71
72with qw/
73 MooseX::Getopt
74/;
75
76__PACKAGE__->meta->make_immutable;
77__PACKAGE__->new_with_options->run unless caller;
78
791;