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.029;
2             # ABSTRACT: a standard section in Dist::Zilla's configuration sequence
3              
4 50     50   1557 use Moose;
  50         178  
  50         427  
5             extends 'Config::MVP::Section';
6              
7 50     50   326196 use Dist::Zilla::Pragmas;
  50         155  
  50         381  
8              
9 50     50   464 use namespace::autoclean;
  50         218  
  50         379  
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   31372 use MooseX::LazyRequire;
  50         546788  
  50         345  
28 50     50   585841 use MooseX::SetOnce;
  50         156  
  50         1498  
29 50     50   527 use Moose::Util::TypeConstraints;
  50         143  
  50         611  
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.029
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 released
113             in the last two to three years. (That is, if the most recently released
114             version is v5.40, then this module should work on both v5.40 and v5.38.)
115              
116             Although it may work on older versions of perl, no guarantee is made that the
117             minimum required version will not be increased. The version may be increased
118             for any reason, and there is no promise that patches will be accepted to lower
119             the minimum required perl.
120              
121             =head1 AUTHOR
122              
123             Ricardo SIGNES 😏 <cpan@semiotic.systems>
124              
125             =head1 COPYRIGHT AND LICENSE
126              
127             This software is copyright (c) 2022 by Ricardo SIGNES.
128              
129             This is free software; you can redistribute it and/or modify it under
130             the same terms as the Perl 5 programming language system itself.
131              
132             =cut