| 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 | 5 5 5 | 154990 5 78 | use strict; | |||
| 4 | 5 5 5 | 8 4 99 | use warnings; | |||
| 5 | 5 5 5 | 346 17430 82 | use Params::Validate::Strict 0.30; | |||
| 6 | 5 5 5 | 9 5 389 | use YAML::XS; | |||
| 7 | ||||||
| 8 | our $VERSION = '0.41'; | |||||
| 9 | ||||||
| 10 - 18 | =head1 NAME App::Test::Generator::Exporter::YAML - Serialise a test plan to YAML =head1 VERSION Version 0.41 =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' },
}
=head4 output
{ type => UNDEF }
=cut | |||||
| 57 | ||||||
| 58 | sub export { | |||||
| 59 | 12 | 20494 | my ($self, $plan, $file) = @_; | |||
| 60 | ||||||
| 61 | 12 | 8 | my %args; | |||
| 62 | 12 | 20 | $args{plan} = $plan if defined $plan; | |||
| 63 | 12 | 18 | $args{file} = $file if defined $file; | |||
| 64 | ||||||
| 65 | 12 | 48 | 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 | 5 | 682 | YAML::XS::DumpFile($params->{file}, $params->{plan}); | |||
| 74 | ||||||
| 75 | 4 | 734 | return; | |||
| 76 | } | |||||
| 77 | ||||||
| 78 | 1; | |||||