Login
New policy RegularExpressions::ProhibitComplexRegexes
[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
bb9f1668 15our $VERSION = 1.076;
34cc6052
ES
16
17use base qw{ Exporter };
18
19our @EXPORT_OK = qw{
70f3f307
ES
20 recommended_module_versions
21 test_wrappers_to_generate
22 dump_unlisted_or_optional_module_versions
34cc6052
ES
23};
24
25sub recommended_module_versions {
26 return (
27 'File::HomeDir' => 0,
28 'Perl::Tidy' => 0,
90c0067c 29 'Regexp::Parser' => '0.20',
34cc6052
ES
30
31 # All of these are for Documentation::PodSpelling
32 'File::Which' => 0,
33 'IPC::Open2' => 1,
34 'Pod::Spell' => 1,
35 'Text::ParseWords' => 3,
36 );
37}
38
39sub test_wrappers_to_generate {
70f3f307 40 my @tests_to_be_wrapped = qw<
34cc6052
ES
41 t/00_modules.t
42 t/01_config.t
43 t/01_config_bad_perlcriticrc.t
44 t/02_policy.t
45 t/03_pragmas.t
46 t/04_defaults.t
47 t/05_utils.t
48 t/05_utils_ppi.t
49 t/06_violation.t
50 t/07_perlcritic.t
51 t/08_document.t
52 t/09_theme.t
53 t/10_userprofile.t
54 t/11_policyfactory.t
55 t/12_policylisting.t
56 t/13_bundled_policies.t
57 t/14_policy_parameters.t
58 t/15_statistics.t
59 t/20_policy_podspelling.t
60 t/20_policy_requiretidycode.t
61 t/80_policysummary.t
62 t/92_memory_leaks.t
63 t/94_includes.t
70f3f307 64 >;
34cc6052
ES
65
66 return
67 map
68 { $_ . '_without_optional_dependencies.t' }
69 @tests_to_be_wrapped;
70}
71
70f3f307
ES
72sub dump_unlisted_or_optional_module_versions {
73 print
74 "\nVersions of optional/unlisted/indirect dependencies:\n\n";
75
76 my @unlisted_modules = (
77 qw<
78 Exporter
79 Readonly::XS
80 >,
81 keys %{ { recommended_module_versions() } },
82 );
83
84 foreach my $module (sort @unlisted_modules) {
85 my $version;
86
87 eval "use $module; \$version = \$${module}::VERSION;";
88 if ($EVAL_ERROR) {
89 $version = 'not installed';
90 } elsif (not defined $version) {
91 $version = 'undef';
92 }
93
94 print " $module = $version\n";
95 }
96
97 print "\n";
98
99 return;
100}
34cc6052
ES
101
1021;
103
104__END__
105
106=head1 NAME
107
108Perl::Critic::BuildUtilities - Common bits of compiling Perl::Critic.
109
110
111=head1 DESCRIPTION
112
113Various utilities used in assembling Perl::Critic, primary for use by
114*.PL programs that generate code.
115
116
117=head1 IMPORTABLE SUBROUTINES
118
119=over
120
121=item C<recommended_module_versions()>
122
123Returns a hash mapping between recommended (but not required) modules
124for Perl::Critic and the minimum version required of each module,
125
126
127=item C<test_wrappers_to_generate()>
128
129Returns a list of test wrappers to be generated by
130F<t/generate_without_optional_dependencies_wrappers.PL>.
131
70f3f307
ES
132=item C<dump_unlisted_or_optional_module_versions()>
133
134Prints to C<STDOUT> a list of all the unlisted (e.g. things in core
135like L<Exporter>), optional (e.g. L<File::Which>), or potentially
136indirect (e.g. L<Readonly::XS>) dependencies, plus their versions, if
137they're installed.
138
34cc6052
ES
139
140=back
141
142
143=head1 AUTHOR
144
145Elliot Shank C<< <perl@galumph.com> >>
146
147
148=head1 LICENCE AND COPYRIGHT
149
150Copyright (c) 2007, Elliot Shank C<< <perl@galumph.com> >>. All rights
151reserved.
152
153This program is free software; you can redistribute it and/or modify
154it under the same terms as Perl itself. The full text of this license
155can be found in the LICENSE file included with this module.
156
157=cut
158
159##############################################################################
160# Local Variables:
161# mode: cperl
162# cperl-indent-level: 4
163# fill-column: 78
164# indent-tabs-mode: nil
165# c-indentation-style: bsd
166# End:
167# ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab :