Add built local::lib
[catagits/Gitalist.git] / local-lib5 / lib / perl5 / Module / Install / AuthorRequires.pm
1 use strict;
2 use warnings;
3
4 package Module::Install::AuthorRequires;
5
6 use base 'Module::Install::Base';
7
8 # cargo cult
9 BEGIN {
10     our $VERSION = '0.02';
11     our $ISCORE  = 1;
12 }
13
14 sub author_requires {
15     my $self = shift;
16
17     return $self->{values}->{author_requires}
18         unless @_;
19
20     my @added;
21     while (@_) {
22         my $mod = shift or last;
23         my $version = shift || 0;
24         push @added, [$mod => $version];
25     }
26
27     push @{ $self->{values}->{author_requires} }, @added;
28     $self->admin->author_requires(@added);
29
30     return map { @$_ } @added;
31 }
32
33 1;
34
35 __END__
36
37 =head1 NAME
38
39 Module::Install::AuthorRequires - declare author-only dependencies
40
41 =head1 SYNOPSIS
42
43     author_requires 'Some::Module';
44     author_requires 'Another::Module' => '0.42';
45
46 =head1 DESCRIPTION
47
48 Modules often have optional requirements, for example dependencies that are
49 useful for (optional) tests, but not required for the module to work properly.
50
51 Usually you want all developers of a project to have these optional modules
52 installed. However, simply telling everyone or printing diagnostic messages if
53 optional dependencies are missing often isn't enough to make sure all authors
54 have all optional modules installed.
55
56 C<Module::Install> already has a way of detecting an author environment, so an
57 easy way to achieve the above would be something like:
58
59     if ($Module::Install::AUTHOR) {
60         requires 'Some::Module';
61         requires 'Another::Module' => '0.42';
62     }
63
64 Unfortunately, that'll also make the optional dependencies show up in the
65 distributions C<META.yml> file, which is obviously wrong, as they aren't
66 actually hard requirements.
67
68 Working that around requires a considerable amount of non-trivial Makefile.PL
69 hackery, or simply using this module's C<author_requires> command.
70
71 =head1 COMMANDS
72
73 =head2 author_requires
74
75     author_requires $module;
76     author_requires $module => $version;
77
78 This declares a hard dependency, that's only enforced in author environments
79 and is not put in the generate C<META.yml> file of the distribution.
80
81 =head1 AUTHOR
82
83 Florian Ragwitz E<lt>rafl@debian.orgE<gt>
84
85 =head1 COPYRIGHT AND LICENSE
86
87 Copyright (c) 2009  Florian Ragwitz
88
89 This is free software; you can redistribute it and/or modify it under the same
90 terms as the Perl 5 programming language system itself.
91
92 =cut