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.029;
2             # ABSTRACT: provide arbitrary "resources" for distribution metadata
3              
4 3     3   2878 use Moose;
  3         8  
  3         23  
5             with 'Dist::Zilla::Role::MetaProvider';
6              
7 3     3   22117 use Dist::Zilla::Pragmas;
  3         7  
  3         31  
8              
9 3     3   29 use namespace::autoclean;
  3         16  
  3         48  
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 17 my ($self) = @_;
71              
72 6         238 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.029
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 released
116             in the last two to three years. (That is, if the most recently released
117             version is v5.40, then this module should work on both v5.40 and v5.38.)
118              
119             Although it may work on older versions of perl, no guarantee is made that the
120             minimum required version will not be increased. The version may be increased
121             for any reason, and there is no promise that patches will be accepted to lower
122             the minimum required perl.
123              
124             =head1 SEE ALSO
125              
126             Dist::Zilla roles: L<MetaProvider|Dist::Zilla::Role::MetaProvider>.
127              
128             Dist::Zilla plugins on the CPAN: L<GithubMeta|Dist::Zilla::Plugin::GithubMeta>.
129              
130             =head1 AUTHOR
131              
132             Ricardo SIGNES 😏 <cpan@semiotic.systems>
133              
134             =head1 COPYRIGHT AND LICENSE
135              
136             This software is copyright (c) 2022 by Ricardo SIGNES.
137              
138             This is free software; you can redistribute it and/or modify it under
139             the same terms as the Perl 5 programming language system itself.
140              
141             =cut