File Coverage

blib/lib/Build/Simple/Node.pm
Criterion Covered Total %
statement 15 15 100.0
branch 6 6 100.0
condition 7 8 87.5
subroutine 3 3 100.0
pod 0 1 0.0
total 31 33 93.9


line stmt bran cond sub pod time code
1             package Build::Simple::Node;
2             {
3             $Build::Simple::Node::VERSION = '0.002';
4             }
5              
6 1     1   6 use Moo;
  1         2  
  1         5  
7              
8             has phony => (
9             is => 'ro',
10             );
11              
12             has skip_mkdir => (
13             is => 'ro',
14             default => sub {
15             my $self = shift;
16             return $self->phony;
17             },
18             );
19              
20             has dependencies => (
21             is => 'ro',
22             default => sub { [] },
23             );
24              
25             has action => (
26             is => 'ro',
27             default => sub { sub {} },
28             );
29              
30             sub run {
31 40     40 0 65 my ($self, $name, $graph, $options) = @_;
32 40 100 100     541 if (!$self->phony and -e $name) {
33 14         22 my @files = grep { !$graph->_is_phony($_) } sort @{ $self->dependencies };
  7         24  
  14         39  
34 14 100 66 14   60 return if sub { -d $_ or -M $name <= -M $_ or return 0 for @files; 1 }->();
  14   100     241  
  13         50  
35             }
36 27 100       1108 File::Path::mkpath(File::Basename::dirname($name)) if !$self->skip_mkdir;
37 27         55 $self->action->(name => $name, dependencies => $self->dependencies, %{$options});
  27         111  
38 27         1607 return;
39             }
40              
41             1;
42              
43             #ABSTRACT: A Build::Simple node
44              
45              
46             __END__