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