Stepford/Role/Step/FileGenerator.pm

filter: Statementstmt 100% 43 / 43 Branchbran 100% 4 / 4 Conditioncond 100% 3 / 3 MC/DCmcdc 100% 2 / 2 Subroutinesub 100% 13 / 13 Podpod 100% 2 / 2 totaltotal 100% 67 / 67 CC 4 SCAR 4.1
CC
4
Cov
100%
__ANON__
3.0
last_run_time
2.0
BEGIN
1.0
CRAP 1.5
« Stepford.pm ↑ Summary Stepford/Role/Step.pm »
1 package Stepford::Role::Step::FileGenerator;
2  
3 32 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 32 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 32 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 32 our $VERSION = '0.006001';
8  
9 32 ▶use Carp qw( croak );
Subroutine BEGIN: called CC=1 SCAR=0.0
10 32 ▶use List::AllUtils qw( any max );
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 # Sadly, there's no (sane) way to make Path::Class::File use this
13 32 ▶use Time::HiRes 1.9726 qw( stat );
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 32 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 32 with 'Stepford::Role::Step';
18  
19 470 ▶sub BUILD { }
Subroutine BUILD: called CC=1 SCAR=0.0
Pod documented
20 480 ▶before BUILD => sub {
Subroutine __ANON__: called CC=3 SCAR=11.0
21 480 my $self = shift;
22  
23 2 my @not_files = sort map { $_->name } grep {
24 480 ▶ !( $_->has_type_constraint && _is_a_file_type( $_->type_constraint ) )
Condition100%3/3
$_->has_type_constraint && _is_a_file_type($_->type_constraint)
!ll&&!rl&&r
11592
MC/DC100%2/2
$_->has_type_constraint && _is_a_file_type($_->type_constraint)
$_->has_type_constraint _is_a_file_type($_->type_constraint)
Truth table100%3/3
A && B
A= $_->has_type_constraintB= _is_a_file_type($_->type_constraint)
ABresult
0X0
100
111
25 } $self->productions;
26  
27 480 ▶ croak 'The '
Branch: 1 branch
BranchTrueFalseTotal
if @not_files 1 479 480
28 . ( ref $self )
29 . ' class consumed the Stepford::Role::Step::FileGenerator role but contains'
30 . " the following productions which are not a supported file type: @not_files"
31 if @not_files;
32  
33 479 return;
34 32 };
35  
36 593 ▶sub _is_a_file_type {
Subroutine _is_a_file_type: called CC=1 SCAR=0.0
37 593 my $type = shift;
38  
39 593 ▶ return any { $type->is_a_type_of($_) } qw(
Subroutine __ANON__: called CC=1 SCAR=0.0
40 MooseX::Types::Path::Class::File
41 MooseX::Types::Path::Tiny::File
42 MooseX::Types::Path::Tiny::AbsFile
43 MooseX::Types::Path::Tiny::Path
44 MooseX::Types::Path::Tiny::AbsPath
45 );
46 }
47  
48 485 ▶sub last_run_time {
Subroutine last_run_time: called CC=2 SCAR=6.9
Pod documented
49 485 my $self = shift;
50  
51 my @production_files
52 485 = map { $self->${ \( $_->get_read_method ) } } $self->productions;
53  
54 485 ▶ return undef if any { !-f } @production_files;
Subroutine __ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
BranchTrueFalseTotal
if &any(sub { not -f $_; } , @production_files) 195 290 485
55  
56 290 my @times = map { ( stat $_ )[9] } @production_files;
57  
58 290 return max @times;
59 }
60  
61 32 1;
62  
63 # ABSTRACT: A role for steps that generate files
64  
65 __END__
« Stepford.pm ↑ Summary Stepford/Role/Step.pm »