regexp test fixed
[catagits/CatalystX-HelpText.git] / lib / CatalystX / HelpText / Finder / TemplateToolkit / Regexp.pm
1 package CatalystX::HelpText::Finder::TemplateToolkit::Regexp;
2 use Moose;
3 use List::MoreUtils qw/ uniq /;
4 use namespace::autoclean;
5
6 sub find_helptext_keys_in_fn {
7     my ($self, $fn) = @_;
8     open(my $FILE, '<', $fn) or warn "Can't open $fn\n" && return;
9     my @keys = ();
10     while (my $line = <$FILE>) {
11         foreach my $key ($line =~ m/help_text\(\s*['"](\w+)['"]\s*\)/g) {
12             push @keys, $key;
13         }
14     }
15     close($FILE);
16     return [ uniq @keys ];
17 }
18
19 __PACKAGE__->meta->make_immutable;
20
21 1;
22
23
24 =head1 NAME
25
26 CatalystX::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
43 Toomas Doran, C<< t0m at state51.co.uk >>
44
45 Cinxgler Mariaca Minda, C<< cinxgler at ci-info.com >>
46
47 =head1 COPYRIGHT
48
49 Copyright Oscar Music and Media 2011.
50
51 =head1 LICENSE
52
53 This sofware is free software, and is licensed under the same terms as perl itself.
54
55 =cut
56