line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Stepford::Role::Step::FileGenerator; |
2
|
|
|
|
|
|
|
|
3
|
32
|
|
|
32
|
|
318695
|
use strict; |
|
32
|
|
|
|
|
75
|
|
|
32
|
|
|
|
|
941
|
|
4
|
32
|
|
|
32
|
|
182
|
use warnings; |
|
32
|
|
|
|
|
63
|
|
|
32
|
|
|
|
|
748
|
|
5
|
32
|
|
|
32
|
|
168
|
use namespace::autoclean; |
|
32
|
|
|
|
|
77
|
|
|
32
|
|
|
|
|
186
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.006000'; |
8
|
|
|
|
|
|
|
|
9
|
32
|
|
|
32
|
|
2445
|
use Carp qw( croak ); |
|
32
|
|
|
|
|
69
|
|
|
32
|
|
|
|
|
1798
|
|
10
|
32
|
|
|
32
|
|
1815
|
use List::AllUtils qw( any max ); |
|
32
|
|
|
|
|
31260
|
|
|
32
|
|
|
|
|
1822
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# Sadly, there's no (sane) way to make Path::Class::File use this |
13
|
32
|
|
|
32
|
|
13183
|
use Time::HiRes 1.9726 qw( stat ); |
|
32
|
|
|
|
|
36410
|
|
|
32
|
|
|
|
|
205
|
|
14
|
|
|
|
|
|
|
|
15
|
32
|
|
|
32
|
|
5091
|
use Moose::Role; |
|
32
|
|
|
|
|
128
|
|
|
32
|
|
|
|
|
293
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
with 'Stepford::Role::Step'; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
470
|
1
|
|
sub BUILD { } |
20
|
|
|
|
|
|
|
before BUILD => sub { |
21
|
|
|
|
|
|
|
my $self = shift; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
my @not_files = sort map { $_->name } grep { |
24
|
|
|
|
|
|
|
!( $_->has_type_constraint && _is_a_file_type( $_->type_constraint ) ) |
25
|
|
|
|
|
|
|
} $self->productions; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
croak 'The ' |
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
|
|
|
|
|
|
|
return; |
34
|
|
|
|
|
|
|
}; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub _is_a_file_type { |
37
|
593
|
|
|
593
|
|
26886
|
my $type = shift; |
38
|
|
|
|
|
|
|
|
39
|
593
|
|
|
609
|
|
4771
|
return any { $type->is_a_type_of($_) } qw( |
|
609
|
|
|
|
|
20334
|
|
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
|
|
|
|
|
|
|
sub last_run_time { |
49
|
485
|
|
|
485
|
1
|
1505
|
my $self = shift; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
my @production_files |
52
|
485
|
|
|
|
|
2607
|
= map { $self->${ \( $_->get_read_method ) } } $self->productions; |
|
604
|
|
|
|
|
99178
|
|
|
604
|
|
|
|
|
5044
|
|
53
|
|
|
|
|
|
|
|
54
|
485
|
100
|
|
556
|
|
105590
|
return undef if any { !-f } @production_files; |
|
556
|
|
|
|
|
6981
|
|
55
|
|
|
|
|
|
|
|
56
|
290
|
|
|
|
|
16781
|
my @times = map { ( stat $_ )[9] } @production_files; |
|
361
|
|
|
|
|
5008
|
|
57
|
|
|
|
|
|
|
|
58
|
290
|
|
|
|
|
22060
|
return max @times; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
1; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
# ABSTRACT: A role for steps that generate files |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
__END__ |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=pod |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=encoding UTF-8 |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 NAME |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Stepford::Role::Step::FileGenerator - A role for steps that generate files |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 VERSION |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
version 0.006000 |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 DESCRIPTION |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
This role consumes the L<Stepford::Role::Step> role and adds some additional |
82
|
|
|
|
|
|
|
functionality specific to generating files. |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 METHODS |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
This role provides the following methods: |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head2 $step->BUILD |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
This method adds a wrapper to the BUILD method which checks that all of the |
91
|
|
|
|
|
|
|
class's productions are of the C<File> type provided by |
92
|
|
|
|
|
|
|
L<MooseX::Types::Path::Class> or one of the L<MooseX::Types::Path::Tiny> file |
93
|
|
|
|
|
|
|
types. The attributes can also be subtypes of these types. |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
This check may be changed so that it is done as part of the class definition, |
96
|
|
|
|
|
|
|
if I can think of a way to do this sanely. |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head2 $step->last_run_time |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
This returns the most recent file modification time from all of the step's |
101
|
|
|
|
|
|
|
productions, or C<undef> (requesting an unconditional run) if any productions |
102
|
|
|
|
|
|
|
are missing. |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head1 SUPPORT |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Bugs may be submitted through L<https://github.com/maxmind/Stepford/issues>. |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head1 AUTHOR |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
Dave Rolsky <drolsky@maxmind.com> |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
This software is copyright (c) 2014 - 2019 by MaxMind, Inc. |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
117
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=cut |