File Coverage

blib/lib/Data/Hopen/G/Goal.pm
Criterion Covered Total %
statement 25 25 100.0
branch 6 6 100.0
condition n/a
subroutine 9 9 100.0
pod 1 1 100.0
total 41 41 100.0


line stmt bran cond sub pod time code
1             # Data::Hopen::G::Goal - A named build goal
2             package Data::Hopen::G::Goal;
3 9     9   23352 use strict;
  9         20  
  9         326  
4 9     9   50 use Data::Hopen::Base;
  9         19  
  9         62  
5              
6             our $VERSION = '0.000017';
7              
8 9     9   2149 use parent 'Data::Hopen::G::Op';
  9         23  
  9         64  
9             use Class::Tiny {
10 9         115 should_output => true, # if true, forward the goal's inputs as
11             # its outputs.
12 9     9   603 };
  9         23  
13              
14 9     9   2281 use Data::Hopen;
  9         19  
  9         554  
15 9     9   60 use Data::Hopen::Util::Data qw(forward_opts);
  9         20  
  9         2392  
16              
17             # Docs {{{1
18              
19             =head1 NAME
20              
21             Data::Hopen::G::Goal - a named goal in a hopen build
22              
23             =head1 SYNOPSIS
24              
25             A C is a named build target, e.g., C or C. The name C
26             is reserved for the root goal. Goals usually appear at the end of the build
27             graph, but this is not required --- Goal nodes can appear anywhere in the
28             graph.
29              
30             =head1 MEMBERS
31              
32             =head2 should_output
33              
34             Boolean, default true. If false, the goal's outputs are always C<{}> (empty).
35             If true, the goal's inputs are passed through as outputs.
36              
37             =head1 FUNCTIONS
38              
39             =head2 run
40              
41             Passes through the inputs if L is set.
42              
43             =cut
44              
45             # }}}1
46              
47             sub _run {
48 27     27   147 my ($self, %args) = getparameters('self', [qw(; phase visitor)], @_);
49 20 100   20   82 hlog { Goal => $self->name, ($self->should_output ? 'with' : 'without'),
50 27         1334 'outputs' };
51              
52 27 100       773 return {} unless $self->should_output;
53              
54 25         345 return $self->passthrough(-nocontext=>1, -levels => 'local',
55             forward_opts(\%args, {'-'=>1}, qw[phase visitor]));
56             } #_run()
57              
58             =head2 BUILD
59              
60             Enforce the requirement for a user-specified name.
61              
62             =cut
63              
64             sub BUILD {
65 17     17 1 2478 my ($self, $args) = @_;
66 17 100       370 croak 'Goals must have names' unless $args->{name};
67             } #BUILD()
68              
69             1;
70             __END__