regexp test fixed
[catagits/CatalystX-HelpText.git] / lib / CatalystX / HelpText / Finder / TemplateToolkit / Regexp.pm
CommitLineData
54b1774e 1package CatalystX::HelpText::Finder::TemplateToolkit::Regexp;
2use Moose;
54b1774e 3use List::MoreUtils qw/ uniq /;
009a8923 4use namespace::autoclean;
54b1774e 5
6sub find_helptext_keys_in_fn {
009a8923 7 my ($self, $fn) = @_;
8 open(my $FILE, '<', $fn) or warn "Can't open $fn\n" && return;
54b1774e 9 my @keys = ();
22c77d41 10 while (my $line = <$FILE>) {
9a0530a7 11 foreach my $key ($line =~ m/help_text\(\s*['"](\w+)['"]\s*\)/g) {
54b1774e 12 push @keys, $key;
13 }
14 }
009a8923 15 close($FILE);
54b1774e 16 return [ uniq @keys ];
17}
18
009a8923 19__PACKAGE__->meta->make_immutable;
20
211;
61d108e4 22
23
24=head1 NAME
25
26CatalystX::HelpText::Finder::TemplateToolkit::Regexp
27
28=head1 SYNOPSIS
29
30 Find helptext keys parsing the templates using a regular expression, it helps to find
31 helptext keys which are not called by a simple TT parsing due logical conditions
32
33=head1 SEE ALSO
34
35=over
36
37=item L<CatalystX::HelpText>
38
39=back
40
41=head1 AUTHOR
42
43Toomas Doran, C<< t0m at state51.co.uk >>
44
45Cinxgler Mariaca Minda, C<< cinxgler at ci-info.com >>
46
47=head1 COPYRIGHT
48
49Copyright Oscar Music and Media 2011.
50
51=head1 LICENSE
52
53This sofware is free software, and is licensed under the same terms as perl itself.
54
55=cut
56