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.037;
2             # ABSTRACT: something that can add files to the distribution
3              
4 46     46   34546 use Moose::Role;
  46         141  
  46         413  
5              
6 46     46   275112 use Dist::Zilla::Pragmas;
  46         110  
  46         409  
7              
8 46     46   378 use namespace::autoclean;
  46         127  
  46         444  
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 6294 my ($self, $file) = @_;
27 781         2763 my ($pkg, undef, $line) = caller;
28              
29 781         27579 $file->_set_added_by(
30             sprintf("%s (%s line %s)", $self->plugin_name, $pkg, $line),
31             );
32              
33 781         3657 $self->log_debug([ 'adding file %s', $file->name ]);
34 781         48924 push @{ $self->zilla->files }, $file;
  781         27231  
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.037
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
63             released in the last two to three years. (That is, if the most recently
64             released version is v5.40, then this module should work on both v5.40 and
65             v5.38.)
66              
67             Although it may work on older versions of perl, no guarantee is made that the
68             minimum required version will not be increased. The version may be increased
69             for any reason, and there is no promise that patches will be accepted to
70             lower the minimum required perl.
71              
72             =head1 METHODS
73              
74             =head2 add_file
75              
76             $plugin->add_file($dzil_file);
77              
78             This adds a file to the distribution, setting the file's C<added_by> attribute
79             as it does so.
80              
81             =head1 AUTHOR
82              
83             Ricardo SIGNES 😏 <cpan@semiotic.systems>
84              
85             =head1 COPYRIGHT AND LICENSE
86              
87             This software is copyright (c) 2026 by Ricardo SIGNES.
88              
89             This is free software; you can redistribute it and/or modify it under
90             the same terms as the Perl 5 programming language system itself.
91              
92             =cut