File Coverage

File:blib/lib/App/Test/Generator/Template.pm
Coverage:100.0%

linestmtbrancondsubtimecode
1package App::Test::Generator::Template;
2
3
84
84
84
49094
55
711
use strict;
4
84
84
84
81
35
1136
use warnings;
5
84
84
84
245
4444
147
use autodie qw(:all);
6
7
84
84
84
133159
148
301
use utf8;
8
84
84
84
875
94
1468
use Carp qw(carp);
9
84
84
84
11758
19705
1182
use Data::Section::Simple;
10
84
84
84
135
67
3188
use Scalar::Util ();
11
12our $VERSION = '0.52';
13
14 - 71
=head1 NAME

App::Test::Generator::Template - Template for the test files generated by App::Test::Generator

=head1 VERSION

Version 0.52

=head1 SYNOPSIS

The template for the test files generated by App::Test::Generator.

=head1 METHODS

=head2 get_data_section

Returns a reference to the named template, read from this module's
C<__DATA__> section via L<Data::Section::Simple>.

    my $template_ref = App::Test::Generator::Template->get_data_section('test.tt');
    my $template_ref = App::Test::Generator::Template::get_data_section('test.tt');

=head3 Arguments

=over 4

=item * C<$template_file>

The name of the C<@@>-delimited section to retrieve. The only value
currently defined in this module's C<__DATA__> section is C<test.tt>.
May be called either as a class method (C<< Template->get_data_section(...) >>,
in which case the leading class-name argument is stripped before lookup)
or as a plain function.

=back

=head3 Returns

A scalar reference to the template content. If C<$template_file> does
not match a defined C<@@> section, returns a reference to C<undef>.

=head3 Side Effects

None. Does not write to disk or modify any global state.

=head3 API specification

=head4 input

    {
        template_file => { type => SCALAR, optional => 1 },
    }

=head4 output

    { type => SCALARREF }

=cut
72
73sub get_data_section
74{
75
207
19103397
        if($_[0] && ($_[0] eq __PACKAGE__)) {
76
202
137
                shift;
77        }
78
79
207
568
        return \Data::Section::Simple::get_data_section($_[0]);
80}
81
821;
83
84 - 92
=head1 AUTHOR

Nigel Horne, C<< <njh at nigelhorne.com> >>

Portions of this module's initial design and documentation were created with the
assistance of L<ChatGPT|https://openai.com/> (GPT-5), with final curation
and authorship by Nigel Horne.

=cut
93