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