Subject: | Enhancement Patch: User customizable files |
Hello Liz,
I found your module in your PerlMonks writeup. I use the ABSTRACT_FROM variable instead of the VERSION_FROM variable, and my readme file is auto-generated from a pod file: doc/README.pod. Therefore, I enhanced your module to make it more customizable.
Here's an example usage:
#
# auto-update documentation if needed
#
$::DEVEL_REQUIRED_MAKEFILE_VARIABLE = 'ABSTRACT_FROM';
@::DEVEL_REQUIRED_DEFAULT_POD_FILES = ( 'doc/README.pod' );
@::DEVEL_REQUIRED_DEFAULT_TEXT_FILES = ( '' );
eval "use Devel::Required";
I hope you like it.
-Dan
--- Required.pm.orig 2003-12-31 11:52:57.000000000 -0800
+++ Required.pm 2003-12-31 12:31:31.000000000 -0800
@@ -6,6 +6,20 @@
$VERSION = '0.02';
use strict;
+#
+# Allow the user to specify where things are.
+#
+my $MAKEFILE_VARIABLE = $::DEVEL_REQUIRED_MAKEFILE_VARIABLE || 'VERSION_FROM';
+my @DEFAULT_POD_FILES = @::DEVEL_REQUIRED_DEFAULT_POD_FILES;
+my @DEFAULT_TEXT_FILES = @::DEVEL_REQUIRED_DEFAULT_TEXT_FILES;
+if ( ! @DEFAULT_TEXT_FILES ) {
+ @DEFAULT_TEXT_FILES = ( 'README' );
+}
+#print "MAKEFILE_VARIABLE = $MAKEFILE_VARIABLE\n";
+#print "DEFAULT_POD_FILES = " . join( "\n", @DEFAULT_POD_FILES ) . "\n";
+#print "DEFAULT_TEXT_FILES = " . join( "\n", @DEFAULT_TEXT_FILES ) . "\n";
+
+
# While we're compiling
# Make sure we can redefine without problems
# Obtain the subroutine name
@@ -24,7 +38,8 @@
# Initialize the hash reference to the module info
# Initialize the text to replace
- my $pod;
+ my @pod_files = @DEFAULT_POD_FILES;
+ my @text_files = @DEFAULT_TEXT_FILES;
my $modules;
my $text;
@@ -37,8 +52,8 @@
while (@_) {
my ($key,$value) = (shift,shift);
- if ($key eq 'VERSION_FROM') {
- $pod = $value;
+ if ($key eq $MAKEFILE_VARIABLE) {
+ push @pod_files, $value;
} elsif ($key eq 'PREREQ_PM') {
$modules = $value;
}
@@ -53,13 +68,18 @@
if $modules;
$text ||= " (none)";
-# Convert the README file if there is one
-# Convert the main perl module if there is supposed to be one
+# Convert text files, if any (README is default).
+# Convert pod files (including the specified in VERSION_FROM, by default)
- _convert( 'README',"Required Modules:\n",$text,"\n\n" )
- if -e 'README';
- _convert( $pod,"=head1 REQUIRED MODULES\n","\n$text\n","\n=" )
- if $pod and -e $pod;
+ foreach my $text_file ( @text_files ) {
+ _convert( $text_file,"Required Modules:\n",$text,"\n\n" )
+ if $text_file and -e $text_file;
+ }
+
+ foreach my $pod_file ( @pod_files ) {
+ _convert( $pod_file,"=head1 REQUIRED MODULES\n","\n$text\n","\n=" )
+ if $pod_file and -e $pod_file;
+ }
};
} #BEGIN