line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# App::hopen::G::Cmd - base class for hopen(1) command-graph nodes |
2
|
|
|
|
|
|
|
package App::hopen::G::Cmd; |
3
|
3
|
|
|
3
|
|
1298
|
use strict; use warnings; |
|
3
|
|
|
3
|
|
6
|
|
|
3
|
|
|
|
|
85
|
|
|
3
|
|
|
|
|
15
|
|
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
87
|
|
4
|
3
|
|
|
3
|
|
16
|
use Data::Hopen::Base; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
18
|
|
5
|
3
|
|
|
3
|
|
4324
|
use Quote::Code; |
|
3
|
|
|
|
|
674
|
|
|
3
|
|
|
|
|
16
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.000012'; # TRIAL |
8
|
|
|
|
|
|
|
|
9
|
3
|
|
|
3
|
|
173
|
use parent 'Data::Hopen::G::Op'; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
34
|
|
10
|
|
|
|
|
|
|
use Class::Tiny { |
11
|
13
|
|
|
|
|
111
|
made => sub { [] }, |
12
|
3
|
|
|
3
|
|
108300
|
}; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
34
|
|
13
|
|
|
|
|
|
|
|
14
|
3
|
|
|
3
|
|
2112
|
use Class::Method::Modifiers qw(around); |
|
3
|
|
|
|
|
4743
|
|
|
3
|
|
|
|
|
177
|
|
15
|
3
|
|
|
3
|
|
64
|
use Data::Hopen qw(getparameters); |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
1566
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# Docs {{{1 |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 NAME |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
App::hopen::G::Cmd - base class for hopen(1) command-graph nodes |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 SYNOPSIS |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
This is the base class for graph nodes in the command graph of |
26
|
|
|
|
|
|
|
L<App::hopen>. See L<App::hopen::Conventions>. |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head2 made |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
An arrayref of the outputs from this function, which are L<App::hopen::Asset> |
33
|
|
|
|
|
|
|
instances. |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=cut |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# }}}1 |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 FUNCTIONS |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head2 make |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
Adds L<App::hopen::Asset> instances to L</made> (a L<Cmd|App::hopen::G::Cmd>'s |
44
|
|
|
|
|
|
|
asset output). B<Does not> add the assets to the generator's asset graph, |
45
|
|
|
|
|
|
|
since the generator is not available as instance data. One or more parameters |
46
|
|
|
|
|
|
|
or arrayrefs of parameters can be given. Returns a list of the C<Asset> |
47
|
|
|
|
|
|
|
instances made. Each parameter can be: |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=over |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=item * |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
An L<App::hopen::Asset> or subclass (in which case |
54
|
|
|
|
|
|
|
L<made_by|App::hopen::Asset/made_by> is updated) |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=item * |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
A valid C<target> for an L<App::hopen::Asset>. |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=back |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=cut |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub make { |
65
|
15
|
50
|
|
15
|
1
|
384
|
my $self = shift or croak 'Need an instance'; |
66
|
15
|
|
|
|
|
245
|
my @retval; |
67
|
15
|
|
|
|
|
38
|
for my $arg (@_) { |
68
|
15
|
100
|
|
|
|
57
|
if(ref $arg eq 'ARRAY') { |
|
|
100
|
|
|
|
|
|
69
|
2
|
|
|
|
|
10
|
push @retval, $self->make(@$arg); |
70
|
13
|
|
|
|
|
97
|
} elsif(eval { $arg->DOES('App::hopen::Asset') }) { |
71
|
10
|
|
|
|
|
40
|
$arg->made_by($self); |
72
|
10
|
|
|
|
|
57
|
push @{$self->made}, $arg; |
|
10
|
|
|
|
|
246
|
|
73
|
10
|
|
|
|
|
26
|
push @retval, $arg; |
74
|
|
|
|
|
|
|
} else { |
75
|
3
|
|
|
|
|
27
|
my $asset = App::hopen::Asset->new(target=>$arg, made_by=>$self); |
76
|
3
|
|
|
|
|
42
|
push @{$self->made}, $asset; |
|
3
|
|
|
|
|
77
|
|
77
|
3
|
|
|
|
|
12
|
push @retval, $asset; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
} #foreach arg |
80
|
15
|
|
|
|
|
44
|
return @retval; |
81
|
|
|
|
|
|
|
} #make() |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head2 input_assets |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Returns the assets provided as input via L</make> calls in predecessor nodes. |
86
|
|
|
|
|
|
|
Only meaningful within C<_run()> (since that's when C<< $self->scope >> |
87
|
|
|
|
|
|
|
is populated). Returns an arrayref in scalar context or a list in list context. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=cut |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub input_assets { |
92
|
10
|
50
|
|
10
|
1
|
42
|
my $self = shift or croak 'Need an instance'; |
93
|
10
|
|
|
|
|
168
|
my $lrSourceFiles; |
94
|
|
|
|
|
|
|
|
95
|
10
|
|
100
|
|
|
207
|
my $hrSourceFiles = |
96
|
|
|
|
|
|
|
$self->scope->find(-name => 'made', -set => '*', -levels => 'local') // {}; |
97
|
|
|
|
|
|
|
|
98
|
10
|
100
|
|
|
|
5565
|
if(keys %$hrSourceFiles) { |
99
|
8
|
|
|
|
|
26
|
$lrSourceFiles = $hrSourceFiles->{(keys %$hrSourceFiles)[0]}; |
100
|
|
|
|
|
|
|
} else { |
101
|
2
|
|
|
|
|
6
|
$lrSourceFiles = []; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
10
|
100
|
|
|
|
35
|
return $lrSourceFiles unless wantarray; |
105
|
6
|
|
|
|
|
40
|
return @$lrSourceFiles; |
106
|
|
|
|
|
|
|
} #input_assets() |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head2 run |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
Overrides L<Data::Hopen::G::Runnable/run> to stuff L</made> into the |
111
|
|
|
|
|
|
|
outputs if it's not already there. Note that this will B<replace> |
112
|
|
|
|
|
|
|
any non-arrayref C<made> output. |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=cut |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
around 'run' => sub { |
117
|
|
|
|
|
|
|
my $orig = shift; |
118
|
|
|
|
|
|
|
my $self = shift or croak 'Need an instance'; |
119
|
|
|
|
|
|
|
my $retval = $self->$orig(@_); |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
$retval->{made} = $self->made unless ref $retval->{made} eq 'ARRAY'; |
122
|
|
|
|
|
|
|
# TODO clone? Shallow copy? |
123
|
|
|
|
|
|
|
return $retval; |
124
|
|
|
|
|
|
|
}; #run() |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
1; |
127
|
|
|
|
|
|
|
__END__ |
128
|
|
|
|
|
|
|
# vi: set fdm=marker: # |