Plugin/Code/Initialization.pm

filter: Statementstmt 100% 32 / 32 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod n/a totaltotal 100% 40 / 40 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« Plugin/Code.pm ↑ Summary
1 # vim: ts=4 sts=4 sw=4 et: syntax=perl
2 #
3 # Copyright (c) 2020-2023 Sven Kirmess
4 #
5 # Permission to use, copy, modify, and distribute this software for any
6 # purpose with or without fee is hereby granted, provided that the above
7 # copyright notice and this permission notice appear in all copies.
8 #
9 # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16  
17 2 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 package Dist::Zilla::Plugin::Code::Initialization;
22  
23 2 our $VERSION = '0.008';
24  
25 2 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
26 2 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
27  
28 2 with 'Dist::Zilla::Role::Plugin';
29  
30 2 ▶use Config::MVP 2.200012 (); # https://github.com/rjbs/Config-MVP/issues/13
Subroutine BEGIN: called CC=1 SCAR=0.0
31 2 ▶use MooseX::Types::Moose qw(CodeRef);
Subroutine BEGIN: called CC=1 SCAR=0.0
32  
33 2 has initialization => (
34 is => 'ro',
35 isa => 'CodeRef',
36 reader => '_initialization',
37 required => 1,
38 );
39  
40 3 ▶around plugin_from_config => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
41 3 my $orig = shift @_;
42 3 my $plugin_class = shift @_;
43  
44 3 my $instance = $plugin_class->$orig(@_);
45  
46 2 my $code_ref = $instance->_initialization;
47 2 $instance->$code_ref(@_);
48  
49 2 return $instance;
50 2 };
51  
52 2 __PACKAGE__->meta->make_immutable;
53  
54 2 1;
55  
56 __END__
« Plugin/Code.pm ↑ Summary