| 1 | package Software::Policies::MaintainerSuccession::Basic; | ||||||||||||
| 2 | ## no critic (ControlStructures::ProhibitPostfixControls) | ||||||||||||
| 3 | |||||||||||||
| 4 | 2 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 5 | 2 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 6 | 2 | ▶ | use 5.010; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 7 | |||||||||||||
| 8 | # ABSTRACT: Create project policy file: MaintainerSuccession / Basic | ||||||||||||
| 9 | |||||||||||||
| 10 | 2 | our $VERSION = '0.006'; | |||||||||||
| 11 | |||||||||||||
| 12 | 2 | ▶ | use Carp; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 13 | 2 | ▶ | use Data::Section -setup; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 14 | 2 | ▶ | use Text::Template (); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 15 | |||||||||||||
| 16 | 2 | ▶ | sub new { | ||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 17 | 2 | my ($class) = @_; | |||||||||||
| 18 | 2 | return bless {}, $class; | |||||||||||
| 19 | } | ||||||||||||
| 20 | |||||||||||||
| 21 | 2 | ▶ | sub create { | ||||||||||
|
Subroutine
create: called CC=10 SCAR=23.3
Pod
documented
| |||||||||||||
| 22 | 2 | my ( $self, %args ) = @_; | |||||||||||
| 23 | 2 | ▶ | my $version = delete $args{'version'} // '1'; | ||||||||||
|
Condition50%1/2
delete $args{"version"} // 1
MC/DC0%0/1
delete $args{"version"} // 1
delete $args{"version"}
Truth table50%1/2
A
A= delete $args{"version"}
| |||||||||||||
| 24 | 2 | ▶ | my $format = delete $args{'format'} // 'markdown'; | ||||||||||
|
Condition50%1/2
delete $args{"format"} // "markdown"
MC/DC0%0/1
delete $args{"format"} // "markdown"
delete $args{"format"}
Truth table50%1/2
A
A= delete $args{"format"}
| |||||||||||||
| 25 | |||||||||||||
| 26 | 2 | my %attributes; | |||||||||||
| 27 | 2 | ▶ | my $attrs = delete $args{'attributes'} // {}; | ||||||||||
|
Condition50%1/2
delete $args{"attributes"} // {}
MC/DC0%0/1
delete $args{"attributes"} // {}
delete $args{"attributes"}
Truth table50%1/2
A
A= delete $args{"attributes"}
| |||||||||||||
| 28 | 2 | ▶ | croak q{Unknown arguments: }, join q{,}, keys %args if (%args); | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 29 | |||||||||||||
| 30 | 2 | foreach (qw( authors )) { | |||||||||||
| 31 | 2 | $attributes{$_} = $attrs->{$_}; | |||||||||||
| 32 | } | ||||||||||||
| 33 | |||||||||||||
| 34 | # N.B. We do not check for unknown attributes because: | ||||||||||||
| 35 | # 1. Dist::Zilla passes most of attributes | ||||||||||||
| 36 | # 2. User can have his own classes or versions | ||||||||||||
| 37 | |||||||||||||
| 38 | 2 | my @missing_attributes; | |||||||||||
| 39 | 2 | foreach (qw( authors )) { | |||||||||||
| 40 | 2 | ▶ | push @missing_attributes, $_ if ( !defined $attributes{$_} ); | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 41 | } | ||||||||||||
| 42 | 2 | ▶ | croak q{Missing attributes: } . join q{,}, @missing_attributes | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 43 | if (@missing_attributes); | ||||||||||||
| 44 | |||||||||||||
| 45 | 1 | $attributes{'contact'} = $attributes{'authors'}->[0]; | |||||||||||
| 46 | 1 | delete $attributes{'authors'}; | |||||||||||
| 47 | 1 | $attributes{'tools'} = delete $attributes{'ai_tools'}; | |||||||||||
| 48 | |||||||||||||
| 49 | 1 | my ($data_section) = __PACKAGE__ =~ m/.+::([^:]+)$/msx; | |||||||||||
| 50 | 1 | my $data_section_label = $data_section . q{_v} . $version . q{_} . $format; | |||||||||||
| 51 | 1 | my $template = $self->section_data($data_section_label); | |||||||||||
| 52 | 1 | ▶ | croak "Cannot find data section $data_section_label" | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 53 | if ( !$template ); | ||||||||||||
| 54 | my $text = Text::Template->fill_this_in( | ||||||||||||
| 55 | 1 | ${$template}, | |||||||||||
| 56 | HASH => \%attributes, | ||||||||||||
| 57 | DELIMITERS => [qw/{{ }}/], | ||||||||||||
| 58 | ); | ||||||||||||
| 59 | return ( | ||||||||||||
| 60 | 1 | policy => 'MaintainerSuccession', | |||||||||||
| 61 | class => 'Basic', | ||||||||||||
| 62 | version => $version, | ||||||||||||
| 63 | text => $text, | ||||||||||||
| 64 | filename => _filename($format), | ||||||||||||
| 65 | format => $format, | ||||||||||||
| 66 | ); | ||||||||||||
| 67 | } | ||||||||||||
| 68 | |||||||||||||
| 69 | 0 | ▶ | sub get_available_classes_and_versions { | ||||||||||
|
Subroutine
get_available_classes_and_versions: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||
| 70 | return { | ||||||||||||
| 71 | 0 | 'Basic' => { | |||||||||||
| 72 | versions => { | ||||||||||||
| 73 | '1' => 1, | ||||||||||||
| 74 | }, | ||||||||||||
| 75 | formats => { | ||||||||||||
| 76 | 'markdown' => 1, | ||||||||||||
| 77 | 'pod' => 1, | ||||||||||||
| 78 | }, | ||||||||||||
| 79 | }, | ||||||||||||
| 80 | }; | ||||||||||||
| 81 | } | ||||||||||||
| 82 | |||||||||||||
| 83 | 1 | ▶ | sub _filename { | ||||||||||
|
Subroutine
_filename: called CC=1 SCAR=0.0
| |||||||||||||
| 84 | 1 | my ($format) = @_; | |||||||||||
| 85 | 1 | my %formats = ( | |||||||||||
| 86 | 'markdown' => 'MAINTAINER_SUCCESSION.md', | ||||||||||||
| 87 | 'pod' => 'MAINTAINER_SUCCESSION.pod' | ||||||||||||
| 88 | ); | ||||||||||||
| 89 | 1 | return $formats{$format}; | |||||||||||
| 90 | } | ||||||||||||
| 91 | |||||||||||||
| 92 | 2 | 1; | |||||||||||
| 93 | |||||||||||||
| 94 | =pod | ||||||||||||
| 95 | |||||||||||||
| 96 | =encoding UTF-8 | ||||||||||||
| 97 | |||||||||||||
| 98 | =head1 NAME | ||||||||||||
| 99 | |||||||||||||
| 100 | Software::Policies::MaintainerSuccession::Basic - Create project policy file: MaintainerSuccession / Basic | ||||||||||||
| 101 | |||||||||||||
| 102 | =head1 VERSION | ||||||||||||
| 103 | |||||||||||||
| 104 | version 0.006 | ||||||||||||
| 105 | |||||||||||||
| 106 | =for Pod::Coverage new create get_available_classes_and_versions | ||||||||||||
| 107 | |||||||||||||
| 108 | =for :stopwords maintainership | ||||||||||||
| 109 | |||||||||||||
| 110 | =head1 METHODS | ||||||||||||
| 111 | |||||||||||||
| 112 | =head2 new | ||||||||||||
| 113 | |||||||||||||
| 114 | =head2 create | ||||||||||||
| 115 | |||||||||||||
| 116 | Create the policy. | ||||||||||||
| 117 | |||||||||||||
| 118 | Options: | ||||||||||||
| 119 | |||||||||||||
| 120 | =over 8 | ||||||||||||
| 121 | |||||||||||||
| 122 | =item class | ||||||||||||
| 123 | |||||||||||||
| 124 | Available classes: B<Basic> (default). | ||||||||||||
| 125 | |||||||||||||
| 126 | =item version | ||||||||||||
| 127 | |||||||||||||
| 128 | Available versions: 1 (default). | ||||||||||||
| 129 | |||||||||||||
| 130 | =item format | ||||||||||||
| 131 | |||||||||||||
| 132 | Available formats: markdown (default). | ||||||||||||
| 133 | |||||||||||||
| 134 | =item attributes | ||||||||||||
| 135 | |||||||||||||
| 136 | =over 8 | ||||||||||||
| 137 | |||||||||||||
| 138 | =item authors | ||||||||||||
| 139 | |||||||||||||
| 140 | Required attribute for contact information. | ||||||||||||
| 141 | |||||||||||||
| 142 | =back | ||||||||||||
| 143 | |||||||||||||
| 144 | =back | ||||||||||||
| 145 | |||||||||||||
| 146 | =head1 AUTHOR | ||||||||||||
| 147 | |||||||||||||
| 148 | Mikko Koivunalho <mikkoi@cpan.org> | ||||||||||||
| 149 | |||||||||||||
| 150 | =head1 COPYRIGHT AND LICENSE | ||||||||||||
| 151 | |||||||||||||
| 152 | This software is copyright (c) 2025 by Mikko Koivunalho. | ||||||||||||
| 153 | |||||||||||||
| 154 | This is free software; you can redistribute it and/or modify it under | ||||||||||||
| 155 | the same terms as the Perl 5 programming language system itself. | ||||||||||||
| 156 | |||||||||||||
| 157 | =cut | ||||||||||||
| 158 | |||||||||||||
| 159 | __DATA__ | ||||||||||||