module-build-checkins Mailing List for Module::Build (Page 33)
Status: Beta
Brought to you by:
kwilliams
You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(82) |
Dec
(58) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(49) |
Feb
(57) |
Mar
(49) |
Apr
(49) |
May
(2) |
Jun
(147) |
Jul
(60) |
Aug
(55) |
Sep
(51) |
Oct
(68) |
Nov
(61) |
Dec
(44) |
2006 |
Jan
(27) |
Feb
(38) |
Mar
(89) |
Apr
(31) |
May
(17) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Ken W. <kwi...@us...> - 2005-02-23 02:44:32
|
Update of /cvsroot/module-build/Module-Build In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20868 Modified Files: Tag: release-0_26_branch Changes Log Message: Handle the absence of Pod::Man more gracefully Index: Changes =================================================================== RCS file: /cvsroot/module-build/Module-Build/Changes,v retrieving revision 1.299.2.36 retrieving revision 1.299.2.37 diff -u -d -r1.299.2.36 -r1.299.2.37 --- Changes 8 Feb 2005 07:06:22 -0000 1.299.2.36 +++ Changes 23 Feb 2005 02:44:23 -0000 1.299.2.37 @@ -8,6 +8,9 @@ specific about the directories we scan for pod that needs to be converted, effectively avoiding blib/html. [Ray Zimmerman] + - If Pod::Man is not available, we now skip building man pages + (rather than dying) and tell the user why. + - On some Unix platforms (BSD derivatives, mostly) perl's $^X variable isn't set to the full path of the perl executable, just 'perl', when the 'Build' script is run as './Build' and not 'perl |
From: Randy W. S. <si...@us...> - 2005-02-20 10:56:29
|
Update of /cvsroot/module-build/Module-Build/lib/Module/Build In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5098/lib/Module/Build Modified Files: Base.pm Log Message: Test 't/ext.t' failing because of extraneous ARGV entry. We now eliminate the creation of the ARGV key unless assigning a non-empty value. This also ensures that the return value of read_args is unpolluted when called from outside M::B. Index: Base.pm =================================================================== RCS file: /cvsroot/module-build/Module-Build/lib/Module/Build/Base.pm,v retrieving revision 1.392 retrieving revision 1.393 diff -u -d -r1.392 -r1.393 --- Base.pm 18 Feb 2005 13:54:14 -0000 1.392 +++ Base.pm 20 Feb 2005 10:56:14 -0000 1.393 @@ -1272,7 +1272,7 @@ push @argv, $_; } } - $args{ARGV} = \@argv; + $args{ARGV} = \@argv if @argv; # Hashify these parameters for ($self->hash_properties) { |
From: Randy W. S. <si...@us...> - 2005-02-20 10:56:29
|
Update of /cvsroot/module-build/Module-Build/t In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5098/t Modified Files: ext.t Log Message: Test 't/ext.t' failing because of extraneous ARGV entry. We now eliminate the creation of the ARGV key unless assigning a non-empty value. This also ensures that the return value of read_args is unpolluted when called from outside M::B. Index: ext.t =================================================================== RCS file: /cvsroot/module-build/Module-Build/t/ext.t,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- ext.t 17 Feb 2005 02:43:37 -0000 1.11 +++ ext.t 20 Feb 2005 10:56:16 -0000 1.12 @@ -88,7 +88,7 @@ # Make sure read_args() functions properly as a class method my @args = qw(foo=bar --food bard); my ($args) = Module::Build->read_args(@args); - is_deeply($args, {foo => 'bar', food => 'bard', ARGV => []}); + is_deeply($args, {foo => 'bar', food => 'bard'}); } { |
From: Randy W. S. <si...@us...> - 2005-02-20 10:17:44
|
Update of /cvsroot/module-build/Module-Build/lib/Module/Build In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28253/lib/Module/Build Modified Files: ModuleInfo.pm Log Message: Definition of $VERSION was not being detected if it was first line of undeclared package main. Index: ModuleInfo.pm =================================================================== RCS file: /cvsroot/module-build/Module-Build/lib/Module/Build/ModuleInfo.pm,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- ModuleInfo.pm 11 Feb 2005 03:53:48 -0000 1.2 +++ ModuleInfo.pm 20 Feb 2005 10:17:35 -0000 1.3 @@ -143,6 +143,19 @@ $vers{$pkg} = undef; push( @pkgs, $pkg ); + # first non-comment line in undeclared package main is VERSION + } elsif ( !exists($vers{main}) && $pkg eq 'main' && + $line =~ $VERS_REGEXP ) { + my $v = $self->_evaluate_version_line( $line ); + $vers{$pkg} = $v; + push( @pkgs, 'main' ); + + # first non-comement line in undeclared packge defines package main + } elsif ( !exists($vers{main}) && $pkg eq 'main' && + $line =~ /\w+/ ) { + $vers{main} = ''; + push( @pkgs, 'main' ); + } elsif ( $line =~ $VERS_REGEXP ) { # only first keep if this is the first $VERSION seen unless ( defined $vers{$pkg} && length $vers{$pkg} ) { @@ -150,10 +163,6 @@ $vers{$pkg} = $v; } - } elsif ( !exists($vers{main}) && $pkg eq 'main' && $line =~ /\w+/ ) { - $vers{main} = ''; - push( @pkgs, 'main' ); - } } |
From: Randy W. S. <si...@us...> - 2005-02-20 10:14:48
|
Update of /cvsroot/module-build/Module-Build/t In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27139/t Modified Files: moduleinfo.t Log Message: Convert tests to use t/lib/DistGen.pm, and increase test coverage. Index: moduleinfo.t =================================================================== RCS file: /cvsroot/module-build/Module-Build/t/moduleinfo.t,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- moduleinfo.t 11 Feb 2005 03:53:48 -0000 1.2 +++ moduleinfo.t 20 Feb 2005 10:14:39 -0000 1.3 @@ -1,7 +1,16 @@ use strict; use Test; -BEGIN { plan tests => 18 } + +BEGIN { + plan tests => 27; + + chdir( 't' ) if -d 't'; + + push( @INC, 'lib' ); + require DistGen; + require File::Spec; +} use Module::Build::ModuleInfo; ok(1); @@ -13,55 +22,176 @@ ok( -e $module ); -my $pm_info; +# fail on invalid module name +my $pm_info = Module::Build::ModuleInfo->new_from_module( 'Foo::Bar' ); +ok( !defined( $pm_info ) ); + # fail on invalid filename -$pm_info = Module::Build::ModuleInfo->new_from_file( 'Foo/Bar.pm' ); +my $file = File::Spec->catfile( 'Foo', 'Bar.pm' ); +$pm_info = Module::Build::ModuleInfo->new_from_file( $file ); ok( !defined( $pm_info ) ); + +my $dist = DistGen->new(); +$dist->regen(); + # construct from module filename +$file = File::Spec->catfile( $dist->dirname, 'lib', 'Simple.pm' ); $pm_info = - Module::Build::ModuleInfo->new_from_file( 't/Sample/lib/Sample.pm' ); + Module::Build::ModuleInfo->new_from_file( $file ); ok( defined( $pm_info ) ); -# construct from script filename -$pm_info = - Module::Build::ModuleInfo->new_from_file( 't/Sample/bin/sample.pl' ); +# construct from module name, using custom include path +my $inc = File::Spec->catdir( qw( Simple lib ) ); +$pm_info = Module::Build::ModuleInfo->new_from_module( + 'Simple', inc => [ $inc, @INC ] ); ok( defined( $pm_info ) ); -# find $VERSION in non-declared package main of script -ok( $pm_info->version('main'), '0.01' ); -# fail on invalid module name -$pm_info = Module::Build::ModuleInfo->new_from_module( 'Foo::Bar' ); -ok( !defined( $pm_info ) ); +# parse various module $VERSION lines +my @modules = ( + <<'---', # declared & defined on same line with 'our' +package Simple; +our $VERSION = '1.23'; +1; +--- + <<'---', # declared & defined on seperate lines with 'our' +package Simple; +our $VERSION; +$VERSION = '1.23'; +1; +--- + <<'---', # use vars +package Simple; +use vars qw( $VERSION ); +$VERSION = '1.23'; +1; +--- + <<'---', # choose the right default package based on package/file name +package Simple::_private; +our $VERSION = '0'; +1; +package Simple; +our $VERSION = '1.23'; # this should be chosen for version +1; +--- + <<'---', # just read the first $VERSION line +package Simple; +our $VERSION = '1.23'; # we should see this line +$VERSION = eval $VERSION; # and ignore this one +1; +--- +); +$dist = DistGen->new(); +foreach my $module ( @modules ) { + $dist->change_file( 'lib/Simple.pm', $module ); + $dist->regen( clean => 1 ); + $file = File::Spec->catfile( $dist->dirname, 'lib', 'Simple.pm' ); + my $pm_info = Module::Build::ModuleInfo->new_from_file( $file ); + ok( $pm_info->version eq '1.23' ); +} +$dist->remove(); -$pm_info = Module::Build::ModuleInfo->new_from_module( - 'Sample', inc => [ 't/Sample/lib', @INC ] ); -# finds module in 'inc' path -ok( defined( $pm_info ) ); +# parse $VERSION lines scripts for package main +my @scripts = ( + <<'---', # package main declared +#!perl -w +package main; +our $VERSION = '0.01'; +--- + <<'---', # on first non-comment line, non declared package main +#!perl -w +our $VERSION = '0.01'; +--- + <<'---', # after non-comment line +#!perl -w +use strict; +our $VERSION = '0.01'; +--- + <<'---', # 1st declared package +#!perl -w +package main; +our $VERSION = '0.01'; +package _private; +our $VERSION = '999'; +1; +--- + <<'---', # 2nd declared package +#!perl -w +package _private; +our $VERSION = '999'; +1; +package main; +our $VERSION = '0.01'; +--- + <<'---', # split package +#!perl -w +package main; +1; +package _private; +our $VERSION = '999'; +1; +package main; +our $VERSION = '0.01'; +1; +--- +); -ok( $pm_info->name(), 'Sample' ); +$dist = DistGen->new(); +foreach my $script ( @scripts ) { + $dist->change_file( 'bin/simple.plx', $script ); + $dist->regen(); + $pm_info = + Module::Build::ModuleInfo->new_from_file( 'Simple/bin/simple.plx' ); + ok( defined( $pm_info ) && $pm_info->version eq '0.01' ); +} -ok( $pm_info->version(), '0.01' ); + +# examine properties of a module: name, pod, etc +$dist->change_file( 'lib/Simple.pm', <<'---' ); +package Simple; +our $VERSION = '0.01'; +1; +package Simple::Ex; +our $VERSION = '0.02'; +1; +=head1 NAME + +Simple - It's easy. + +=head1 AUTHOR + +Simple Simon + +=cut +--- +$dist->regen(); + +$pm_info = Module::Build::ModuleInfo->new_from_module( + 'Simple', inc => [ $inc, @INC ] ); + +ok( $pm_info->name() eq 'Simple' ); + +ok( $pm_info->version() eq '0.01' ); # got correct version for secondary package -ok( $pm_info->version( 'Sample::Ex' ), '0.02' ); +ok( $pm_info->version( 'Simple::Ex' ) eq '0.02' ); my $filename = $pm_info->filename(); ok( defined( $filename ) && length( $filename ) ); my @packages = $pm_info->packages_inside(); -ok( scalar( @packages ), 2 ); -ok( $packages[0], 'Sample' ); +ok( scalar( @packages ) == 2 ); +ok( $packages[0] eq 'Simple' ); # we can detect presence of pod regardless of whether we are collecting it ok( $pm_info->contains_pod() ); my @pod = $pm_info->pod_inside(); -ok( "@pod", 'NAME AUTHOR OTHER' ); +ok( "@pod" eq 'NAME AUTHOR' ); # no pod is collected my $name = $pm_info->pod('NAME'); @@ -70,11 +200,15 @@ # collect_pod $pm_info = Module::Build::ModuleInfo->new_from_module( - 'Sample', inc => [ 't/Sample/lib', @INC ], collect_pod => 1 ); + 'Simple', inc => [ $inc, @INC ], collect_pod => 1 ); $name = $pm_info->pod('NAME'); if ( $name ) { $name =~ s/^\s+//; $name =~ s/\s+$//; } -ok( $name, 'Sample - Foo foo sample foo' ); +ok( $name eq q|Simple - It's easy.| ); + + + +$dist->remove(); |
From: Randy W. S. <si...@us...> - 2005-02-20 10:13:08
|
Update of /cvsroot/module-build/Module-Build/t/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26647/t/lib Added Files: DistGen.pm Log Message: Added module to aid testing by generating and managing simple distributions to test against. --- NEW FILE: DistGen.pm --- package DistGen; use strict; use warnings; use vars qw( $VERSION $VERBOSE ); $VERSION = '0.01'; $VERBOSE = 0; use Cwd (); use File::Basename (); use File::Find (); use File::Path (); use File::Spec (); sub new { my $package = shift; my %options = @_; $options{name} ||= 'Simple'; $options{dir} ||= File::Spec->curdir(); my %data = ( skip_manifest => 0, xs_module => 0, %options, ); my $self = bless( \%data, $package ); $self->_gen_default_filedata(); return $self; } sub _gen_default_filedata { my $self = shift; $self->add_file( 'Build.PL', <<"---" ) unless $self->{filedata}{'Build.PL'}; use strict; use warnings; use Module::Build; my \$builder = Module::Build->new( module_name => '$self->{name}', license => 'perl', ); \$builder->create_build_script(); --- my $module_filename = join( '/', ('lib', split(/::/, $self->{name})) ) . '.pm'; unless ( $self->{xs_module} ) { $self->add_file( $module_filename, <<"---" ) unless $self->{filedata}{$module_filename}; package $self->{name}; our \$VERSION = '0.01'; use strict; use warnings; 1; __END__ =head1 NAME $self->{name} =cut --- $self->add_file( 't/basic.t', <<"---" ) unless $self->{filedata}{'t/basic.t'}; use Test::More tests => 1; use strict; use $self->{name}; ok( 1 ); --- } else { $self->add_file( $module_filename, <<"---" ) unless $self->{filedata}{$module_filename}; package $self->{name}; use base qw( Exporter DynaLoader ); our \$VERSION = '0.01'; our \@EXPORT_OK = qw( ok ); bootstrap $self->{name} \$VERSION; 1; --- my $xs_filename = join( '/', ('lib', split(/::/, $self->{name})) ) . '.xs'; $self->add_file( $xs_filename, <<"---" ) unless $self->{filedata}{$xs_filename}; #include "EXTERN.h" #include "perl.h" #include "XSUB.h" MODULE = $self->{name} PACKAGE = $self->{name} SV * ok() CODE: RETVAL = newSVpv( "ok", 0 ); OUTPUT: RETVAL --- $self->add_file( 't/basic.t', <<"---" ) unless $self->{filedata}{'t/basic.t'}; use Test::More tests => 2; use strict; use $self->{name}; ok( 1 ); ok( $self->{name}::ok() eq 'ok' ); --- } } sub _gen_manifest { my $self = shift; my $manifest = shift; open( my $fh, ">$manifest" ) or do { $self->remove(); die "Can't write '$manifest'\n"; }; print $fh join( "\n", sort keys( %{$self->{filedata}} ) ); print $fh "\n"; close( $fh ); } sub name { shift()->{name} } sub dirname { my $self = shift; my $dist = join( '-', split( /::/, $self->{name} ) ); return File::Spec->catdir( $self->{dir}, $dist ); } sub _real_filename { my $self = shift; my $filename = shift; return File::Spec->catfile( split( /\//, $filename ) ); } sub regen { my $self = shift; my %opts = @_; my $dist_dirname = $self->dirname; if ( $opts{clean} ) { $self->clean() if -d $dist_dirname; } else { # TODO: This might leave dangling directories. Eg if the removed file # is 'lib/Simple/Simon.pm', The directory 'lib/Simple' will be left # even if there are no files left in it. However, clean() will remove it. my @files = keys %{$self->{pending}{remove}}; foreach my $file ( @files ) { my $real_filename = $self->_real_filename( $file ); my $fullname = File::Spec->catfile( $dist_dirname, $real_filename ); unlink( $fullname ) or die "Couldn't unlink '$file'\n"; print "Unlinking pending file '$file'\n" if $VERBOSE; delete( $self->{pending}{remove}{$file} ); } } foreach my $file ( keys( %{$self->{filedata}} ) ) { my $real_filename = $self->_real_filename( $file ); my $fullname = File::Spec->catfile( $dist_dirname, $real_filename ); if ( ! -e $fullname || ( -e $fullname && $self->{pending}{change}{$file} ) ) { print "Changed file '$file'.\n" if $VERBOSE; my $dirname = File::Basename::dirname( $fullname ); unless ( -d $dirname ) { File::Path::mkpath( $dirname ) or do { $self->remove(); die "Can't create '$dirname'\n"; }; } if ( -e $fullname ) { unlink( $fullname ) or die "Can't unlink '$file'\n"; } open( my $fh, ">$fullname" ) or do { $self->remove(); die "Can't write '$fullname'\n"; }; print $fh $self->{filedata}{$file}; close( $fh ); } delete( $self->{pending}{change}{$file} ); } my $manifest = File::Spec->catfile( $dist_dirname, 'MANIFEST' ); unless ( $self->{skip_manifest} ) { if ( -e $manifest ) { unlink( $manifest ) or die "Can't remove '$manifest'\n"; } $self->_gen_manifest( $manifest ); } } sub clean { my $self = shift; my $here = Cwd::abs_path(); my $there = File::Spec->rel2abs( $self->dirname() ); if ( -d $there ) { chdir( $there ) or die "Can't change directory to '$there'\n"; } else { die "Distribution not found in '$there'\n"; } my %names; foreach my $file ( keys %{$self->{filedata}} ) { my $filename = $self->_real_filename( $file ); my $dirname = File::Basename::dirname( $filename ); $names{files}{$filename} = 0; my @dirs = File::Spec->splitdir( $dirname ); while ( @dirs ) { my $dir = File::Spec->catdir( @dirs ); $names{dirs}{$dir} = 0; pop( @dirs ); } } File::Find::finddepth( sub { my $dir = File::Spec->canonpath( $File::Find::dir ); my $name = File::Spec->canonpath( $File::Find::name ); if ( -d && not exists $names{dirs}{$name} ) { print "Removing directory '$name'\n" if $VERBOSE; File::Path::rmtree( $_ ); return; } elsif ( -d ) { return; } elsif ( exists $names{files}{$name} ) { #print "Leaving file '$name'\n" if $VERBOSE; } else { print "Unlinking file '$name'\n" if $VERBOSE; unlink( $_ ); } }, File::Spec->curdir ); chdir( $here ); } sub remove { my $self = shift; File::Path::rmtree( $self->dirname ); } sub revert { my $self = shift; die "Unimplemented.\n"; } sub add_file { my $self = shift; $self->change_file( @_ ); } sub remove_file { my $self = shift; my $file = shift; unless ( exists $self->{filedata}{$file} ) { warn "Can't remove '$file': It does not exist.\n" if $VERBOSE; } delete( $self->{filedata}{$file} ); $self->{pending}{remove}{$file} = 1; } sub change_file { my $self = shift; my $file = shift; my $data = shift; $self->{filedata}{$file} = $data; $self->{pending}{change}{$file} = 1; } 1; __END__ =head1 NAME DistGen =head1 DESCRIPTION =head1 API =head2 Constructor =head3 new() Create a new distribution generator. Does not actually write the contents. =over =item name The name of the module this distribution represents. The default is 'Simple'. =item dir The directory in which to create the distribution directory. The default is File::Spec->curdir. =item xs_module Generates an XS based module. =back =head2 Manipulating the Distribution =head3 regen( [OPTIONS] ) Regenerate all files that are missing or that have changed. If the optional C<clean> argument is given, it also removes any extraneous files that do not belong to the distribution. =over =item clean When true, removes any files not part of the distribution while regenerating. =back =head3 clean() Removes any files that are not part of the distribution. =head3 revert( [$filename] ) [Unimplemented] Returns the object to its initial state, or given a $filename it returns that file to it's initial state if it is one of the built-in files. =head3 remove() Removes the complete distribution. =head2 Editing Files Note that all ${filename}s should be specified with unix-style paths, and are relative to the distribution root directory. Eg 'lib/Module.pm' =head3 add_file( $filename, $content ) Add a $filename containg $content to the distribution. No action is performed until the distribution is regenerated. =head3 remove_file( $filename ) Removes $filename from the distribution. No action is performed until the distribution is regenerated. =head3 change_file( $filename, $content ) Changes the contents of $filename to $content. No action is performed until the distribution is regenerated. =head2 Properties =head3 name() Returns the name of the distribution. =head3 dirname() Returns the directory name where the distribution is created. =cut |
From: Ken W. <kwi...@us...> - 2005-02-18 13:54:24
|
Update of /cvsroot/module-build/Module-Build/lib/Module/Build In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32038 Modified Files: Base.pm Log Message: Fix a typo, features() should have been feature(). Index: Base.pm =================================================================== RCS file: /cvsroot/module-build/Module-Build/lib/Module/Build/Base.pm,v retrieving revision 1.391 retrieving revision 1.392 diff -u -d -r1.391 -r1.392 --- Base.pm 17 Feb 2005 03:06:21 -0000 1.391 +++ Base.pm 18 Feb 2005 13:54:14 -0000 1.392 @@ -821,7 +821,7 @@ next unless -e $self->config_file($_); $self->_persistent_hash_restore($_); } - $self->has_config_data(1) if keys(%{$self->config_data}) || keys(%{$self->features}); + $self->has_config_data(1) if keys(%{$self->config_data}) || keys(%{$self->feature}); } sub _write_dumper { |
From: Ken W. <kwi...@us...> - 2005-02-17 03:06:31
|
Update of /cvsroot/module-build/Module-Build/lib/Module/Build In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7103/lib/Module/Build Modified Files: Base.pm Log Message: Make sure 'has_config_data' is set if there's config_data or features Index: Base.pm =================================================================== RCS file: /cvsroot/module-build/Module-Build/lib/Module/Build/Base.pm,v retrieving revision 1.390 retrieving revision 1.391 diff -u -d -r1.390 -r1.391 --- Base.pm 17 Feb 2005 02:33:57 -0000 1.390 +++ Base.pm 17 Feb 2005 03:06:21 -0000 1.391 @@ -300,7 +300,7 @@ } sub notes { shift()->_general_notes('notes', @_) } -sub config_data { shift()->_general_notes('config_data', @_) } +sub config_data { shift()->_general_notes('config_data', @_) } sub feature { shift()->_general_notes('features', @_) } sub runtime_params { shift->_persistent_hash_read('runtime_params', @_ ? shift : ()) } sub current_action { shift->{action} } @@ -821,6 +821,7 @@ next unless -e $self->config_file($_); $self->_persistent_hash_restore($_); } + $self->has_config_data(1) if keys(%{$self->config_data}) || keys(%{$self->features}); } sub _write_dumper { |
From: Ken W. <kwi...@us...> - 2005-02-17 02:43:47
|
Update of /cvsroot/module-build/Module-Build/t In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3026 Modified Files: ext.t Log Message: Make sure embedded hashes like 'config' can survive read_args( unparse_args() ) Index: ext.t =================================================================== RCS file: /cvsroot/module-build/Module-Build/t/ext.t,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- ext.t 17 Feb 2005 02:42:55 -0000 1.10 +++ ext.t 17 Feb 2005 02:43:37 -0000 1.11 @@ -93,7 +93,7 @@ { # Make sure data can make a round-trip through unparse_args() and read_args() - my %args = (foo => 'bar', food => 'bard'); + my %args = (foo => 'bar', food => 'bard', config => {a => 1, b => 2}); my ($args) = Module::Build->read_args( Module::Build->unparse_args(\%args) ); is_deeply($args, \%args); } |
From: Ken W. <kwi...@us...> - 2005-02-17 02:43:03
|
Update of /cvsroot/module-build/Module-Build/t In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2866 Modified Files: ext.t Log Message: Switch the read_args() test to use is_deeply() Index: ext.t =================================================================== RCS file: /cvsroot/module-build/Module-Build/t/ext.t,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- ext.t 17 Feb 2005 02:40:00 -0000 1.9 +++ ext.t 17 Feb 2005 02:42:55 -0000 1.10 @@ -60,7 +60,7 @@ { 'a " b " c' => [ 'a', ' b ', 'c' ] }, ); -plan tests => 14 + 2*@unix_splits + 2*@win_splits; +plan tests => 10 + 2*@unix_splits + 2*@win_splits; use Module::Build; ok(1); @@ -88,12 +88,7 @@ # Make sure read_args() functions properly as a class method my @args = qw(foo=bar --food bard); my ($args) = Module::Build->read_args(@args); - - is keys(%$args), 3; - is $args->{foo}, 'bar'; - is $args->{food}, 'bard'; - is exists $args->{ARGV}, 1; - is @{$args->{ARGV}}, 0; + is_deeply($args, {foo => 'bar', food => 'bard', ARGV => []}); } { |
From: Ken W. <kwi...@us...> - 2005-02-17 02:40:09
|
Update of /cvsroot/module-build/Module-Build/t In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2273/t Modified Files: ext.t Log Message: Convert to Test::More so we can use is_deeply() Index: ext.t =================================================================== RCS file: /cvsroot/module-build/Module-Build/t/ext.t,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- ext.t 17 Feb 2005 02:33:21 -0000 1.8 +++ ext.t 17 Feb 2005 02:40:00 -0000 1.9 @@ -1,8 +1,13 @@ use strict; -use Test; use File::Spec; +BEGIN { + my $t_lib = File::Spec->catdir('t', 'lib'); + push @INC, $t_lib; # Let user's installed version override +} +use Test::More; + my $common_pl = File::Spec->catfile('t', 'common.pl'); require $common_pl; @@ -55,7 +60,7 @@ { 'a " b " c' => [ 'a', ' b ', 'c' ] }, ); -plan tests => 15 + 2*@unix_splits + 2*@win_splits; +plan tests => 14 + 2*@unix_splits + 2*@win_splits; use Module::Build; ok(1); @@ -64,8 +69,8 @@ foreach my $platform ('', '::Platform::Unix', '::Platform::Windows') { my $pkg = "Module::Build$platform"; my @result = $pkg->split_like_shell(['foo', 'bar', 'baz']); - ok @result, 3, "Split using $pkg"; - ok "@result", "foo bar baz", "Split using $pkg"; + is @result, 3, "Split using $pkg"; + is "@result", "foo bar baz", "Split using $pkg"; } use Module::Build::Platform::Unix; @@ -84,26 +89,25 @@ my @args = qw(foo=bar --food bard); my ($args) = Module::Build->read_args(@args); - ok keys(%$args), 3; - ok $args->{foo}, 'bar'; - ok $args->{food}, 'bard'; - ok exists $args->{ARGV}, 1; - ok @{$args->{ARGV}}, 0; + is keys(%$args), 3; + is $args->{foo}, 'bar'; + is $args->{food}, 'bard'; + is exists $args->{ARGV}, 1; + is @{$args->{ARGV}}, 0; } { # Make sure data can make a round-trip through unparse_args() and read_args() my %args = (foo => 'bar', food => 'bard'); my ($args) = Module::Build->read_args( Module::Build->unparse_args(\%args) ); - ok $args->{foo}, $args{foo}; - ok $args->{food}, $args{food}; + is_deeply($args, \%args); } { # Make sure run_perl_script() propagates @INC local @INC = ('whosiewhatzit', @INC); my $output = stdout_of( sub { Module::Build->run_perl_script('', ['-le', 'print for @INC']) } ); - ok $output, qr{^whosiewhatzit}m; + like $output, qr{^whosiewhatzit}m; } ################################################################## @@ -112,10 +116,8 @@ my ($string, $expected) = %$test; my @result = $package->split_like_shell($string); - ok( 0 + grep( !defined(), @result ), # all defined + is( 0 + grep( !defined(), @result ), # all defined 0, "'$string' result all defined" ); - ok( join(' ', map "{$_}", @result), - join(' ', map "{$_}", @$expected), - join(' ', map "{$_}", @$expected) ); + is_deeply(\@result, $expected); } |
From: Ken W. <kwi...@us...> - 2005-02-17 02:34:06
|
Update of /cvsroot/module-build/Module-Build/lib/Module/Build In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv846 Modified Files: Base.pm Log Message: Fix an unparse_args() bug Index: Base.pm =================================================================== RCS file: /cvsroot/module-build/Module-Build/lib/Module/Build/Base.pm,v retrieving revision 1.389 retrieving revision 1.390 diff -u -d -r1.389 -r1.390 --- Base.pm 17 Feb 2005 01:38:20 -0000 1.389 +++ Base.pm 17 Feb 2005 02:33:57 -0000 1.390 @@ -37,21 +37,23 @@ } sub resume { - my $self = shift()->_construct(@_); - + my $package = shift; + my $self = $package->_construct(@_); $self->read_config; - # When called from current() or new_from_context(), we may need to - # re-bless ourself into the appropriate build_class. - if ( $self->build_class ne ref($self) ) { + # If someone called Module::Build->current() or + # Module::Build->new_from_context() and the correct class to use is + # actually a *subclass* of Module::Build, we may need to load that + # subclass here and re-delegate the resume() method to it. + unless ( UNIVERSAL::isa($package, $self->build_class) ) { + my $build_class = $self->build_class; my $config_dir = $self->config_dir || '_build'; my $build_lib = File::Spec->catdir( $config_dir, 'lib' ); unshift( @INC, $build_lib ); - if ( eval "require @{[$self->build_class]}" ) { - $self = bless( $self, $self->build_class ); - } else { - die "Failed to re-bless into '@{[$self->build_class]}': $@"; + unless ( $build_class->can('new') ) { + eval "require $build_class; 1" or die "Failed to re-load '$build_class': $@"; } + return $build_class->resume(@_); } unless ($self->_perl_is_same($self->{properties}{perl})) { @@ -1227,7 +1229,7 @@ while (my ($k, $v) = each %$args) { push @out, (UNIVERSAL::isa($v, 'HASH') ? map {+"--$k", "$_=$v->{$_}"} keys %$v : UNIVERSAL::isa($v, 'ARRAY') ? map {+"--$k", $_} @$v : - ($k, $v)); + ("--$k", $v)); } return @out; } |
From: Ken W. <kwi...@us...> - 2005-02-17 02:33:33
|
Update of /cvsroot/module-build/Module-Build/t In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv624/t Modified Files: ext.t Log Message: Add a simple test for unparse_args() Index: ext.t =================================================================== RCS file: /cvsroot/module-build/Module-Build/t/ext.t,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- ext.t 7 Jan 2005 10:15:53 -0000 1.7 +++ ext.t 17 Feb 2005 02:33:21 -0000 1.8 @@ -55,7 +55,7 @@ { 'a " b " c' => [ 'a', ' b ', 'c' ] }, ); -plan tests => 13 + 2*@unix_splits + 2*@win_splits; +plan tests => 15 + 2*@unix_splits + 2*@win_splits; use Module::Build; ok(1); @@ -92,6 +92,14 @@ } { + # Make sure data can make a round-trip through unparse_args() and read_args() + my %args = (foo => 'bar', food => 'bard'); + my ($args) = Module::Build->read_args( Module::Build->unparse_args(\%args) ); + ok $args->{foo}, $args{foo}; + ok $args->{food}, $args{food}; +} + +{ # Make sure run_perl_script() propagates @INC local @INC = ('whosiewhatzit', @INC); my $output = stdout_of( sub { Module::Build->run_perl_script('', ['-le', 'print for @INC']) } ); |
From: Ken W. <kwi...@us...> - 2005-02-17 02:25:34
|
Update of /cvsroot/module-build/Module-Build/t In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30635/t Modified Files: compat.t Log Message: Revert to previous revision, now that it can work again Index: compat.t =================================================================== RCS file: /cvsroot/module-build/Module-Build/t/compat.t,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -r1.21 -r1.22 --- compat.t 12 Feb 2005 14:07:36 -0000 1.21 +++ compat.t 17 Feb 2005 02:25:18 -0000 1.22 @@ -73,7 +73,7 @@ # Make sure custom builder subclass is used in the created # Makefile.PL - make sure it fails in the right way here. local @Foo::Builder::ISA = qw(Module::Build); - my $foo_builder = bless( Module::Build->new_from_context, 'Foo::Builder' ); + my $foo_builder = Foo::Builder->new_from_context(); foreach my $style ('passthrough', 'small') { Module::Build::Compat->create_makefile_pl($style, $foo_builder); ok -e 'Makefile.PL'; |
From: Ken W. <kwi...@us...> - 2005-02-17 01:38:39
|
Update of /cvsroot/module-build/Module-Build/lib/Module/Build In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18386/lib/Module/Build Modified Files: Base.pm Log Message: Add a new unparse_args() method and use it in new_from_context() Index: Base.pm =================================================================== RCS file: /cvsroot/module-build/Module-Build/lib/Module/Build/Base.pm,v retrieving revision 1.388 retrieving revision 1.389 diff -u -d -r1.388 -r1.389 --- Base.pm 16 Feb 2005 12:36:06 -0000 1.388 +++ Base.pm 17 Feb 2005 01:38:20 -0000 1.389 @@ -77,7 +77,7 @@ # XXX Read the META.yml and see whether we need to run the Build.PL? # Run the Build.PL - $package->run_perl_script('Build.PL', [], [map {"--$_", $args{$_}} keys %args]); + $package->run_perl_script('Build.PL', [], [$package->unparse_args(\%args)]); return $package->resume; } @@ -1221,6 +1221,17 @@ return $args, @ARGV; } +sub unparse_args { + my ($self, $args) = @_; + my @out; + while (my ($k, $v) = each %$args) { + push @out, (UNIVERSAL::isa($v, 'HASH') ? map {+"--$k", "$_=$v->{$_}"} keys %$v : + UNIVERSAL::isa($v, 'ARRAY') ? map {+"--$k", $_} @$v : + ($k, $v)); + } + return @out; +} + sub args { my $self = shift; return wantarray ? %{ $self->{args} } : $self->{args} unless @_; |
From: Ken W. <kwi...@us...> - 2005-02-16 12:39:06
|
Update of /cvsroot/module-build/Module-Build In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10977 Modified Files: Changes Log Message: Index: Changes =================================================================== RCS file: /cvsroot/module-build/Module-Build/Changes,v retrieving revision 1.331 retrieving revision 1.332 diff -u -d -r1.331 -r1.332 --- Changes 12 Feb 2005 14:07:34 -0000 1.331 +++ Changes 16 Feb 2005 12:38:57 -0000 1.332 @@ -3,6 +3,11 @@ 0.27_01 (Beta for 0.28) + - new_from_context() was losing its arguments in some cases (and not + because of inadequate training in debate) - we now pass its + arguments directly to the Build.PL script rather than merging them + in afterwards. + - Let resume() return an object blessed into the appropriate class if the user has provided a subclass, as specified by the 'build_class' property. This allows current() and new_from_context() |
From: Ken W. <kwi...@us...> - 2005-02-16 12:36:27
|
Update of /cvsroot/module-build/Module-Build/lib/Module/Build In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10330/lib/Module/Build Modified Files: Base.pm Log Message: Feed new_from_context() arguments right to the Build.PL Index: Base.pm =================================================================== RCS file: /cvsroot/module-build/Module-Build/lib/Module/Build/Base.pm,v retrieving revision 1.387 retrieving revision 1.388 diff -u -d -r1.387 -r1.388 --- Base.pm 12 Feb 2005 14:07:35 -0000 1.387 +++ Base.pm 16 Feb 2005 12:36:06 -0000 1.388 @@ -74,13 +74,11 @@ sub new_from_context { my ($package, %args) = @_; - # XXX Read the META.yml and see whether we need to run the Build.PL + # XXX Read the META.yml and see whether we need to run the Build.PL? # Run the Build.PL - $package->run_perl_script('Build.PL'); - my $self = $package->resume; - $self->merge_args(undef, %args); - return $self; + $package->run_perl_script('Build.PL', [], [map {"--$_", $args{$_}} keys %args]); + return $package->resume; } sub current { |
From: Randy W. S. <si...@us...> - 2005-02-12 14:07:45
|
Update of /cvsroot/module-build/Module-Build/t In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5422/t Modified Files: compat.t Log Message: Let resume() return an object blessed into the appropriate class if the user has provided a subclass, as specified by the 'build_class' property. Index: compat.t =================================================================== RCS file: /cvsroot/module-build/Module-Build/t/compat.t,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -r1.20 -r1.21 --- compat.t 7 Jan 2005 10:15:53 -0000 1.20 +++ compat.t 12 Feb 2005 14:07:36 -0000 1.21 @@ -73,7 +73,7 @@ # Make sure custom builder subclass is used in the created # Makefile.PL - make sure it fails in the right way here. local @Foo::Builder::ISA = qw(Module::Build); - my $foo_builder = Foo::Builder->new_from_context(); + my $foo_builder = bless( Module::Build->new_from_context, 'Foo::Builder' ); foreach my $style ('passthrough', 'small') { Module::Build::Compat->create_makefile_pl($style, $foo_builder); ok -e 'Makefile.PL'; |
From: Randy W. S. <si...@us...> - 2005-02-12 14:07:44
|
Update of /cvsroot/module-build/Module-Build/lib/Module/Build In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5422/lib/Module/Build Modified Files: Base.pm Log Message: Let resume() return an object blessed into the appropriate class if the user has provided a subclass, as specified by the 'build_class' property. Index: Base.pm =================================================================== RCS file: /cvsroot/module-build/Module-Build/lib/Module/Build/Base.pm,v retrieving revision 1.386 retrieving revision 1.387 diff -u -d -r1.386 -r1.387 --- Base.pm 9 Feb 2005 10:21:39 -0000 1.386 +++ Base.pm 12 Feb 2005 14:07:35 -0000 1.387 @@ -40,7 +40,20 @@ my $self = shift()->_construct(@_); $self->read_config; - + + # When called from current() or new_from_context(), we may need to + # re-bless ourself into the appropriate build_class. + if ( $self->build_class ne ref($self) ) { + my $config_dir = $self->config_dir || '_build'; + my $build_lib = File::Spec->catdir( $config_dir, 'lib' ); + unshift( @INC, $build_lib ); + if ( eval "require @{[$self->build_class]}" ) { + $self = bless( $self, $self->build_class ); + } else { + die "Failed to re-bless into '@{[$self->build_class]}': $@"; + } + } + unless ($self->_perl_is_same($self->{properties}{perl})) { my $perl = $self->find_perl_interpreter; $self->log_warn(" * WARNING: Configuration was initially created with '$self->{properties}{perl}',\n". |
From: Randy W. S. <si...@us...> - 2005-02-12 14:07:44
|
Update of /cvsroot/module-build/Module-Build In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5422 Modified Files: Changes Log Message: Let resume() return an object blessed into the appropriate class if the user has provided a subclass, as specified by the 'build_class' property. Index: Changes =================================================================== RCS file: /cvsroot/module-build/Module-Build/Changes,v retrieving revision 1.330 retrieving revision 1.331 diff -u -d -r1.330 -r1.331 --- Changes 11 Feb 2005 03:53:47 -0000 1.330 +++ Changes 12 Feb 2005 14:07:34 -0000 1.331 @@ -3,6 +3,12 @@ 0.27_01 (Beta for 0.28) + - Let resume() return an object blessed into the appropriate class + if the user has provided a subclass, as specified by the + 'build_class' property. This allows current() and new_from_context() + to behave more like factory methods returning objects of the correct + class based on context. [Ray Zimmerman] + - M::B::ModuleInfo would not read the $VERSION in the assumed package 'main' of a script unless the $VERSION line was the first non-empty line in the script. [David Wheeler] |
From: Randy W. S. <si...@us...> - 2005-02-11 03:53:57
|
Update of /cvsroot/module-build/Module-Build/t/Sample/bin In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17575/t/Sample/bin Modified Files: sample.pl Log Message: M::B::ModuleInfo would not read the $VERSION in the assumed package 'main' of a script unless the $VERSION line was the first non-empty line in the script. [David Wheeler] Index: sample.pl =================================================================== RCS file: /cvsroot/module-build/Module-Build/t/Sample/bin/sample.pl,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- sample.pl 21 Jul 2003 17:08:49 -0000 1.1 +++ sample.pl 11 Feb 2005 03:53:48 -0000 1.2 @@ -1,5 +1,10 @@ #!perl -w +use strict; +our $VERSION = '0.01'; # M::B::ModuleInfo should see this version in 'main' + # when it's not the first non-empty line in the + # assumed package main. + print "Hello, world"; __END__ |
From: Randy W. S. <si...@us...> - 2005-02-11 03:53:57
|
Update of /cvsroot/module-build/Module-Build/t In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17575/t Modified Files: moduleinfo.t Log Message: M::B::ModuleInfo would not read the $VERSION in the assumed package 'main' of a script unless the $VERSION line was the first non-empty line in the script. [David Wheeler] Index: moduleinfo.t =================================================================== RCS file: /cvsroot/module-build/Module-Build/t/moduleinfo.t,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- moduleinfo.t 7 Jan 2005 11:09:10 -0000 1.1 +++ moduleinfo.t 11 Feb 2005 03:53:48 -0000 1.2 @@ -1,7 +1,7 @@ use strict; use Test; -BEGIN { plan tests => 17 } +BEGIN { plan tests => 18 } use Module::Build::ModuleInfo; ok(1); @@ -29,6 +29,8 @@ Module::Build::ModuleInfo->new_from_file( 't/Sample/bin/sample.pl' ); ok( defined( $pm_info ) ); +# find $VERSION in non-declared package main of script +ok( $pm_info->version('main'), '0.01' ); # fail on invalid module name $pm_info = Module::Build::ModuleInfo->new_from_module( 'Foo::Bar' ); |
From: Randy W. S. <si...@us...> - 2005-02-11 03:53:56
|
Update of /cvsroot/module-build/Module-Build/lib/Module/Build In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17575/lib/Module/Build Modified Files: ModuleInfo.pm Log Message: M::B::ModuleInfo would not read the $VERSION in the assumed package 'main' of a script unless the $VERSION line was the first non-empty line in the script. [David Wheeler] Index: ModuleInfo.pm =================================================================== RCS file: /cvsroot/module-build/Module-Build/lib/Module/Build/ModuleInfo.pm,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- ModuleInfo.pm 7 Jan 2005 11:09:09 -0000 1.1 +++ ModuleInfo.pm 11 Feb 2005 03:53:48 -0000 1.2 @@ -144,7 +144,8 @@ push( @pkgs, $pkg ); } elsif ( $line =~ $VERS_REGEXP ) { - unless ( defined( $vers{$pkg} ) ) { # only first VERSION + # only first keep if this is the first $VERSION seen + unless ( defined $vers{$pkg} && length $vers{$pkg} ) { my $v = $self->_evaluate_version_line( $line ); $vers{$pkg} = $v; } |
From: Randy W. S. <si...@us...> - 2005-02-11 03:53:56
|
Update of /cvsroot/module-build/Module-Build In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17575 Modified Files: Changes Log Message: M::B::ModuleInfo would not read the $VERSION in the assumed package 'main' of a script unless the $VERSION line was the first non-empty line in the script. [David Wheeler] Index: Changes =================================================================== RCS file: /cvsroot/module-build/Module-Build/Changes,v retrieving revision 1.329 retrieving revision 1.330 diff -u -d -r1.329 -r1.330 --- Changes 24 Jan 2005 22:00:18 -0000 1.329 +++ Changes 11 Feb 2005 03:53:47 -0000 1.330 @@ -3,6 +3,10 @@ 0.27_01 (Beta for 0.28) + - M::B::ModuleInfo would not read the $VERSION in the assumed package + 'main' of a script unless the $VERSION line was the first non-empty + line in the script. [David Wheeler] + - Added new method Module::Build::prepare_metadata() for authors to override in order to add custom fields to META.yml. |
From: Randy W. S. <si...@us...> - 2005-02-09 10:22:03
|
Update of /cvsroot/module-build/Module-Build/lib/Module/Build In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24411/lib/Module/Build Modified Files: Base.pm Log Message: Integrate from branch. Index: Base.pm =================================================================== RCS file: /cvsroot/module-build/Module-Build/lib/Module/Build/Base.pm,v retrieving revision 1.385 retrieving revision 1.386 diff -u -d -r1.385 -r1.386 --- Base.pm 8 Feb 2005 07:15:18 -0000 1.385 +++ Base.pm 9 Feb 2005 10:21:39 -0000 1.386 @@ -1739,7 +1739,7 @@ or die "The 'testpod' action requires Test::Pod version 0.95"; my @files = sort keys %{$self->_find_pods($self->libdoc_dirs)}, - keys %{$self->_find_pods($self->bindoc_dirs)} + keys %{$self->_find_pods($self->bindoc_dirs, exclude => [ qr/\.bat$/ ])} or die "Couldn't find any POD files to test\n"; { package Module::Build::PodTester; # Don't want to pollute the main namespace @@ -1772,7 +1772,8 @@ my $self = shift; require Pod::Man; my $parser = Pod::Man->new( section => 1 ); # binary manpages go in section 1 - my $files = $self->_find_pods($self->{properties}{bindoc_dirs}); + my $files = $self->_find_pods( $self->{properties}{bindoc_dirs}, + exclude => [ qr/\.bat$/ ] ); return unless keys %$files; my $mandir = File::Spec->catdir( $self->blib, 'bindoc' ); @@ -1809,13 +1810,17 @@ } sub _find_pods { - my ($self, $dirs) = @_; + my ($self, $dirs, %args) = @_; my %files; foreach my $spec (@$dirs) { my $dir = $self->localize_file_path($spec); next unless -e $dir; - do { $files{$_} = File::Spec->abs2rel($_, $dir) if $self->contains_pod( $_ ) } - for @{ $self->rscan_dir( $dir ) }; + FILE: foreach my $file ( @{ $self->rscan_dir( $dir ) } ) { + foreach my $regexp ( @{ $args{exclude} } ) { + next FILE if $file =~ $regexp; + } + $files{$file} = File::Spec->abs2rel($file, $dir) if $self->contains_pod( $file ) + } } return \%files; } @@ -1840,93 +1845,83 @@ sub htmlify_pods { my $self = shift; + require Module::Build::PodParser; - - my $blib = $self->blib; - my $html = File::Spec::Unix->catdir($blib, 'html'); - my $script = File::Spec::Unix->catdir($blib, 'script'); - - unless (-d $html) { - File::Path::mkpath($html, 1, 0755) or die "Couldn't mkdir $html: $!"; - } - - my $pods = $self->_find_pods([ @{$self->libdoc_dirs}, @{$self->libdoc_dirs} ]); - if (-d $script) { - File::Find::finddepth( sub { - $pods->{$File::Find::name} = - File::Spec->catfile("script", - File::Basename::basename($File::Find::name) ) - if (-f $_ and not /\.bat$/ and $self->contains_pod($_)); - }, $script); + require Pod::Html; + + my $pods = $self->_find_pods( [ @{$self->libdoc_dirs}, + @{$self->bindoc_dirs} ], + exclude => [ qr/\.(?:bat|com|html)$/ ] ); + + my $podpath = join ':', + map $_->[1], + grep -e $_->[0], + map [File::Spec->catdir($self->blib, $_), $_], + qw( script lib ); + + my $htmldir = File::Spec::Unix->catdir($self->blib, 'html'); + unless (-d $htmldir) { + File::Path::mkpath($htmldir, 0, 0755) or die "Couldn't mkdir $htmldir: $!"; } - - my %opts = ( - css => $self->html_css, - backlink => $self->html_backlink, - htmldir => $html, - ); + + $self->add_to_cleanup('pod2htm*'); foreach my $pod (keys %$pods){ - $self->_htmlify_pod( - path => $pod, - rel_path => $pods->{$pod}, - %opts, - ); - } -} -# The distinction here between htmlify_pods() and _htmlify_pod() is a -# little silly. -sub _htmlify_pod { - my ($self, %args) = @_; - require Pod::Html; + my $isbin = 0; + { + my @d = File::Spec->splitdir( + File::Spec->canonpath( (File::Spec->splitpath($pod))[1] ) ); + $isbin = pop( @d ) eq 'script'; + } - $self->add_to_cleanup('pod2htm*'); - - my ($name, $path) = File::Basename::fileparse($args{rel_path}, qr{\..*}); - my @dirs = File::Spec->splitdir($path); - my $isbin = shift @dirs eq 'script'; - my $infile = File::Spec::Unix->abs2rel($args{path}); - - my @rootdirs = $isbin? ('bin') : ('site', 'lib'); - - my $fulldir = File::Spec::Unix->catfile($args{htmldir}, @rootdirs, @dirs); - my $outfile = File::Spec::Unix->catfile($fulldir, $name . '.html'); + my @rootdirs = $isbin ? ('bin') : ('site', 'lib'); + + my ($name, $path) = File::Basename::fileparse($pods->{$pod}, qr{\..*}); + my @dirs = File::Spec->splitdir( File::Spec->canonpath( $path ) ); + pop( @dirs ) if $dirs[-1] eq File::Spec->curdir; + + my $fulldir = File::Spec::Unix->catfile($htmldir, @rootdirs, @dirs); + my $outfile = File::Spec::Unix->catfile($fulldir, $name . '.html'); + my $infile = File::Spec::Unix->abs2rel($pod); + + return if $self->up_to_date($infile, $outfile); + + unless (-d $fulldir){ + File::Path::mkpath($fulldir, 0, 0755) + or die "Couldn't mkdir $fulldir: $!"; + } + + my $path2root = "../" x (@rootdirs+@dirs); + my $htmlroot = File::Spec::Unix->catdir($path2root, 'site'); + + my $title = join('::', (@dirs, $name)); + { + my $fh = IO::File->new($infile); + my $abstract = Module::Build::PodParser->new(fh => $fh)->get_abstract(); + $title .= " - $abstract" if $abstract; + } + + my @opts = ( + '--flush', + "--title=$title", + "--podpath=$podpath", + "--infile=$infile", + "--outfile=$outfile", + '--podroot=' . $self->blib, + "--htmlroot=$htmlroot", + eval {Pod::Html->VERSION(1.03); 1} ? + ('--header', '--backlink=' . $self->html_backlink) : (), + ); + + push( @opts, "--css=$path2root/". $self->html_css ) if $self->html_css; + + $self->log_info("HTMLifying $infile -> $outfile\n"); + $self->log_verbose("pod2html @opts\n"); + Pod::Html::pod2html(@opts); # or warn "pod2html @opts failed: $!"; - return if $self->up_to_date($infile, $outfile); - - unless (-d $fulldir){ - File::Path::mkpath($fulldir, 1, 0755) - or die "Couldn't mkdir $fulldir: $!"; - } - - my $path2root = "../" x (@rootdirs+@dirs-1); - my $htmlroot = File::Spec::Unix->catdir($path2root, 'site'); - my $podpath = join ":" => ($isbin ? qw(script lib) : qw(lib)); - my $title = join('::', @dirs) . $name; - - { - my $fh = IO::File->new($infile); - my $abstract = Module::Build::PodParser->new(fh => $fh)->get_abstract(); - $title .= " - $abstract" if $abstract; } - - my $blib = $self->blib; - my @opts = ( - '--flush', - "--title=$title", - "--podpath=$podpath", - "--infile=$infile", - "--outfile=$outfile", - "--podroot=$blib", - "--htmlroot=$htmlroot", - eval {Pod::Html->VERSION(1.03); 1} ? ('--header', "--backlink=$args{backlink}") : (), - ); - push @opts, "--css=$path2root/$args{css}" if $args{css}; - - $self->log_info("Creating $outfile\n"); - $self->log_verbose("pod2html @opts\n"); - Pod::Html::pod2html(@opts); # or warn "pod2html @opts failed: $!"; + } # Adapted from ExtUtils::MM_Unix |