| 1 | package Boxer::Task::Serialize; | ||||||||||
| 2 | |||||||||||
| 3 | =encoding UTF-8 | ||||||||||
| 4 | |||||||||||
| 5 | =cut | ||||||||||
| 6 | |||||||||||
| 7 | 3 | ▶ | use v5.20; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 3 | ▶ | use utf8; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 3 | ▶ | use Role::Commons -all; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 3 | ▶ | use feature 'signatures'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 3 | ▶ | use namespace::autoclean 0.16; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | 3 | ▶ | use autodie; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | |||||||||||
| 14 | 3 | ▶ | use Path::Tiny; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 15 | 3 | ▶ | use File::ShareDir qw(dist_dir); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 16 | 3 | ▶ | use Boxer::File::WithSkeleton; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 17 | |||||||||||
| 18 | 3 | ▶ | use Moo; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 19 | 3 | ▶ | use MooX::StrictConstructor; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 20 | 3 | extends qw(Boxer::Task); | |||||||||
| 21 | |||||||||||
| 22 | 3 | ▶ | use Types::Standard qw( Bool Maybe Str Undef InstanceOf ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 23 | 3 | ▶ | use Types::Path::Tiny qw( Dir File Path ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 24 | 3 | ▶ | use Boxer::Types qw( SkelDir SerializationList ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 25 | |||||||||||
| 26 | 3 | ▶ | use strictures 2; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 27 | 3 | ▶ | no warnings "experimental::signatures"; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 28 | |||||||||||
| 29 | =head1 VERSION | ||||||||||
| 30 | |||||||||||
| 31 | Version v1.4.3 | ||||||||||
| 32 | |||||||||||
| 33 | =cut | ||||||||||
| 34 | |||||||||||
| 35 | 3 | our $VERSION = "v1.4.3"; | |||||||||
| 36 | |||||||||||
| 37 | 3 | has world => ( | |||||||||
| 38 | is => 'ro', | ||||||||||
| 39 | isa => InstanceOf ['Boxer::World'], | ||||||||||
| 40 | required => 1, | ||||||||||
| 41 | ); | ||||||||||
| 42 | |||||||||||
| 43 | 3 | has skeldir => ( | |||||||||
| 44 | is => 'ro', | ||||||||||
| 45 | isa => Maybe [SkelDir], | ||||||||||
| 46 | coerce => 1, | ||||||||||
| 47 | ); | ||||||||||
| 48 | |||||||||||
| 49 | 3 | has infile => ( | |||||||||
| 50 | is => 'ro', | ||||||||||
| 51 | isa => File, | ||||||||||
| 52 | coerce => 1, | ||||||||||
| 53 | ); | ||||||||||
| 54 | |||||||||||
| 55 | 3 | has altinfile => ( | |||||||||
| 56 | is => 'ro', | ||||||||||
| 57 | isa => File, | ||||||||||
| 58 | coerce => 1, | ||||||||||
| 59 | ); | ||||||||||
| 60 | |||||||||||
| 61 | 3 | has outdir => ( | |||||||||
| 62 | is => 'ro', | ||||||||||
| 63 | isa => Dir, | ||||||||||
| 64 | coerce => 1, | ||||||||||
| 65 | ); | ||||||||||
| 66 | |||||||||||
| 67 | 3 | has outfile => ( | |||||||||
| 68 | is => 'ro', | ||||||||||
| 69 | isa => Path, | ||||||||||
| 70 | coerce => 1, | ||||||||||
| 71 | ); | ||||||||||
| 72 | |||||||||||
| 73 | 3 | has altoutfile => ( | |||||||||
| 74 | is => 'ro', | ||||||||||
| 75 | isa => Path, | ||||||||||
| 76 | coerce => 1, | ||||||||||
| 77 | ); | ||||||||||
| 78 | |||||||||||
| 79 | 3 | has node => ( | |||||||||
| 80 | is => 'ro', | ||||||||||
| 81 | isa => Str, | ||||||||||
| 82 | required => 1, | ||||||||||
| 83 | ); | ||||||||||
| 84 | |||||||||||
| 85 | 3 | has format => ( | |||||||||
| 86 | is => 'ro', | ||||||||||
| 87 | isa => SerializationList, | ||||||||||
| 88 | coerce => 1, | ||||||||||
| 89 | required => 1, | ||||||||||
| 90 | ); | ||||||||||
| 91 | |||||||||||
| 92 | has nonfree => ( | ||||||||||
| 93 | is => 'ro', | ||||||||||
| 94 | isa => Bool, | ||||||||||
| 95 | required => 1, | ||||||||||
| 96 | 4 | ▶ | default => sub {0}, | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 97 | 3 | ); | |||||||||
| 98 | |||||||||||
| 99 | 6 | ▶ | sub run ($self) | ||||||||
|
Subroutine
run: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||
| 100 | { | ||||||||||
| 101 | 6 | my $world = $self->world->map( $self->node, $self->nonfree, ); | |||||||||
| 102 | |||||||||||
| 103 | 6 | ▶ | if ( grep( /^preseed$/, @{ $self->format } ) ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 104 | 4 | my @args = ( | |||||||||
| 105 | basename => 'preseed.cfg', | ||||||||||
| 106 | skeleton_dir => $self->skeldir, | ||||||||||
| 107 | skeleton_path => $self->infile, | ||||||||||
| 108 | file_dir => $self->outdir, | ||||||||||
| 109 | file_path => $self->outfile, | ||||||||||
| 110 | ); | ||||||||||
| 111 | 4 | ▶ | $self->_logger->info( | ||||||||
|
Branch: 1 branch
| |||||||||||
| 112 | 'Serializing to preseed', | ||||||||||
| 113 | $self->_logger->is_debug() ? {@args} : (), | ||||||||||
| 114 | ); | ||||||||||
| 115 | 4 | my $file = Boxer::File::WithSkeleton->new(@args); | |||||||||
| 116 | 4 | $world->as_file($file); | |||||||||
| 117 | } | ||||||||||
| 118 | |||||||||||
| 119 | 6 | ▶ | if ( grep( /^script$/, @{ $self->format } ) ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 120 | 4 | my @args = ( | |||||||||
| 121 | basename => 'script.sh', | ||||||||||
| 122 | skeleton_dir => $self->skeldir, | ||||||||||
| 123 | skeleton_path => $self->altinfile, | ||||||||||
| 124 | file_dir => $self->outdir, | ||||||||||
| 125 | file_path => $self->altoutfile, | ||||||||||
| 126 | ); | ||||||||||
| 127 | 4 | ▶ | $self->_logger->info( | ||||||||
|
Branch: 1 branch
| |||||||||||
| 128 | 'Serializing to script', | ||||||||||
| 129 | $self->_logger->is_debug() ? {@args} : (), | ||||||||||
| 130 | ); | ||||||||||
| 131 | 4 | my $file = Boxer::File::WithSkeleton->new(@args); | |||||||||
| 132 | 4 | $world->as_file( $file, 1 ); | |||||||||
| 133 | } | ||||||||||
| 134 | |||||||||||
| 135 | 6 | 1; | |||||||||
| 136 | } | ||||||||||
| 137 | |||||||||||
| 138 | =head1 AUTHOR | ||||||||||
| 139 | |||||||||||
| 140 | Jonas Smedegaard C<< <dr@jones.dk> >>. | ||||||||||
| 141 | |||||||||||
| 142 | =cut | ||||||||||
| 143 | |||||||||||
| 144 | 3 | our $AUTHORITY = 'cpan:JONASS'; | |||||||||
| 145 | |||||||||||
| 146 | =head1 COPYRIGHT AND LICENCE | ||||||||||
| 147 | |||||||||||
| 148 | Copyright © 2013-2016 Jonas Smedegaard | ||||||||||
| 149 | |||||||||||
| 150 | This is free software; you can redistribute it and/or modify it under | ||||||||||
| 151 | the same terms as the Perl 5 programming language system itself. | ||||||||||
| 152 | |||||||||||
| 153 | =head1 DISCLAIMER OF WARRANTIES | ||||||||||
| 154 | |||||||||||
| 155 | THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED | ||||||||||
| 156 | WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF | ||||||||||
| 157 | MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||||||||||
| 158 | |||||||||||
| 159 | =cut | ||||||||||
| 160 | |||||||||||
| 161 | 3 | 1; | |||||||||