File Coverage

blib/lib/Dist/Zilla/File/InMemory.pm
Criterion Covered Total %
statement 9 12 75.0
branch n/a
condition n/a
subroutine 3 6 50.0
pod n/a
total 12 18 66.6


line stmt bran cond sub pod time code
1             package Dist::Zilla::File::InMemory 6.029;
2             # ABSTRACT: a file that you build entirely in memory
3              
4 21     21   2803 use Moose;
  21         897777  
  21         155  
5              
6 21     21   141459 use Dist::Zilla::Pragmas;
  21         60  
  21         154  
7              
8 21     21   195 use namespace::autoclean;
  21         72  
  21         197  
9              
10             #pod =head1 DESCRIPTION
11             #pod
12             #pod This represents a file created in memory -- it's not much more than a glorified
13             #pod string.
14             #pod
15             #pod See L<Dist::Zilla::Role::MutableFile> for details.
16             #pod
17             #pod =cut
18              
19             with 'Dist::Zilla::Role::MutableFile', 'Dist::Zilla::Role::StubBuild';
20              
21             after 'BUILD' => sub {
22             my ($self,$opts) = @_;
23             my @sources = qw/encoded_content content/;
24             my @given = grep { exists $opts->{$_} } @sources;
25             unless ( @given == 1 ) {
26             $self->log_fatal(__PACKAGE__ . " requires have one and only one of: @sources");
27             }
28             my $source = $given[0];
29             my $setter = "_$source";
30             $self->_content_source($source);
31             $self->$setter( $opts->{$source} );
32             };
33              
34             # these should never be called since we ensure one of _content or
35             # _encoded_content content is set in BUILD and set the source accordingly
36              
37 0     0     sub _build_content { die "shouldn't reach here" }
38 0     0     sub _build_encoded_content { die "shouldn't reach here" }
39 0     0     sub _build_content_source { die "shouldn't reach here" }
40              
41             __PACKAGE__->meta->make_immutable;
42             1;
43              
44             __END__
45              
46             =pod
47              
48             =encoding UTF-8
49              
50             =head1 NAME
51              
52             Dist::Zilla::File::InMemory - a file that you build entirely in memory
53              
54             =head1 VERSION
55              
56             version 6.029
57              
58             =head1 DESCRIPTION
59              
60             This represents a file created in memory -- it's not much more than a glorified
61             string.
62              
63             See L<Dist::Zilla::Role::MutableFile> for details.
64              
65             =head1 PERL VERSION
66              
67             This module should work on any version of perl still receiving updates from
68             the Perl 5 Porters. This means it should work on any version of perl released
69             in the last two to three years. (That is, if the most recently released
70             version is v5.40, then this module should work on both v5.40 and v5.38.)
71              
72             Although it may work on older versions of perl, no guarantee is made that the
73             minimum required version will not be increased. The version may be increased
74             for any reason, and there is no promise that patches will be accepted to lower
75             the minimum required perl.
76              
77             =head1 AUTHOR
78              
79             Ricardo SIGNES 😏 <cpan@semiotic.systems>
80              
81             =head1 COPYRIGHT AND LICENSE
82              
83             This software is copyright (c) 2022 by Ricardo SIGNES.
84              
85             This is free software; you can redistribute it and/or modify it under
86             the same terms as the Perl 5 programming language system itself.
87              
88             =cut