| 1 | # App::hopen::G::OutputPerFileCmd - hopen Cmd that makes outputs from input separately | ||||||||||
| 2 | package App::hopen::G::OutputPerFileCmd; | ||||||||||
| 3 | 1 | ▶ | use Data::Hopen; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 1 | ▶ | use strict; use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 1 | ▶ | use Data::Hopen::Base; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 1 | our $VERSION = '0.000013'; # TRIAL | |||||||||
| 8 | |||||||||||
| 9 | 1 | ▶ | use parent 'App::hopen::G::Cmd'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 1 | ▶ | use Class::Tiny; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | |||||||||||
| 12 | 1 | ▶ | use Data::Hopen::Util::Data qw(forward_opts); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | |||||||||||
| 14 | # Docs {{{1 | ||||||||||
| 15 | |||||||||||
| 16 | =head1 NAME | ||||||||||
| 17 | |||||||||||
| 18 | App::hopen::G::OutputPerFileCmd - hopen Cmd that makes outputs for each input separately | ||||||||||
| 19 | |||||||||||
| 20 | =head1 SYNOPSIS | ||||||||||
| 21 | |||||||||||
| 22 | In a Cmd package: | ||||||||||
| 23 | |||||||||||
| 24 | use parent 'App::hopen::G::OutputPerFileCmd'; | ||||||||||
| 25 | use Class::Tiny; | ||||||||||
| 26 | sub _process_input { | ||||||||||
| 27 | my ($self, $source_asset) = @_; | ||||||||||
| 28 | # $source_asset is an App::hopen::Asset | ||||||||||
| 29 | ... # Return a list of [$asset, $how] arrayrefs | ||||||||||
| 30 | } | ||||||||||
| 31 | |||||||||||
| 32 | =cut | ||||||||||
| 33 | |||||||||||
| 34 | # }}}1 | ||||||||||
| 35 | |||||||||||
| 36 | =head1 FUNCTIONS | ||||||||||
| 37 | |||||||||||
| 38 | =head2 _process_input | ||||||||||
| 39 | |||||||||||
| 40 | Makes output assets for a given input asset. Must be implemented | ||||||||||
| 41 | by subclasses. Called as: | ||||||||||
| 42 | |||||||||||
| 43 | $self->_process_input(-asset=>$asset, -visitor=>$visitor); | ||||||||||
| 44 | |||||||||||
| 45 | Returns a list of arrayrefs of C<[$asset, $how]>. C<$how> defaults to C<undef>. | ||||||||||
| 46 | |||||||||||
| 47 | =cut | ||||||||||
| 48 | |||||||||||
| 49 | sub _process_input { | ||||||||||
| 50 | ... | ||||||||||
| 51 | 0 | ▶ | } #_process_input() | ||||||||
|
Subroutine
_process_input: not called CC=1 SCAR=6.9
| |||||||||||
| 52 | |||||||||||
| 53 | =head2 _should_act | ||||||||||
| 54 | |||||||||||
| 55 | Returns truthy if L</_process_input> should be called. Must be implemented | ||||||||||
| 56 | by subclasses. Called as: | ||||||||||
| 57 | |||||||||||
| 58 | $self->_should_act(-phase=>$phase, -visitor=>$visitor); | ||||||||||
| 59 | |||||||||||
| 60 | =cut | ||||||||||
| 61 | |||||||||||
| 62 | sub _should_act { | ||||||||||
| 63 | ... | ||||||||||
| 64 | 0 | ▶ | } | ||||||||
|
Subroutine
_should_act: not called CC=1 SCAR=6.9
| |||||||||||
| 65 | |||||||||||
| 66 | =head2 _run | ||||||||||
| 67 | |||||||||||
| 68 | Creates the output list by calling L</_process_input>. | ||||||||||
| 69 | |||||||||||
| 70 | =cut | ||||||||||
| 71 | |||||||||||
| 72 | sub _run { | ||||||||||
| 73 | 3 | ▶ | my ($self, %args) = getparameters('self', [qw(visitor ; *)], @_); | ||||||||
|
Subroutine
_run: called CC=4 SCAR=13.9
| |||||||||||
| 74 | |||||||||||
| 75 | 3 | ▶ | return $self->passthrough(-nocontext=>1) unless | ||||||||
|
Branch: 1 branch
| |||||||||||
| 76 | $self->_should_act(forward_opts(\%args, {'-'=>1}, qw(visitor))); | ||||||||||
| 77 | |||||||||||
| 78 | # Pull the inputs | ||||||||||
| 79 | 3 | my $lrSourceFiles = $self->input_assets; | |||||||||
| 80 | 3 | ▶ | hlog { 'found source files', Dumper($lrSourceFiles) } 2; | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||
| 81 | |||||||||||
| 82 | 3 | my @outputs; | |||||||||
| 83 | 3 | foreach my $src (@$lrSourceFiles) { | |||||||||
| 84 | 3 | my @outputs_here = $self->_process_input(-asset=>$src, | |||||||||
| 85 | forward_opts(\%args, {'-'=>1}, qw(visitor))); | ||||||||||
| 86 | |||||||||||
| 87 | 3 | foreach my $lrOutput (@outputs_here) { | |||||||||
| 88 | 3 | my ($obj, $how) = @$lrOutput; | |||||||||
| 89 | 3 | push @outputs, $obj; | |||||||||
| 90 | 3 | $args{visitor}->asset($obj, -how => $how); | |||||||||
| 91 | 3 | $args{visitor}->connect($src, $obj); | |||||||||
| 92 | } #foreach $lrOutput | ||||||||||
| 93 | } #foreach $src | ||||||||||
| 94 | |||||||||||
| 95 | 3 | $self->make(\@outputs); | |||||||||
| 96 | 3 | return {}; | |||||||||
| 97 | } #_run() | ||||||||||
| 98 | |||||||||||
| 99 | |||||||||||
| 100 | 1 | 1; | |||||||||
| 101 | __END__ | ||||||||||
| 102 | # vi: set fdm=marker: # | ||||||||||