| 1 | #--------------------------------------------------------------------- | ||||||||||||
| 2 | package Dist::Zilla::Plugin::Metadata; | ||||||||||||
| 3 | # | ||||||||||||
| 4 | # Copyright 2017 Christopher J. Madsen | ||||||||||||
| 5 | # | ||||||||||||
| 6 | # Author: Christopher J. Madsen <perl@cjmweb.net> | ||||||||||||
| 7 | # Created: 2 Dec 2010 | ||||||||||||
| 8 | # | ||||||||||||
| 9 | # This program is free software; you can redistribute it and/or modify | ||||||||||||
| 10 | # it under the same terms as Perl itself. | ||||||||||||
| 11 | # | ||||||||||||
| 12 | # This program is distributed in the hope that it will be useful, | ||||||||||||
| 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||||||||
| 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See either the | ||||||||||||
| 15 | # GNU General Public License or the Artistic License for more details. | ||||||||||||
| 16 | # | ||||||||||||
| 17 | # ABSTRACT: Add arbitrary keys to distmeta | ||||||||||||
| 18 | #--------------------------------------------------------------------- | ||||||||||||
| 19 | |||||||||||||
| 20 | 2 | our $VERSION = '6.000'; | |||||||||||
| 21 | # This file is part of Dist-Zilla-Plugins-CJM 6.000 (December 17, 2017) | ||||||||||||
| 22 | |||||||||||||
| 23 | |||||||||||||
| 24 | 2 | ▶ | use Moose; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 25 | |||||||||||||
| 26 | 2 | has metadata => ( | |||||||||||
| 27 | is => 'ro', | ||||||||||||
| 28 | isa => 'HashRef', | ||||||||||||
| 29 | required => 1, | ||||||||||||
| 30 | ); | ||||||||||||
| 31 | |||||||||||||
| 32 | 2 | with 'Dist::Zilla::Role::MetaProvider'; | |||||||||||
| 33 | |||||||||||||
| 34 | #--------------------------------------------------------------------- | ||||||||||||
| 35 | sub BUILDARGS | ||||||||||||
| 36 | 6 | ▶ | { | ||||||||||
|
Subroutine
BUILDARGS: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||
| 37 | 6 | my ($class, @arg) = @_; | |||||||||||
| 38 | 6 | ▶ | my %copy = ref $arg[0] ? %{$arg[0]} : @arg; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 39 | |||||||||||||
| 40 | 6 | my $zilla = delete $copy{zilla}; | |||||||||||
| 41 | 6 | my $name = delete $copy{plugin_name}; | |||||||||||
| 42 | |||||||||||||
| 43 | 6 | my %metadata; | |||||||||||
| 44 | 6 | ▶ | while (my ($key, $value) = each %copy) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 45 | 7 | my @keys = split (/\./, $key, -1); | |||||||||||
| 46 | 7 | my $hash = \%metadata; | |||||||||||
| 47 | 7 | ▶ | while (@keys > 1) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 48 | 9 | ▶ | $hash = $hash->{shift @keys} ||= {}; | ||||||||||
|
Condition100%2/2
$$hash{shift @keys} ||= {}
MC/DC100%1/1
$$hash{shift @keys} ||= {}
$$hash{shift @keys}
Truth table100%2/2
A
A= $$hash{shift @keys}
| |||||||||||||
| 49 | } | ||||||||||||
| 50 | |||||||||||||
| 51 | 7 | $hash->{$keys[0]} = $value; | |||||||||||
| 52 | } # end while each %copy | ||||||||||||
| 53 | |||||||||||||
| 54 | return { | ||||||||||||
| 55 | 6 | zilla => $zilla, | |||||||||||
| 56 | plugin_name => $name, | ||||||||||||
| 57 | metadata => \%metadata, | ||||||||||||
| 58 | }; | ||||||||||||
| 59 | } # end BUILDARGS | ||||||||||||
| 60 | |||||||||||||
| 61 | #--------------------------------------------------------------------- | ||||||||||||
| 62 | sub mvp_multivalue_args | ||||||||||||
| 63 | 6 | ▶ | { | ||||||||||
|
Subroutine
mvp_multivalue_args: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||
| 64 | 6 | return qw(author keywords license no_index.file no_index.directory | |||||||||||
| 65 | no_index.package no_index.namespace resources.license | ||||||||||||
| 66 | x_contributors | ||||||||||||
| 67 | ); | ||||||||||||
| 68 | } # end mvp_multivalue_args | ||||||||||||
| 69 | |||||||||||||
| 70 | #===================================================================== | ||||||||||||
| 71 | 2 | ▶ | no Moose; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 72 | 2 | __PACKAGE__->meta->make_immutable; | |||||||||||
| 73 | 2 | 1; | |||||||||||
| 74 | |||||||||||||
| 75 | __END__ | ||||||||||||