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   2733641 use strict;
  2         2  
  2         53  
2 2     2   8 use warnings;
  2         2  
  2         92  
3             package Dist::Zilla::Plugin::Deprecated; # git description: v0.005-5-g9f3d7b9
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=115 et :
7              
8             our $VERSION = '0.006';
9              
10 2     2   7 use Moose;
  2         2  
  2         12  
11             with 'Dist::Zilla::Role::MetaProvider';
12 2     2   7631 use namespace::autoclean;
  2         2  
  2         15  
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 225 sub mvp_aliases { { module => 'modules' } }
33 2     2 0 800 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 ? 1 : 0),
42             modules => [ sort $self->modules ],
43             blessed($self) ne __PACKAGE__ ? ( version => $VERSION ) : (),
44             };
45              
46             return $config;
47             };
48              
49             sub metadata
50             {
51 2     2 0 18751 my $self = shift;
52              
53 2 100       70 return { x_deprecated => 1 } if $self->all;
54              
55             # older Dist::Zilla uses Hash::Merge::Simple, which performs the same sort
56             # of merge we need as in new CPAN::Meta::Merge
57             $self->log_fatal('CPAN::Meta::Merge 2.150002 required to deprecate an individual module!')
58 1 50 33     3 if eval { Dist::Zilla->VERSION('5.022') }
  1         100  
59             and not eval 'require CPAN::Meta::Merge; CPAN::Meta::Merge->VERSION("2.150002"); 1';
60              
61 0           return { provides => { map { $_ => { x_deprecated => 1 } } $self->modules } };
  0            
62             }
63              
64             __PACKAGE__->meta->make_immutable;
65              
66             __END__
67              
68             =pod
69              
70             =encoding UTF-8
71              
72             =head1 NAME
73              
74             Dist::Zilla::Plugin::Deprecated - Add metadata to your distribution marking it as deprecated
75              
76             =head1 VERSION
77              
78             version 0.006
79              
80             =head1 SYNOPSIS
81              
82             In your F<dist.ini>:
83              
84             [Deprecated]
85              
86             or
87              
88             [Deprecated]
89             module = MyApp::OlderAPI
90              
91             =head1 DESCRIPTION
92              
93             This is a L<Dist::Zilla> plugin that adds metadata to your distribution marking it as deprecated.
94              
95             This uses the unofficial C<x_deprecated> field,
96             which is a new convention for marking a CPAN distribution as deprecated.
97             You should still note that the distribution is deprecated in the documentation,
98             for example in the abstract and the first paragraph of the DESCRIPTION section.
99              
100             You can also mark a single module (or subset of modules) as deprecated by
101             listing them with the C<module> option. This will add an C<x_deprecated>
102             field to the C<provides> section of metadata. Note that L<CPAN::Meta::Spec>
103             requires you to populate the rest of C<provides> metadata through some
104             other means, such as L<Dist::Zilla::Plugin::MetaProvides::Package>.
105              
106             =head1 CONFIGURATION OPTIONS
107              
108             =head2 C<module>
109              
110             [Deprecated]
111             module = MyApp::OlderAPI
112              
113             Identify a specific module to be deprecated. Can be used more than once.
114              
115             =head2 C<all>
116              
117             [Deprecated]
118             all = 1
119              
120             Not normally needed directly. Mark an entire distribution as deprecated. This
121             defaults to true when there are no C<module>s listed, and false otherwise.
122              
123             =for Pod::Coverage metadata mvp_aliases mvp_multivalue_args
124              
125             =head1 ACKNOWLEDGEMENTS
126              
127             Neil Bowers requested this. :) And then he
128             L<blogged about it|http://neilb.org/2015/01/17/deprecated-metadata.html>.
129              
130             =head1 SUPPORT
131              
132             Bugs may be submitted through L<the RT bug tracker|https://rt.cpan.org/Public/Dist/Display.html?Name=Dist-Zilla-Plugin-Deprecated>
133             (or L<bug-Dist-Zilla-Plugin-Deprecated@rt.cpan.org|mailto:bug-Dist-Zilla-Plugin-Deprecated@rt.cpan.org>).
134              
135             There is also a mailing list available for users of this distribution, at
136             L<http://dzil.org/#mailing-list>.
137              
138             There is also an irc channel available for users of this distribution, at
139             L<C<#distzilla> on C<irc.perl.org>|irc://irc.perl.org/#distzilla>.
140              
141             I am also usually active on irc, as 'ether' at C<irc.perl.org>.
142              
143             =head1 AUTHOR
144              
145             Karen Etheridge <ether@cpan.org>
146              
147             =head1 CONTRIBUTOR
148              
149             =for stopwords Neil Bowers
150              
151             Neil Bowers <neil@bowers.com>
152              
153             =head1 COPYRIGHT AND LICENCE
154              
155             This software is copyright (c) 2015 by Karen Etheridge.
156              
157             This is free software; you can redistribute it and/or modify it under
158             the same terms as the Perl 5 programming language system itself.
159              
160             =cut