| 1 | ## no critic (ControlStructures::ProhibitPostfixControls) | ||||||||||||
| 2 | package Dist::Zilla::Plugin::Software::Policies; | ||||||||||||
| 3 | |||||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 5 | 1 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 6 | 1 | ▶ | use 5.010; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 7 | 1 | ▶ | use feature qw( say ); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 8 | |||||||||||||
| 9 | # ABSTRACT: Create project policy files | ||||||||||||
| 10 | |||||||||||||
| 11 | 1 | our $VERSION = '0.002'; | |||||||||||
| 12 | |||||||||||||
| 13 | 1 | ▶ | use Moose; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 14 | 1 | with 'Dist::Zilla::Role::Plugin'; | |||||||||||
| 15 | 1 | ▶ | use Dist::Zilla::Pragmas; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 16 | 1 | ▶ | use namespace::autoclean; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 17 | |||||||||||||
| 18 | 1 | has class => ( | |||||||||||
| 19 | is => 'ro', | ||||||||||||
| 20 | isa => 'Str', | ||||||||||||
| 21 | ); | ||||||||||||
| 22 | |||||||||||||
| 23 | 1 | has version => ( | |||||||||||
| 24 | is => 'ro', | ||||||||||||
| 25 | isa => 'Str', | ||||||||||||
| 26 | ); | ||||||||||||
| 27 | |||||||||||||
| 28 | 1 | has format => ( | |||||||||||
| 29 | is => 'ro', | ||||||||||||
| 30 | isa => 'Str', | ||||||||||||
| 31 | ); | ||||||||||||
| 32 | |||||||||||||
| 33 | has policy_attribute => ( | ||||||||||||
| 34 | is => 'ro', | ||||||||||||
| 35 | isa => 'HashRef', | ||||||||||||
| 36 | 0 | ▶ | default => sub { {} }, | ||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||
| 37 | 1 | ); | |||||||||||
| 38 | |||||||||||||
| 39 | 1 | has dir => ( | |||||||||||
| 40 | is => 'ro', | ||||||||||||
| 41 | isa => 'Str', | ||||||||||||
| 42 | ); | ||||||||||||
| 43 | |||||||||||||
| 44 | 1 | has filename => ( | |||||||||||
| 45 | is => 'ro', | ||||||||||||
| 46 | isa => 'Str', | ||||||||||||
| 47 | ); | ||||||||||||
| 48 | |||||||||||||
| 49 | 0 | ▶ | sub mvp_multivalue_args { return qw( policy_attribute ) } | ||||||||||
|
Subroutine
mvp_multivalue_args: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||
| 50 | |||||||||||||
| 51 | 0 | ▶ | sub register_prereqs { | ||||||||||
|
Subroutine
register_prereqs: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||
| 52 | 0 | my $self = shift; | |||||||||||
| 53 | 0 | $self->zilla->register_prereqs( | |||||||||||
| 54 | { | ||||||||||||
| 55 | type => 'requires', | ||||||||||||
| 56 | phase => 'develop', | ||||||||||||
| 57 | }, | ||||||||||||
| 58 | 'Dist::Zilla::App::Command::policies' => 0, | ||||||||||||
| 59 | ); | ||||||||||||
| 60 | |||||||||||||
| 61 | 0 | return $self->zilla->register_prereqs( | |||||||||||
| 62 | { | ||||||||||||
| 63 | type => 'requires', | ||||||||||||
| 64 | phase => 'develop', | ||||||||||||
| 65 | }, | ||||||||||||
| 66 | 'Software::Policies' => 0, | ||||||||||||
| 67 | ); | ||||||||||||
| 68 | } | ||||||||||||
| 69 | |||||||||||||
| 70 | # If there is no / Policy definition in [Software::Policies] | ||||||||||||
| 71 | # Leave plugin_name Software::Policies | ||||||||||||
| 72 | |||||||||||||
| 73 | 0 | ▶ | around BUILDARGS => sub { | ||||||||||
|
Subroutine
__ANON__: not called CC=5 SCAR=34.0
| |||||||||||||
| 74 | 0 | my ( $orig, $class, @arg ) = @_; | |||||||||||
| 75 | 0 | my $args = $class->$orig(@arg); | |||||||||||
| 76 | 0 | my %copy = %{$args}; | |||||||||||
| 77 | 0 | my $zilla = delete $copy{zilla}; | |||||||||||
| 78 | 0 | my $name = delete $copy{plugin_name}; | |||||||||||
| 79 | 0 | my %other; | |||||||||||
| 80 | 0 | ▶ | my %attributes = map { split qr/\s*=\s*/msx, $_, 2 } @{ delete $copy{policy_attribute} // [] }; | ||||||||||
|
Condition0%0/2
delete $copy{"policy_attribute"} // []
MC/DC0%0/1
delete $copy{"policy_attribute"} // []
delete $copy{"policy_attribute"}
Truth table0%0/2
A
A= delete $copy{"policy_attribute"}
| |||||||||||||
| 81 | |||||||||||||
| 82 | # $other{'class'} = delete $copy{class} if $copy{class}; | ||||||||||||
| 83 | # $other{'version'} = delete $copy{version} if $copy{version}; | ||||||||||||
| 84 | # $other{'format'} = delete $copy{format} if $copy{format}; | ||||||||||||
| 85 | # $other{'dir'} = delete $copy{dir} if $copy{dir}; | ||||||||||||
| 86 | # $other{'filename'} = delete $copy{filename} if $copy{filename}; | ||||||||||||
| 87 | 0 | for my $key (qw( class version format dir filename )) { | |||||||||||
| 88 | 0 | ▶ | $other{$key} = delete $copy{$key} if $copy{$key}; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 89 | } | ||||||||||||
| 90 | 0 | $other{'policy_attribute'} = \%attributes; | |||||||||||
| 91 | 0 | $zilla->log_debug( [ 'Policy %s. Collected attributes: %s', $name, \%attributes ] ); | |||||||||||
| 92 | 0 | ▶ | if (%copy) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 93 | 0 | $zilla->log_fatal( | |||||||||||
| 94 | [ 'Unknown configuration option(s) in %s: %s', ( __PACKAGE__ . q{ / } . $name ), ( join q{,}, keys %copy ) ] ); | ||||||||||||
| 95 | } | ||||||||||||
| 96 | return { | ||||||||||||
| 97 | 0 | zilla => $zilla, | |||||||||||
| 98 | plugin_name => $name, | ||||||||||||
| 99 | |||||||||||||
| 100 | # _prereq => \%copy, | ||||||||||||
| 101 | %other, | ||||||||||||
| 102 | }; | ||||||||||||
| 103 | 1 | }; | |||||||||||
| 104 | |||||||||||||
| 105 | 1 | ▶ | no Moose; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 106 | 1 | __PACKAGE__->meta->make_immutable; | |||||||||||
| 107 | 1 | 1; | |||||||||||
| 108 | |||||||||||||
| 109 | __END__ | ||||||||||||