File Coverage

blib/lib/Dist/Zilla/Plugin/MetaResources.pm
Criterion Covered Total %
statement 11 11 100.0
branch n/a
condition n/a
subroutine 4 4 100.0
pod 0 1 0.0
total 15 16 93.7


line stmt bran cond sub pod time code
1             package Dist::Zilla::Plugin::MetaResources 6.037;
2             # ABSTRACT: provide arbitrary "resources" for distribution metadata
3              
4 3     3   3082 use Moose;
  3         6  
  3         33  
5             with 'Dist::Zilla::Role::MetaProvider';
6              
7 3     3   20218 use Dist::Zilla::Pragmas;
  3         7  
  3         26  
8              
9 3     3   21 use namespace::autoclean;
  3         6  
  3         31  
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             has resources => (
26             is => 'ro',
27             isa => 'HashRef',
28             required => 1,
29             );
30              
31             around BUILDARGS => sub {
32             my $orig = shift;
33             my ($class, @arg) = @_;
34              
35             my $args = $class->$orig(@arg);
36             my %copy = %{ $args };
37              
38             my $zilla = delete $copy{zilla};
39             my $name = delete $copy{plugin_name};
40              
41             if (exists $copy{license} && ref($copy{license}) ne 'ARRAY') {
42             $copy{license} = [ $copy{license} ];
43             }
44              
45             if (exists $copy{bugtracker}) {
46             my $tracker = delete $copy{bugtracker};
47             $copy{bugtracker}{web} = $tracker;
48             }
49              
50             if (exists $copy{repository}) {
51             my $repo = delete $copy{repository};
52             $copy{repository}{url} = $repo;
53             }
54              
55             for my $multi (qw( bugtracker repository )) {
56             for my $key (grep { /^\Q$multi\E\./ } keys %copy) {
57             my $subkey = (split /\./, $key, 2)[1];
58             $copy{$multi}{$subkey} = delete $copy{$key};
59             }
60             }
61              
62             return {
63             zilla => $zilla,
64             plugin_name => $name,
65             resources => \%copy,
66             };
67             };
68              
69             sub metadata {
70 6     6 0 21 my ($self) = @_;
71              
72 6         363 return { resources => $self->resources };
73             }
74              
75             __PACKAGE__->meta->make_immutable;
76             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__
87              
88             =pod
89              
90             =encoding UTF-8
91              
92             =head1 NAME
93              
94             Dist::Zilla::Plugin::MetaResources - provide arbitrary "resources" for distribution metadata
95              
96             =head1 VERSION
97              
98             version 6.037
99              
100             =head1 DESCRIPTION
101              
102             This plugin adds resources entries to the distribution's metadata.
103              
104             [MetaResources]
105             homepage = https://example.com/~dude/project.asp
106             bugtracker.web = https://rt.cpan.org/Public/Dist/Display.html?Name=Project
107             bugtracker.mailto = bug-Project@rt.cpan.org
108             repository.url = git://github.com/dude/project.git
109             repository.web = https://github.com/dude/project
110             repository.type = git
111              
112             =head1 PERL VERSION
113              
114             This module should work on any version of perl still receiving updates from
115             the Perl 5 Porters. This means it should work on any version of perl
116             released in the last two to three years. (That is, if the most recently
117             released version is v5.40, then this module should work on both v5.40 and
118             v5.38.)
119              
120             Although it may work on older versions of perl, no guarantee is made that the
121             minimum required version will not be increased. The version may be increased
122             for any reason, and there is no promise that patches will be accepted to
123             lower the minimum required perl.
124              
125             =head1 SEE ALSO
126              
127             Dist::Zilla roles: L<MetaProvider|Dist::Zilla::Role::MetaProvider>.
128              
129             Dist::Zilla plugins on the CPAN: L<GithubMeta|Dist::Zilla::Plugin::GithubMeta>.
130              
131             =head1 AUTHOR
132              
133             Ricardo SIGNES 😏 <cpan@semiotic.systems>
134              
135             =head1 COPYRIGHT AND LICENSE
136              
137             This software is copyright (c) 2026 by Ricardo SIGNES.
138              
139             This is free software; you can redistribute it and/or modify it under
140             the same terms as the Perl 5 programming language system itself.
141              
142             =cut