| 1 | package App::Test::Generator::Template; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 228 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 228 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 228 | ▶ | use autodie qw(:all); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 228 | ▶ | use utf8; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 228 | ▶ | use Carp qw(carp); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 228 | ▶ | use Data::Section::Simple; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 228 | ▶ | use Scalar::Util (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 228 | our $VERSION = '0.50'; | |||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | =head1 NAME | ||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | App::Test::Generator::Template - Template for the test files generated by App::Test::Generator | ||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | =head1 VERSION | ||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | Version 0.50 | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | The template for the test files generated by App::Test::Generator. | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | =head1 METHODS | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | =head2 get_data_section | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | Returns a reference to the named template, read from this module's | ||||||||||||||||||||||||||||
| 31 | C<__DATA__> section via L<Data::Section::Simple>. | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | my $template_ref = App::Test::Generator::Template->get_data_section('test.tt'); | ||||||||||||||||||||||||||||
| 34 | my $template_ref = App::Test::Generator::Template::get_data_section('test.tt'); | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | =head3 Arguments | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | =over 4 | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | =item * C<$template_file> | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | The name of the C<@@>-delimited section to retrieve. The only value | ||||||||||||||||||||||||||||
| 43 | currently defined in this module's C<__DATA__> section is C<test.tt>. | ||||||||||||||||||||||||||||
| 44 | May be called either as a class method (C<< Template->get_data_section(...) >>, | ||||||||||||||||||||||||||||
| 45 | in which case the leading class-name argument is stripped before lookup) | ||||||||||||||||||||||||||||
| 46 | or as a plain function. | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | =back | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | =head3 Returns | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | A scalar reference to the template content. If C<$template_file> does | ||||||||||||||||||||||||||||
| 53 | not match a defined C<@@> section, returns a reference to C<undef>. | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | =head3 Side Effects | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | None. Does not write to disk or modify any global state. | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | =head3 API specification | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | =head4 input | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | { | ||||||||||||||||||||||||||||
| 64 | template_file => { type => SCALAR, optional => 1 }, | ||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | =head4 output | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | { type => SCALARREF } | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | =cut | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | sub get_data_section | ||||||||||||||||||||||||||||
| 74 | 567 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
get_data_section: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 75 | 567 | ▶ | if($_[0] && ($_[0] eq __PACKAGE__)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$_[0] and $_[0] eq __PACKAGE__
MC/DC100%2/2
$_[0] and $_[0] eq __PACKAGE__
$_[0]
$_[0] eq __PACKAGE__
Truth table100%3/3
A and B
A= $_[0]B= $_[0] eq __PACKAGE__
| |||||||||||||||||||||||||||||
| 76 | 435 | shift; | |||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | 567 | return \Data::Section::Simple::get_data_section($_[0]); | |||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | 228 | 1; | |||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | Nigel Horne, C<< <njh at nigelhorne.com> >> | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | Portions of this module's initial design and documentation were created with the | ||||||||||||||||||||||||||||
| 89 | assistance of L<ChatGPT|https://openai.com/> (GPT-5), with final curation | ||||||||||||||||||||||||||||
| 90 | and authorship by Nigel Horne. | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | =cut | ||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | __DATA__ | ||||||||||||||||||||||||||||