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