Module::Build::PM_Filter
Este módulo añade una extensión en forma de filtro de código fuente al módulo del cpan Module::Build. Dicha extensión está basada en una característica de ExtUtils::MakeMaker que permite definir un programa externo para efectuar filtrados sobre todos los archivos a instalar.
En este caso únicamente estamos filtrando los archivos con extensión .pm
,
aunque no descarto ampliarla para otras extensiones.
Su propósito final es permitir la inclusión de valores que deben ir en los archivos fuente cuando se empaquetan.
La documentación del módulo es la siguiente:
1 =head1 NAME 2 3 Module::Build::PM_Filter - Add a PM_Filter feature to Module::Build 4 5 =head1 VERSION 6 7 This documentation refers to Module::Build::PM_Filter version 1.2 8 9 =head1 SYNOPSIS 10 11 In a Build.PL file you must use this module in place of the L<Module::Build>: 12 13 use Module::Build::PM_Filter; 14 15 my $build = Module::Build::PM_Filter->new( 16 module_name => 'MyIkiWiki::Tools', 17 license => q(gpl), 18 dist_version => '0.2', 19 dist_author => 'Victor Moral <victor@taquiones.net>', 20 ); 21 22 $build->create_build_script(); 23 24 In the package directory create a pm_filter file like this: 25 26 #!/usr/bin/perl -pl 27 28 s{##PACKAGE_LIB##}{use lib qw(/usr/share/myprogram);}g; 29 30 and change its permissions for user execution. 31 32 Then in a script from package insert a line like this: 33 34 package MyPackage; 35 use strict; 36 use base; 37 38 ... 39 40 ##PACKAGE_LIB## 41 42 ... 43 44 =head1 DESCRIPTION 45 46 This module provides a Module::Build compatible class and adds a filter for 47 F<.pm>, F<.pl> and script files. The filter could be used to replace Perl 48 source from development environment to production, or to remove debug 49 sentences. 50 51 In the debug phase we can play with the application and modules without 52 mattering to us where the library are; when we build the package for 53 distribution, the modules and the scripts will contain the correct path in the 54 final location. 55 56 In addition the module makes sure that the archives F<pm_filter> and 57 F<debian/rules> are copied in the distribution directory with the suitable 58 permissions. 59 60 =head1 SUBROUTINES/METHODS 61 62 =head2 process_pm_files( ) 63 64 This method looks for a file named 'pm_filter' in the current work directory 65 and executes it; his standard input is redirected to the source pm and his 66 standard output is redirected to a temp file. 67 68 The temp file is finally installed on the F<blib/> tree. 69 70 =head2 process_script_files( ) 71 72 This method finds, filters and install the executable files in the package. 73 74 =head2 ACTION_distdir( ) 75 76 This method performs the 'distdir' action and change the permissions of the 77 pm_filter and debian/rules files in the distribution to executable. 78 79 =head1 DIAGNOSTICS 80 81 =over 82 83 =item pm_filter failed ... 84 85 croak with this text when it could not run the pm_filter program. 86 87 =item pm_filter not executable ... 88 89 croak with this text when exists a pm_filter file and it not executable. 90 91 =back 92 93 =head1 CONFIGURATION AND ENVIRONMENT 94 95 The location of the pm_filter script must be the current work directory. 96 97 =head1 DEPENDENCIES 98 99 =over 100 101 =item Module::Build 102 103 =item File::Copy::Recursive 104 105 =back 106 107 =head1 INCOMPATIBILITIES 108 109 =over 110 111 =item L<ExtUtils::MakeMaker> 112 113 =back 114 115 =head1 BUGS AND LIMITATIONS 116 117 There are no known bugs in this module. 118 Please report problems to the author. 119 Patches are welcome. 120 121 =head1 AUTHOR 122 123 Victor Moral <victor@taquiones.net> 124 125 =head1 LICENSE AND COPYRIGHT 126 127 Copyright (c) 2008 "Victor Moral" <victor@taquiones.net> 128 129 This library is free software; you can redistribute it and/or 130 modify it under the terms of the GNU Lesser General Public 131 License as published by the Free Software Foundation; either 132 version 2.1 of the License. 133 134 135 This library is distributed in the hope that it will be useful, 136 but WITHOUT ANY WARRANTY; without even the implied warranty of 137 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 138 Lesser General Public License for more details. 139 140 141 You should have received a copy of the GNU Lesser General Public 142 License along with this library; if not, write to the Free Software 143 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 US