File Coverage

blib/lib/Dist/Zilla/MVP/Assembler.pm
Criterion Covered Total %
statement 16 16 100.0
branch 2 2 100.0
condition 2 3 66.6
subroutine 6 6 100.0
pod 1 2 50.0
total 27 29 93.1


line stmt bran cond sub pod time code
1             package Dist::Zilla::MVP::Assembler 6.030;
2             # ABSTRACT: Dist::Zilla-specific subclass of Config::MVP::Assembler
3              
4 50     50   2833 use Moose;
  50         156  
  50         483  
5             extends 'Config::MVP::Assembler';
6             with 'Config::MVP::Assembler::WithBundles' => { -version => '2.200010' };
7              
8 50     50   361462 use Dist::Zilla::Pragmas;
  50         176  
  50         391  
9              
10 50     50   477 use namespace::autoclean;
  50         189  
  50         417  
11              
12 50     50   4116 use Dist::Zilla::Util;
  50         155  
  50         23037  
13              
14             #pod =head1 DESCRIPTION
15             #pod
16             #pod B<Take this next bit seriously!> If you don't understand how L<Config::MVP>
17             #pod works, reading about how the Dist::Zilla-specific Assembler works is not going
18             #pod to be useful.
19             #pod
20             #pod Dist::Zilla::MVP::Assembler extends L<Config::MVP::Assembler> and composes
21             #pod L<Config::MVP::Assembler::WithBundles>. For potential plugin bundles (things
22             #pod composing L<Dist::Zilla::Role::PluginBundle>)
23             #pod
24             #pod The Assembler has chrome, so it can log and will (eventually) be able to get
25             #pod input from the user.
26             #pod
27             #pod The Assembler's C<expand_package> method delegates to Dist::Zilla::Util's
28             #pod L<expand_config_package_name|Dist::Zilla::Util/expand_config_package_name>
29             #pod method.
30             #pod
31             #pod The Assembler will throw an exception if it is instructed to add a value for
32             #pod C<plugin_name> or C<zilla>.
33             #pod
34             #pod =cut
35              
36             has chrome => (
37             is => 'rw',
38             does => 'Dist::Zilla::Role::Chrome',
39             required => 1,
40             );
41              
42             has logger => (
43             is => 'ro',
44             isa => 'Log::Dispatchouli::Proxy', # could be duck typed, I guess
45             lazy => 1,
46             handles => [ qw(log log_debug log_fatal) ],
47             default => sub {
48             $_[0]->chrome->logger->proxy({ proxy_prefix => '[DZ] ' })
49             },
50             );
51              
52             sub expand_package {
53 628     628 1 171308 return scalar Dist::Zilla::Util->expand_config_package_name($_[1]);
54             }
55              
56             sub package_bundle_method {
57 768     768 0 148008 my ($self, $pkg) = @_;
58 768 100 66     8283 return unless $pkg->isa('Moose::Object')
59             and $pkg->does('Dist::Zilla::Role::PluginBundle');
60 10         3787 return 'bundle_config';
61             }
62              
63             before add_value => sub {
64             my ($self, $name) = @_;
65              
66             return unless $name =~ /\A(?:plugin_name|zilla)\z/;
67              
68             my $section_name = $self->current_section->name;
69             $self->log_fatal(
70             "$section_name arguments attempted to provide reserved argument $name"
71             );
72             };
73              
74             __PACKAGE__->meta->make_immutable;
75             1;
76              
77             __END__
78              
79             =pod
80              
81             =encoding UTF-8
82              
83             =head1 NAME
84              
85             Dist::Zilla::MVP::Assembler - Dist::Zilla-specific subclass of Config::MVP::Assembler
86              
87             =head1 VERSION
88              
89             version 6.030
90              
91             =head1 DESCRIPTION
92              
93             B<Take this next bit seriously!> If you don't understand how L<Config::MVP>
94             works, reading about how the Dist::Zilla-specific Assembler works is not going
95             to be useful.
96              
97             Dist::Zilla::MVP::Assembler extends L<Config::MVP::Assembler> and composes
98             L<Config::MVP::Assembler::WithBundles>. For potential plugin bundles (things
99             composing L<Dist::Zilla::Role::PluginBundle>)
100              
101             The Assembler has chrome, so it can log and will (eventually) be able to get
102             input from the user.
103              
104             The Assembler's C<expand_package> method delegates to Dist::Zilla::Util's
105             L<expand_config_package_name|Dist::Zilla::Util/expand_config_package_name>
106             method.
107              
108             The Assembler will throw an exception if it is instructed to add a value for
109             C<plugin_name> or C<zilla>.
110              
111             =head1 PERL VERSION
112              
113             This module should work on any version of perl still receiving updates from
114             the Perl 5 Porters. This means it should work on any version of perl released
115             in the last two to three years. (That is, if the most recently released
116             version is v5.40, then this module should work on both v5.40 and v5.38.)
117              
118             Although it may work on older versions of perl, no guarantee is made that the
119             minimum required version will not be increased. The version may be increased
120             for any reason, and there is no promise that patches will be accepted to lower
121             the minimum required perl.
122              
123             =head1 AUTHOR
124              
125             Ricardo SIGNES 😏 <cpan@semiotic.systems>
126              
127             =head1 COPYRIGHT AND LICENSE
128              
129             This software is copyright (c) 2023 by Ricardo SIGNES.
130              
131             This is free software; you can redistribute it and/or modify it under
132             the same terms as the Perl 5 programming language system itself.
133              
134             =cut