Login
Change $VERSION to a string instead of a number to deal with
[gknop/Perl-Critic.git] / inc / Perl / Critic / BuildUtilities.pm
CommitLineData
34cc6052
ES
1##############################################################################
2# $URL$
3# $Date$
4# $Author$
5# $Revision$
6##############################################################################
7
8package Perl::Critic::BuildUtilities;
9
10use strict;
11use warnings;
12
70f3f307
ES
13use English q<-_no_match_vars>;
14
479364fc 15our $VERSION = '1.078';
34cc6052
ES
16
17use base qw{ Exporter };
18
496afbe0 19our @EXPORT_OK = qw<
70f3f307
ES
20 recommended_module_versions
21 test_wrappers_to_generate
496afbe0 22 get_PL_files
70f3f307 23 dump_unlisted_or_optional_module_versions
496afbe0
ES
24>;
25
26
27use lib 't/tlib';
28
29use Perl::Critic::TestUtilitiesWithMinimalDependencies qw<
30 should_skip_author_tests
31>;
32
34cc6052
ES
33
34sub recommended_module_versions {
35 return (
36 'File::HomeDir' => 0,
37 'Perl::Tidy' => 0,
90c0067c 38 'Regexp::Parser' => '0.20',
34cc6052
ES
39
40 # All of these are for Documentation::PodSpelling
41 'File::Which' => 0,
42 'IPC::Open2' => 1,
43 'Pod::Spell' => 1,
44 'Text::ParseWords' => 3,
45 );
46}
47
496afbe0 48
34cc6052 49sub test_wrappers_to_generate {
70f3f307 50 my @tests_to_be_wrapped = qw<
34cc6052
ES
51 t/00_modules.t
52 t/01_config.t
53 t/01_config_bad_perlcriticrc.t
54 t/02_policy.t
55 t/03_pragmas.t
56 t/04_defaults.t
57 t/05_utils.t
58 t/05_utils_ppi.t
59 t/06_violation.t
60 t/07_perlcritic.t
61 t/08_document.t
62 t/09_theme.t
63 t/10_userprofile.t
64 t/11_policyfactory.t
65 t/12_policylisting.t
66 t/13_bundled_policies.t
67 t/14_policy_parameters.t
68 t/15_statistics.t
69 t/20_policy_podspelling.t
70 t/20_policy_requiretidycode.t
71 t/80_policysummary.t
72 t/92_memory_leaks.t
73 t/94_includes.t
70f3f307 74 >;
34cc6052
ES
75
76 return
77 map
78 { $_ . '_without_optional_dependencies.t' }
79 @tests_to_be_wrapped;
80}
81
496afbe0 82sub get_PL_files {
6d34b243
ES
83 my %PL_files;
84
85 $PL_files{'t/ControlStructures/ProhibitNegativeExpressionsInUnlessAndUntilConditions.run.PL'} =
86 't/ControlStructures/ProhibitNegativeExpressionsInUnlessAndUntilConditions.run';
458fe68a
CD
87 $PL_files{'t/Variables/RequireLocalizedPunctuationVars.run.PL'} =
88 't/Variables/RequireLocalizedPunctuationVars.run';
6d34b243 89
496afbe0
ES
90 if (should_skip_author_tests()) {
91 print
92 "\nWill not generate extra author tests. Set "
93 . '$ENV{TEST_AUTHOR} to a true value to have them generated.'
94 . "\n\n";
6d34b243
ES
95 }
96 else {
97 $PL_files{'t/generate_without_optional_dependencies_wrappers.PL'} =
98 [ test_wrappers_to_generate() ];
496afbe0
ES
99 }
100
6d34b243 101 return \%PL_files;
496afbe0
ES
102}
103
70f3f307
ES
104sub dump_unlisted_or_optional_module_versions {
105 print
106 "\nVersions of optional/unlisted/indirect dependencies:\n\n";
107
108 my @unlisted_modules = (
109 qw<
110 Exporter
111 Readonly::XS
112 >,
113 keys %{ { recommended_module_versions() } },
114 );
115
116 foreach my $module (sort @unlisted_modules) {
117 my $version;
118
119 eval "use $module; \$version = \$${module}::VERSION;";
120 if ($EVAL_ERROR) {
121 $version = 'not installed';
122 } elsif (not defined $version) {
123 $version = 'undef';
124 }
125
126 print " $module = $version\n";
127 }
128
129 print "\n";
130
131 return;
132}
34cc6052
ES
133
1341;
135
136__END__
137
138=head1 NAME
139
140Perl::Critic::BuildUtilities - Common bits of compiling Perl::Critic.
141
142
143=head1 DESCRIPTION
144
145Various utilities used in assembling Perl::Critic, primary for use by
146*.PL programs that generate code.
147
148
149=head1 IMPORTABLE SUBROUTINES
150
151=over
152
153=item C<recommended_module_versions()>
154
155Returns a hash mapping between recommended (but not required) modules
156for Perl::Critic and the minimum version required of each module,
157
158
159=item C<test_wrappers_to_generate()>
160
161Returns a list of test wrappers to be generated by
162F<t/generate_without_optional_dependencies_wrappers.PL>.
163
496afbe0
ES
164
165=item C<get_PL_files()>
166
167Returns a reference to a hash with a mapping from the name of a .PL
168program to an array of the parameters to be passed to it, suited for
169use by L<Module::Build::API/"PL_files"> or
170L<ExtUtils::MakeMaker/"PL_FILES">. May print to C<STDOUT> messages
171about what it is doing.
172
173
70f3f307
ES
174=item C<dump_unlisted_or_optional_module_versions()>
175
176Prints to C<STDOUT> a list of all the unlisted (e.g. things in core
177like L<Exporter>), optional (e.g. L<File::Which>), or potentially
178indirect (e.g. L<Readonly::XS>) dependencies, plus their versions, if
179they're installed.
180
34cc6052
ES
181
182=back
183
184
185=head1 AUTHOR
186
187Elliot Shank C<< <perl@galumph.com> >>
188
189
190=head1 LICENCE AND COPYRIGHT
191
192Copyright (c) 2007, Elliot Shank C<< <perl@galumph.com> >>. All rights
193reserved.
194
195This program is free software; you can redistribute it and/or modify
196it under the same terms as Perl itself. The full text of this license
197can be found in the LICENSE file included with this module.
198
199=cut
200
201##############################################################################
202# Local Variables:
203# mode: cperl
204# cperl-indent-level: 4
205# fill-column: 78
206# indent-tabs-mode: nil
207# c-indentation-style: bsd
208# End:
209# ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab :