File Coverage

blib/lib/Dist/Zilla/Plugin/Deprecated.pm
Criterion Covered Total %
statement 18 20 90.0
branch 3 4 75.0
condition 1 3 33.3
subroutine 7 7 100.0
pod 0 3 0.0
total 29 37 78.3


line stmt bran cond sub pod time code
1 2     2   1184045 use strict;
  2         4  
  2         67  
2 2     2   7 use warnings;
  2         2  
  2         98  
3             package Dist::Zilla::Plugin::Deprecated; # git description: v0.003-2-g8f29f37
4             # ABSTRACT: add metadata to your distribution marking it as deprecated
5             # KEYWORDS: plugin metadata module distribution deprecated
6             # vim: set ts=8 sts=4 sw=4 tw=78 et :
7              
8             our $VERSION = '0.004';
9              
10 2     2   7 use Moose;
  2         3  
  2         14  
11             with 'Dist::Zilla::Role::MetaProvider';
12 2     2   8439 use namespace::autoclean;
  2         4  
  2         16  
13              
14             has all => (
15             is => 'ro', isa => 'Bool',
16             init_arg => 'all',
17             lazy => 1,
18             default => sub {
19             my $self = shift;
20             $self->modules ? 0 : 1;
21             },
22             );
23              
24             has modules => (
25             isa => 'ArrayRef[Str]',
26             traits => [ 'Array' ],
27             handles => { modules => 'elements' },
28             lazy => 1,
29             default => sub { [] },
30             );
31              
32 2     2 0 230 sub mvp_aliases { { module => 'modules' } }
33 2     2 0 810 sub mvp_multivalue_args { qw(modules) }
34              
35             around dump_config => sub
36             {
37             my ($orig, $self) = @_;
38             my $config = $self->$orig;
39              
40             $config->{+__PACKAGE__} = {
41             all => $self->all,
42             modules => [ $self->modules ],
43             };
44              
45             return $config;
46             };
47              
48             sub metadata
49             {
50 2     2 0 40484 my $self = shift;
51              
52 2 100       88 return { x_deprecated => 1 } if $self->all;
53              
54             # older Dist::Zilla uses Hash::Merge::Simple, which performs the same sort
55             # of merge we need as in new CPAN::Meta::Merge
56             $self->log_fatal('CPAN::Meta::Merge 2.150002 required to deprecate an individual module!')
57 1 50 33     1 if eval { Dist::Zilla->VERSION('5.022') }
  1         94  
58             and not eval 'require CPAN::Meta::Merge; CPAN::Meta::Merge->VERSION("2.150002"); 1';
59              
60 0           return { provides => { map { $_ => { x_deprecated => 1 } } $self->modules } };
  0            
61             }
62              
63             __PACKAGE__->meta->make_immutable;
64              
65             __END__
66              
67             =pod
68              
69             =encoding UTF-8
70              
71             =head1 NAME
72              
73             Dist::Zilla::Plugin::Deprecated - add metadata to your distribution marking it as deprecated
74              
75             =head1 VERSION
76              
77             version 0.004
78              
79             =head1 SYNOPSIS
80              
81             In your F<dist.ini>:
82              
83             [Deprecated]
84              
85             or
86              
87             [Deprecated]
88             module = MyApp::OlderAPI
89              
90             =head1 DESCRIPTION
91              
92             This is a L<Dist::Zilla> plugin that adds metadata to your distribution marking it as deprecated.
93              
94             This uses the unofficial C<x_deprecated> field,
95             which is a new convention for marking a CPAN distribution as deprecated.
96             You should still note that the distribution is deprecated in the documentation,
97             for example in the abstract and the first paragraph of the DESCRIPTION section.
98              
99             You can also mark a single module (or subset of modules) as deprecated by
100             listing them with the C<module> option. This will add an C<x_deprecated>
101             field to the C<provides> section of metadata.
102              
103             =head1 CONFIGURATION OPTIONS
104              
105             =head2 C<module>
106              
107             Identify a specific module to be deprecated. Can be used more than once.
108              
109             =head2 C<all>
110              
111             Not normally needed directly. Mark an entire distribution as deprecated. This
112             defaults to true when there are no C<module>s listed, and false otherwise.
113              
114             =for Pod::Coverage metadata mvp_aliases mvp_multivalue_args
115              
116             =head1 SUPPORT
117              
118             =for stopwords irc
119              
120             Bugs may be submitted through L<the RT bug tracker|https://rt.cpan.org/Public/Dist/Display.html?Name=Dist-Zilla-Plugin-Deprecated>
121             (or L<bug-Dist-Zilla-Plugin-Deprecated@rt.cpan.org|mailto:bug-Dist-Zilla-Plugin-Deprecated@rt.cpan.org>).
122             I am also usually active on irc, as 'ether' at C<irc.perl.org>.
123              
124             =head1 ACKNOWLEDGEMENTS
125              
126             Neil Bowers requested this. :)
127              
128             =head1 AUTHOR
129              
130             Karen Etheridge <ether@cpan.org>
131              
132             =head1 COPYRIGHT AND LICENSE
133              
134             This software is copyright (c) 2015 by Karen Etheridge.
135              
136             This is free software; you can redistribute it and/or modify it under
137             the same terms as the Perl 5 programming language system itself.
138              
139             =head1 CONTRIBUTOR
140              
141             =for stopwords Neil Bowers
142              
143             Neil Bowers <neil@bowers.com>
144              
145             =cut