blib/lib/App/hopen/Gen/Make/AssetGraphNode.pm

filter: Statementstmt 90.3% 56 / 62 Branchbran 87.5% 7 / 8 Conditioncond 33.3% 2 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 100% 12 / 12 Podpod n/a totaltotal 84.6% 77 / 91 CC 9 SCAR 16.5
CC
9
Cov
86%
_run
10.4
BEGIN
1.0
BEGIN
1.0
CRAP 5.2
« blib/lib/App/hopen/Util/BasedPath.pm ↑ Summary blib/lib/App/hopen/Util/String.pm »
1 # App::hopen::Gen::Make::AssetGraphNode - AssetOp for Gen::Make
2 package App::hopen::Gen::Make::AssetGraphNode;
3 1 ▶use Data::Hopen qw(getparameters *VERBOSE);
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::AssetOp';
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 App::hopen::BuildSystemGlobals; # for $DestDir
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use Quote::Code;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶use String::Print;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 # Docs {{{1
17  
18 =head1 NAME
19  
20 App::hopen::Gen::Make::AssetGraphNode - AssetOp for Gen::Make
21  
22 =head1 SYNOPSIS
23  
24 TODO
25  
26 =head1 FUNCTIONS
27  
28 =cut
29  
30 # }}}1
31  
32 1 ▶use vars::i '&OUTPUT' => sub { '__R_Makefile' };
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
33  
34 =head2 _run
35  
36 Generate a piece of a Makefile and write it to the filehandle in
37 C<__R_Makefile>.
38  
39 If the `how` of a node is defined but falsy, it's a goal.
40 If `how` is defined and truthy, it's a file.
41  
42 =cut
43  
44 sub _run {
45 4 ▶ my ($self, %args) = getparameters('self', [qw(; phase visitor)], @_);
Subroutine _run: called CC=9 SCAR=23.4
46 4 my $fh = $self->scope->find(OUTPUT);
47 # TODO deal with multiple inputs being merged in DAG::_run()
48  
49 4 my @inputs = $self->input_assets;
50 4 my $output = $self->asset->target;
51 4 ▶ $output = $output->path_wrt($DestDir) if eval { $output->DOES('App::hopen::Util::BasedPath') };
Branch: 1 branch
BranchTrueFalseTotal
if eval { do { $output->DOES("App::hopen::Util::BasedPath") } } 3 1 4
52 # TODO refactor this processing into a utility module/function
53  
54 # Debugging output
55 4 ▶ if($VERBOSE) {
Branch: 1 branch
BranchTrueFalseTotal
if ($App::hopen::Gen::Make::AssetGraphNode::VERBOSE) 0 4 4
56 0 say $fh qc'\n# Makefile piece from node {$self->name}';
57 0 ▶ say $fh qc' # {$self->how//"<nothing to be done>"}';
Condition0%0/2
$self->how // "<nothing to be done>"
l!l
00
MC/DC0%0/1
$self->how // "<nothing to be done>"
$self->how
Truth table0%0/2
A
A= $self->how
Aresult
11
00
58 0 say $fh qc' # Depends on {$_->target}' foreach @inputs;
59 }
60  
61 4 ▶ if(defined $self->how) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->how) 3 1 4
62 3 my @paths = map { $_->target->path_wrt($DestDir) } @inputs;
63 3 my $recipe = $self->how;
64 # TODO refactor this processing into a utility module/function
65 3 ▶ $recipe =~ s<#first\b><$paths[0] // ''>ge; # first input
Condition50%1/2
$paths[0] // ""
l!l
10
MC/DC0%0/1
$paths[0] // ""
$paths[0]
Truth table50%1/2
A
A= $paths[0]
Aresult
11
00
66 3 $recipe =~ s<#all\b><join(' ', @paths)>ge; # all inputs
67 3 ▶ $recipe =~ s<#out\b><$output // ''>ge;
Condition50%1/2
$output // ""
l!l
20
MC/DC0%0/1
$output // ""
$output
Truth table50%1/2
A
A= $output
Aresult
11
00
68  
69 # Emit the entry. If the recipe is defined but falsy,
70 # this is a goal, so it gets a .PHONY.
71 3 print $fh qc_to <<"EOT"
72 3 ▶#{$output}: #{join(" ", @paths)}
Branch: 1 branch
BranchTrueFalseTotal
$recipe ? : 2 1 3
73 #{$recipe ? "\t$recipe" : ".PHONY: $output"}
74  
75 EOT
76  
77 }
78  
79 4 $self->make($self->asset);
80 4 return {};
81 } #_run()
82  
83 1 1;
84 __END__
85 # vi: set fdm=marker: #
« blib/lib/App/hopen/Util/BasedPath.pm ↑ Summary blib/lib/App/hopen/Util/String.pm »