| File: | blib/lib/App/Test/Generator/Exporter/YAML.pm |
| Coverage: | 100.0% |
| line | stmt | bran | cond | sub | time | code |
|---|---|---|---|---|---|---|
| 1 | package App::Test::Generator::Exporter::YAML; | |||||
| 2 | ||||||
| 3 | 7 7 7 | 170267 7 80 | use strict; | |||
| 4 | 7 7 7 | 10 6 181 | use warnings; | |||
| 5 | 7 7 7 | 1019 42195 147 | use Params::Validate::Strict 0.30; | |||
| 6 | 7 7 7 | 18 14 586 | use YAML::XS; | |||
| 7 | ||||||
| 8 | our $VERSION = '0.46'; | |||||
| 9 | ||||||
| 10 - 18 | =head1 NAME App::Test::Generator::Exporter::YAML - Serialise a test plan to YAML =head1 VERSION Version 0.46 =cut | |||||
| 19 | ||||||
| 20 - 56 | =head2 export
Serialise a plan hashref to a YAML file on disk.
=head3 Arguments
=over 4
=item * C<$plan>
A hashref representing the test plan to serialise.
=item * C<$file>
A string. The path to the output YAML file.
=back
=head3 Returns
Nothing.
=head3 API specification
=head4 input
{
self => { type => 'object' },
plan => { type => 'hashref' },
file => { type => 'string', min => 1 },
}
=head4 output
{ type => UNDEF }
=cut | |||||
| 57 | ||||||
| 58 | sub export { | |||||
| 59 | 20 | 29210 | my ($self, $plan, $file) = @_; | |||
| 60 | ||||||
| 61 | 20 | 19 | my %args; | |||
| 62 | 20 | 41 | $args{plan} = $plan if defined $plan; | |||
| 63 | 20 | 39 | $args{file} = $file if defined $file; | |||
| 64 | ||||||
| 65 | 20 | 115 | my $params = Params::Validate::Strict::validate_strict({ | |||
| 66 | args => \%args, | |||||
| 67 | schema => { | |||||
| 68 | plan => { type => 'hashref' }, | |||||
| 69 | file => { type => 'string', min => 1 }, | |||||
| 70 | } | |||||
| 71 | }); | |||||
| 72 | ||||||
| 73 | 11 | 1365 | YAML::XS::DumpFile($params->{file}, $params->{plan}); | |||
| 74 | ||||||
| 75 | 9 | 1600 | return; | |||
| 76 | } | |||||
| 77 | ||||||
| 78 | 1; | |||||