File Coverage

blib/lib/Dist/Zilla/Plugin/InlineFiles.pm
Criterion Covered Total %
statement 25 25 100.0
branch 1 2 50.0
condition 1 3 33.3
subroutine 7 7 100.0
pod 0 1 0.0
total 34 38 89.4


line stmt bran cond sub pod time code
1             # ABSTRACT: files in a data section
2              
3             use Moose;
4 12     12   15923 with 'Dist::Zilla::Role::FileGatherer';
  12         37  
  12         81  
5              
6             use Dist::Zilla::Pragmas;
7 12     12   75425  
  12         34  
  12         86  
8             use namespace::autoclean;
9 12     12   101  
  12         32  
  12         80  
10             #pod =head1 DESCRIPTION
11             #pod
12             #pod This plugin exists only to be extended, and gathers all files contained in its
13             #pod data section and those of its ancestors. For more information, see
14             #pod L<Data::Section|Data::Section>.
15             #pod
16             #pod =cut
17              
18             use Sub::Exporter::ForMethods;
19 12     12   911 use Data::Section 0.200002 # encoding and bytes
  12         35  
  12         182  
20             { installer => Sub::Exporter::ForMethods::method_installer },
21 12         87 '-setup' => { encoding => 'bytes' };
22 12     12   2746 use Dist::Zilla::File::InMemory;
  12         392  
23 12     12   13709  
  12         38  
  12         2593  
24             my ($self) = @_;
25              
26 23     23 0 72 my $data = $self->merged_section_data;
27             return unless $data and %$data;
28 23         153  
29 23 50 33     4806 for my $name (keys %$data) {
30             $self->add_file(
31 23         92 Dist::Zilla::File::InMemory->new({
32             name => $name,
33             content => ${ $data->{$name} },
34             }),
35 25         59 );
  25         898  
36             }
37              
38             return;
39             }
40 23         208  
41             __PACKAGE__->meta->make_immutable;
42             1;
43              
44             #pod =head1 SEE ALSO
45             #pod
46             #pod Core Dist::Zilla plugins inheriting from L<InlineFiles>:
47             #pod L<MetaTests|Dist::Zilla::Plugin::MetaTests>,
48             #pod L<PodCoverageTests|Dist::Zilla::Plugin::PodCoverageTests>,
49             #pod L<PodSyntaxTests|Dist::Zilla::Plugin::PodSyntaxTests>.
50             #pod
51             #pod =cut
52              
53              
54             =pod
55              
56             =encoding UTF-8
57              
58             =head1 NAME
59              
60             Dist::Zilla::Plugin::InlineFiles - files in a data section
61              
62             =head1 VERSION
63              
64             version 6.028
65              
66             =head1 DESCRIPTION
67              
68             This plugin exists only to be extended, and gathers all files contained in its
69             data section and those of its ancestors. For more information, see
70             L<Data::Section|Data::Section>.
71              
72             =head1 PERL VERSION
73              
74             This module should work on any version of perl still receiving updates from
75             the Perl 5 Porters. This means it should work on any version of perl released
76             in the last two to three years. (That is, if the most recently released
77             version is v5.40, then this module should work on both v5.40 and v5.38.)
78              
79             Although it may work on older versions of perl, no guarantee is made that the
80             minimum required version will not be increased. The version may be increased
81             for any reason, and there is no promise that patches will be accepted to lower
82             the minimum required perl.
83              
84             =head1 SEE ALSO
85              
86             Core Dist::Zilla plugins inheriting from L<InlineFiles>:
87             L<MetaTests|Dist::Zilla::Plugin::MetaTests>,
88             L<PodCoverageTests|Dist::Zilla::Plugin::PodCoverageTests>,
89             L<PodSyntaxTests|Dist::Zilla::Plugin::PodSyntaxTests>.
90              
91             =head1 AUTHOR
92              
93             Ricardo SIGNES 😏 <cpan@semiotic.systems>
94              
95             =head1 COPYRIGHT AND LICENSE
96              
97             This software is copyright (c) 2022 by Ricardo SIGNES.
98              
99             This is free software; you can redistribute it and/or modify it under
100             the same terms as the Perl 5 programming language system itself.
101              
102             =cut