File Coverage

blib/lib/Dist/Zilla/MVP/RootSection.pm
Criterion Covered Total %
statement 18 18 100.0
branch n/a
condition n/a
subroutine 6 6 100.0
pod n/a
total 24 24 100.0


line stmt bran cond sub pod time code
1             # ABSTRACT: a standard section in Dist::Zilla's configuration sequence
2              
3             use Moose;
4 50     50   1680 extends 'Config::MVP::Section';
  50         177  
  50         368  
5              
6             use Dist::Zilla::Pragmas;
7 50     50   320959  
  50         144  
  50         367  
8             use namespace::autoclean;
9 50     50   422  
  50         158  
  50         398  
10             #pod =head1 DESCRIPTION
11             #pod
12             #pod This is a subclass of L<Config::MVP::Section>, used as the starting section by
13             #pod L<Dist::Zilla::MVP::Assembler::Zilla>. It has a number of useful defaults, as
14             #pod well as a C<zilla> attribute which will, after section finalization, contain a
15             #pod Dist::Zilla object with which subsequent plugin sections may register.
16             #pod
17             #pod Those useful defaults are:
18             #pod
19             #pod =for :list
20             #pod * name defaults to _
21             #pod * aliases defaults to { author => 'authors' }
22             #pod * multivalue_args defaults to [ 'authors' ]
23             #pod
24             #pod =cut
25              
26             use MooseX::LazyRequire;
27 50     50   30601 use MooseX::SetOnce;
  50         533913  
  50         381  
28 50     50   571294 use Moose::Util::TypeConstraints;
  50         149  
  50         1584  
29 50     50   476  
  50         128  
  50         592  
30             has '+name' => (default => '_');
31              
32             has '+aliases' => (default => sub { return { author => 'authors' } });
33              
34             has '+multivalue_args' => (default => sub { [ qw(authors) ] });
35              
36             has zilla => (
37             is => 'ro',
38             isa => class_type('Dist::Zilla'),
39             traits => [ qw(SetOnce) ],
40             writer => 'set_zilla',
41             lazy_required => 1,
42             );
43              
44             after finalize => sub {
45             my ($self) = @_;
46              
47             my $assembler = $self->sequence->assembler;
48              
49             my %payload = %{ $self->payload };
50              
51             my %dzil;
52             $dzil{$_} = delete $payload{":$_"} for grep { s/\A:// } keys %payload;
53              
54             my $zilla = $assembler->zilla_class->new( \%payload );
55              
56             if (defined $dzil{version}) {
57             Dist::Zilla::Util->_assert_loaded_class_version_ok(
58             'Dist::Zilla',
59             $dzil{version},
60             );
61             }
62              
63             $self->set_zilla($zilla);
64             };
65              
66             __PACKAGE__->meta->make_immutable;
67             1;
68              
69              
70             =pod
71              
72             =encoding UTF-8
73              
74             =head1 NAME
75              
76             Dist::Zilla::MVP::RootSection - a standard section in Dist::Zilla's configuration sequence
77              
78             =head1 VERSION
79              
80             version 6.028
81              
82             =head1 DESCRIPTION
83              
84             This is a subclass of L<Config::MVP::Section>, used as the starting section by
85             L<Dist::Zilla::MVP::Assembler::Zilla>. It has a number of useful defaults, as
86             well as a C<zilla> attribute which will, after section finalization, contain a
87             Dist::Zilla object with which subsequent plugin sections may register.
88              
89             Those useful defaults are:
90              
91             =over 4
92              
93             =item *
94              
95             name defaults to _
96              
97             =item *
98              
99             aliases defaults to { author => 'authors' }
100              
101             =item *
102              
103             multivalue_args defaults to [ 'authors' ]
104              
105             =back
106              
107             =head1 PERL VERSION
108              
109             This module should work on any version of perl still receiving updates from
110             the Perl 5 Porters. This means it should work on any version of perl released
111             in the last two to three years. (That is, if the most recently released
112             version is v5.40, then this module should work on both v5.40 and v5.38.)
113              
114             Although it may work on older versions of perl, no guarantee is made that the
115             minimum required version will not be increased. The version may be increased
116             for any reason, and there is no promise that patches will be accepted to lower
117             the minimum required perl.
118              
119             =head1 AUTHOR
120              
121             Ricardo SIGNES 😏 <cpan@semiotic.systems>
122              
123             =head1 COPYRIGHT AND LICENSE
124              
125             This software is copyright (c) 2022 by Ricardo SIGNES.
126              
127             This is free software; you can redistribute it and/or modify it under
128             the same terms as the Perl 5 programming language system itself.
129              
130             =cut