File Coverage

blib/lib/Dist/Zilla/Role/FileInjector.pm
Criterion Covered Total %
statement 15 15 100.0
branch n/a
condition n/a
subroutine 4 4 100.0
pod 1 1 100.0
total 20 20 100.0


line stmt bran cond sub pod time code
1             package Dist::Zilla::Role::FileInjector 6.030;
2             # ABSTRACT: something that can add files to the distribution
3              
4 46     46   29463 use Moose::Role;
  46         151  
  46         338  
5              
6 46     46   239005 use Dist::Zilla::Pragmas;
  46         134  
  46         342  
7              
8 46     46   430 use namespace::autoclean;
  46         174  
  46         385  
9              
10             #pod =head1 DESCRIPTION
11             #pod
12             #pod This role should be implemented by any plugin that plans to add files into the
13             #pod distribution. It provides one method (C<L</add_file>>, documented below),
14             #pod which adds a file to the distribution, noting the place of addition.
15             #pod
16             #pod =method add_file
17             #pod
18             #pod $plugin->add_file($dzil_file);
19             #pod
20             #pod This adds a file to the distribution, setting the file's C<added_by> attribute
21             #pod as it does so.
22             #pod
23             #pod =cut
24              
25             sub add_file {
26 781     781 1 7494 my ($self, $file) = @_;
27 781         2694 my ($pkg, undef, $line) = caller;
28              
29 781         23220 $file->_set_added_by(
30             sprintf("%s (%s line %s)", $self->plugin_name, $pkg, $line),
31             );
32              
33 781         3686 $self->log_debug([ 'adding file %s', $file->name ]);
34 781         35407 push @{ $self->zilla->files }, $file;
  781         22754  
35             }
36              
37             1;
38              
39             __END__
40              
41             =pod
42              
43             =encoding UTF-8
44              
45             =head1 NAME
46              
47             Dist::Zilla::Role::FileInjector - something that can add files to the distribution
48              
49             =head1 VERSION
50              
51             version 6.030
52              
53             =head1 DESCRIPTION
54              
55             This role should be implemented by any plugin that plans to add files into the
56             distribution. It provides one method (C<L</add_file>>, documented below),
57             which adds a file to the distribution, noting the place of addition.
58              
59             =head1 PERL VERSION
60              
61             This module should work on any version of perl still receiving updates from
62             the Perl 5 Porters. This means it should work on any version of perl released
63             in the last two to three years. (That is, if the most recently released
64             version is v5.40, then this module should work on both v5.40 and v5.38.)
65              
66             Although it may work on older versions of perl, no guarantee is made that the
67             minimum required version will not be increased. The version may be increased
68             for any reason, and there is no promise that patches will be accepted to lower
69             the minimum required perl.
70              
71             =head1 METHODS
72              
73             =head2 add_file
74              
75             $plugin->add_file($dzil_file);
76              
77             This adds a file to the distribution, setting the file's C<added_by> attribute
78             as it does so.
79              
80             =head1 AUTHOR
81              
82             Ricardo SIGNES 😏 <cpan@semiotic.systems>
83              
84             =head1 COPYRIGHT AND LICENSE
85              
86             This software is copyright (c) 2023 by Ricardo SIGNES.
87              
88             This is free software; you can redistribute it and/or modify it under
89             the same terms as the Perl 5 programming language system itself.
90              
91             =cut