package CatalystX::HelpText::Finder::TemplateToolkit::Regexp;
use Moose;
use List::MoreUtils qw/ uniq /;
use namespace::autoclean;

sub find_helptext_keys_in_fn {
    my ($self, $fn) = @_;
    open(my $FILE, '<', $fn) or warn "Can't open $fn\n" && return;
    my @keys = ();
    while (my $line = <$FILE>) {
        if (my ($key) = $line =~ m/help_text\(\s*['"](.*)['"]\s*\)/) {
            push @keys, $key;
        }
    }
    close($FILE);
    return [ uniq @keys ];
}

__PACKAGE__->meta->make_immutable;

1;


=head1 NAME

CatalystX::HelpText::Finder::TemplateToolkit::Regexp

=head1 SYNOPSIS

    Find helptext keys parsing the templates using a regular expression, it helps to find
    helptext keys which are not called by a simple TT parsing due logical conditions

=head1 SEE ALSO

=over

=item L<CatalystX::HelpText>

=back

=head1 AUTHOR

Toomas Doran, C<< t0m at state51.co.uk >>

Cinxgler Mariaca Minda, C<< cinxgler at ci-info.com >>

=head1 COPYRIGHT

Copyright Oscar Music and Media 2011.

=head1 LICENSE

This sofware is free software, and is licensed under the same terms as perl itself.

=cut

