File Coverage

blib/lib/Beam/Make/Recipe.pm
Criterion Covered Total %
statement 14 14 100.0
branch n/a
condition n/a
subroutine 5 5 100.0
pod n/a
total 19 19 100.0


line stmt bran cond sub pod time code
1             package Beam::Make::Recipe;
2             our $VERSION = '0.001';
3             # ABSTRACT: The base class for Beam::Make recipes
4              
5             #pod =head1 SYNOPSIS
6             #pod
7             #pod package My::Recipe;
8             #pod use v5.20;
9             #pod use Moo;
10             #pod use experimental qw( signatures );
11             #pod extends 'Beam::Make::Recipe';
12             #pod
13             #pod # Make the recipe
14             #pod sub make( $self ) {
15             #pod ...;
16             #pod }
17             #pod
18             #pod # Return a Time::Piece object for when this recipe was last
19             #pod # performed, or 0 if it can't be determined.
20             #pod sub last_modified( $self ) {
21             #pod ...;
22             #pod }
23             #pod
24             #pod =head1 DESCRIPTION
25             #pod
26             #pod This is the base L<Beam::Make> recipe class. Extend this to build your
27             #pod own recipe components.
28             #pod
29             #pod =head1 REQUIRED METHODS
30             #pod
31             #pod =head2 make
32             #pod
33             #pod This method performs the work of the recipe. There is no return value.
34             #pod
35             #pod =head2 last_modified
36             #pod
37             #pod This method returns a L<Time::Piece> object for when this recipe was last
38             #pod performed, or C<0> otherwise. This method could use the L</cache> object
39             #pod to read a cached date. See L<Beam::Make::Cache> for more information.
40             #pod
41             #pod =head1 SEE ALSO
42             #pod
43             #pod L<Beam::Make>
44             #pod
45             #pod =cut
46              
47 2     2   966 use v5.20;
  2         9  
48 2     2   12 use warnings;
  2         4  
  2         70  
49 2     2   12 use Moo;
  2         4  
  2         25  
50 2     2   761 use Time::Piece;
  2         8  
  2         31  
51 2     2   159 use experimental qw( signatures postderef );
  2         35  
  2         12  
52              
53             #pod =attr name
54             #pod
55             #pod The name of the recipe. This is the key in the C<Beamfile> used to refer
56             #pod to this recipe.
57             #pod
58             #pod =cut
59              
60             has name => ( is => 'ro', required => 1 );
61              
62             #pod =attr requires
63             #pod
64             #pod An array of recipe names that this recipe depends on.
65             #pod
66             #pod =cut
67              
68             has requires => ( is => 'ro', default => sub { [] } );
69              
70             #pod =attr cache
71             #pod
72             #pod A L<Beam::Make::Cache> object. This is used to store content hashes and
73             #pod modified dates for later use.
74             #pod
75             #pod =cut
76              
77             has cache => ( is => 'ro', required => 1 );
78              
79             1;
80              
81             __END__
82              
83             =pod
84              
85             =head1 NAME
86              
87             Beam::Make::Recipe - The base class for Beam::Make recipes
88              
89             =head1 VERSION
90              
91             version 0.001
92              
93             =head1 SYNOPSIS
94              
95             package My::Recipe;
96             use v5.20;
97             use Moo;
98             use experimental qw( signatures );
99             extends 'Beam::Make::Recipe';
100              
101             # Make the recipe
102             sub make( $self ) {
103             ...;
104             }
105              
106             # Return a Time::Piece object for when this recipe was last
107             # performed, or 0 if it can't be determined.
108             sub last_modified( $self ) {
109             ...;
110             }
111              
112             =head1 DESCRIPTION
113              
114             This is the base L<Beam::Make> recipe class. Extend this to build your
115             own recipe components.
116              
117             =head1 ATTRIBUTES
118              
119             =head2 name
120              
121             The name of the recipe. This is the key in the C<Beamfile> used to refer
122             to this recipe.
123              
124             =head2 requires
125              
126             An array of recipe names that this recipe depends on.
127              
128             =head2 cache
129              
130             A L<Beam::Make::Cache> object. This is used to store content hashes and
131             modified dates for later use.
132              
133             =head1 REQUIRED METHODS
134              
135             =head2 make
136              
137             This method performs the work of the recipe. There is no return value.
138              
139             =head2 last_modified
140              
141             This method returns a L<Time::Piece> object for when this recipe was last
142             performed, or C<0> otherwise. This method could use the L</cache> object
143             to read a cached date. See L<Beam::Make::Cache> for more information.
144              
145             =head1 SEE ALSO
146              
147             L<Beam::Make>
148              
149             =head1 AUTHOR
150              
151             Doug Bell <preaction@cpan.org>
152              
153             =head1 COPYRIGHT AND LICENSE
154              
155             This software is copyright (c) 2020 by Doug Bell.
156              
157             This is free software; you can redistribute it and/or modify it under
158             the same terms as the Perl 5 programming language system itself.
159              
160             =cut