blib/lib/Dist/Zilla/Plugin/MetaResources.pm

filter: Statementstmt 100% 37 / 37 Branchbran 100% 6 / 6 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 1 totaltotal 94.4% 51 / 54 CC 7 SCAR 15.7
CC
7
Cov
98%
__ANON__
7.0
BEGIN
1.0
BEGIN
1.0
CRAP 4.8
« blib/lib/Dist/Zilla/Plugin/PodVersion.pm ↑ Summary blib/lib/Dist/Zilla.pm »
1 package Dist::Zilla::Plugin::MetaResources 6.040;
2 # ABSTRACT: provide arbitrary "resources" for distribution metadata
3  
4 3 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 with 'Dist::Zilla::Role::MetaProvider';
6  
7 3 ▶use Dist::Zilla::Pragmas;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 3 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 #pod =head1 DESCRIPTION
12 #pod
13 #pod This plugin adds resources entries to the distribution's metadata.
14 #pod
15 #pod [MetaResources]
16 #pod homepage = https://example.com/~dude/project.asp
17 #pod bugtracker.web = https://rt.cpan.org/Public/Dist/Display.html?Name=Project
18 #pod bugtracker.mailto = bug-Project@rt.cpan.org
19 #pod repository.url = git://github.com/dude/project.git
20 #pod repository.web = https://github.com/dude/project
21 #pod repository.type = git
22 #pod
23 #pod =cut
24  
25 3 has resources => (
26 is => 'ro',
27 isa => 'HashRef',
28 required => 1,
29 );
30  
31 6 ▶around BUILDARGS => sub {
Subroutine __ANON__: called CC=7 SCAR=19.5
32 6 my $orig = shift;
33 6 my ($class, @arg) = @_;
34  
35 6 my $args = $class->$orig(@arg);
36 6 my %copy = %{ $args };
37  
38 6 my $zilla = delete $copy{zilla};
39 6 my $name = delete $copy{plugin_name};
40  
41 6 ▶ if (exists $copy{license} && ref($copy{license}) ne 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $copy{"license"} and ref $copy{"license"} ne "ARRAY") 2 4 6
Condition66%2/3
exists $copy{"license"} and ref $copy{"license"} ne "ARRAY"
!ll&&!rl&&r
402
MC/DC50%1/2
exists $copy{"license"} and ref $copy{"license"} ne "ARRAY"
exists $copy{"license"} ref $copy{"license"} ne "ARRAY"
Truth table66%2/3
A and B
A= exists $copy{"license"}B= ref $copy{"license"} ne "ARRAY"
ABresult
0X0
100
111
42 2 $copy{license} = [ $copy{license} ];
43 }
44  
45 6 ▶ if (exists $copy{bugtracker}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $copy{"bugtracker"}) 1 5 6
46 1 my $tracker = delete $copy{bugtracker};
47 1 $copy{bugtracker}{web} = $tracker;
48 }
49  
50 6 ▶ if (exists $copy{repository}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $copy{"repository"}) 1 5 6
51 1 my $repo = delete $copy{repository};
52 1 $copy{repository}{url} = $repo;
53 }
54  
55 6 for my $multi (qw( bugtracker repository )) {
56 12 for my $key (grep { /^\Q$multi\E\./ } keys %copy) {
57 5 my $subkey = (split /\./, $key, 2)[1];
58 5 $copy{$multi}{$subkey} = delete $copy{$key};
59 }
60 }
61  
62 return {
63 6 zilla => $zilla,
64 plugin_name => $name,
65 resources => \%copy,
66 };
67 3 };
68  
69 6 ▶sub metadata {
Subroutine metadata: called CC=1 SCAR=0.0
Pod undocumented
70 6 my ($self) = @_;
71  
72 6 return { resources => $self->resources };
73 }
74  
75 3 __PACKAGE__->meta->make_immutable;
76 3 1;
77  
78 #pod =head1 SEE ALSO
79 #pod
80 #pod Dist::Zilla roles: L<MetaProvider|Dist::Zilla::Role::MetaProvider>.
81 #pod
82 #pod Dist::Zilla plugins on the CPAN: L<GithubMeta|Dist::Zilla::Plugin::GithubMeta>.
83 #pod
84 #pod =cut
85  
86 __END__
« blib/lib/Dist/Zilla/Plugin/PodVersion.pm ↑ Summary blib/lib/Dist/Zilla.pm »