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