File Coverage

blib/lib/Dist/Zilla/MVP/Assembler/GlobalConfig.pm
Criterion Covered Total %
statement 13 13 100.0
branch 1 2 50.0
condition n/a
subroutine 4 4 100.0
pod 1 1 100.0
total 19 20 95.0


line stmt bran cond sub pod time code
1             package Dist::Zilla::MVP::Assembler::GlobalConfig 6.029;
2             # ABSTRACT: Dist::Zilla::MVP::Assembler for global configuration
3              
4 2     2   940 use Moose;
  2         5  
  2         18  
5             extends 'Dist::Zilla::MVP::Assembler';
6              
7 2     2   14279 use Dist::Zilla::Pragmas;
  2         6  
  2         16  
8              
9 2     2   17 use namespace::autoclean;
  2         4  
  2         18  
10              
11             #pod =head1 OVERVIEW
12             #pod
13             #pod This is a subclass of L<Dist::Zilla::MVP::Assembler> used when assembling the
14             #pod global configuration. It has a C<stash_registry> attribute, a hashref, into
15             #pod which stashes will be registered.
16             #pod
17             #pod They get registered via the C<register_stash> method, below, generally called
18             #pod by the C<register_component> method on L<Dist::Zilla::Role::Stash>-performing
19             #pod class.
20             #pod
21             #pod =cut
22              
23             has stash_registry => (
24             is => 'ro',
25             isa => 'HashRef[Object]',
26             default => sub { {} },
27             );
28              
29             #pod =method register_stash
30             #pod
31             #pod $assembler->register_stash($name => $stash_object);
32             #pod
33             #pod This adds a stash to the assembler's stash registry -- unless the name is
34             #pod already taken, in which case an exception is raised.
35             #pod
36             #pod =cut
37              
38             sub register_stash {
39 2     2 1 327 my ($self, $name, $object) = @_;
40              
41             # $self->log_fatal("tried to register $name stash entry twice")
42             confess("tried to register $name stash entry twice")
43 2 50       71 if $self->stash_registry->{ $name };
44              
45 2         68 $self->stash_registry->{ $name } = $object;
46 2         6 return;
47             }
48              
49             __PACKAGE__->meta->make_immutable;
50             1;
51              
52             __END__
53              
54             =pod
55              
56             =encoding UTF-8
57              
58             =head1 NAME
59              
60             Dist::Zilla::MVP::Assembler::GlobalConfig - Dist::Zilla::MVP::Assembler for global configuration
61              
62             =head1 VERSION
63              
64             version 6.029
65              
66             =head1 OVERVIEW
67              
68             This is a subclass of L<Dist::Zilla::MVP::Assembler> used when assembling the
69             global configuration. It has a C<stash_registry> attribute, a hashref, into
70             which stashes will be registered.
71              
72             They get registered via the C<register_stash> method, below, generally called
73             by the C<register_component> method on L<Dist::Zilla::Role::Stash>-performing
74             class.
75              
76             =head1 PERL VERSION
77              
78             This module should work on any version of perl still receiving updates from
79             the Perl 5 Porters. This means it should work on any version of perl released
80             in the last two to three years. (That is, if the most recently released
81             version is v5.40, then this module should work on both v5.40 and v5.38.)
82              
83             Although it may work on older versions of perl, no guarantee is made that the
84             minimum required version will not be increased. The version may be increased
85             for any reason, and there is no promise that patches will be accepted to lower
86             the minimum required perl.
87              
88             =head1 METHODS
89              
90             =head2 register_stash
91              
92             $assembler->register_stash($name => $stash_object);
93              
94             This adds a stash to the assembler's stash registry -- unless the name is
95             already taken, in which case an exception is raised.
96              
97             =head1 AUTHOR
98              
99             Ricardo SIGNES 😏 <cpan@semiotic.systems>
100              
101             =head1 COPYRIGHT AND LICENSE
102              
103             This software is copyright (c) 2022 by Ricardo SIGNES.
104              
105             This is free software; you can redistribute it and/or modify it under
106             the same terms as the Perl 5 programming language system itself.
107              
108             =cut