Update of /cvsroot/module-build/Module-Build/lib/Module/Build
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27503/lib/Module/Build
Modified Files:
Base.pm
Log Message:
Make script_files a bit smarter
Index: Base.pm
===================================================================
RCS file: /cvsroot/module-build/Module-Build/lib/Module/Build/Base.pm,v
retrieving revision 1.346
retrieving revision 1.347
diff -C2 -d -r1.346 -r1.347
*** Base.pm 15 Nov 2004 16:16:25 -0000 1.346
--- Base.pm 15 Nov 2004 18:38:50 -0000 1.347
***************
*** 12,15 ****
--- 12,16 ----
use Data::Dumper ();
use IO::File ();
+ use IO::Dir ();
use Text::ParseWords ();
***************
*** 2127,2130 ****
--- 2128,2146 ----
}
+ sub _files_in {
+ my ($self, $dir) = @_;
+ return unless -d $dir;
+
+ my $dh = IO::Dir->new( $dir ) or die "Can't read directory $dir: $!";
+
+ my @files;
+ while (defined (my $file = $dh->read)) {
+ my $full_path = File::Spec->catfile($dir, $file);
+ next if -d $full_path;
+ push @files, $full_path;
+ }
+ return @files;
+ }
+
sub script_files {
my $self = shift;
***************
*** 2132,2142 ****
for ($self->{properties}{script_files}) {
$_ = shift if @_;
! return unless $_;
# Always coerce into a hash
return $_ if UNIVERSAL::isa($_, 'HASH');
! return $_ = {$_ => 1} unless ref();
! return { map {$_,1} @$_ };
}
}
BEGIN { *scripts = \&script_files; }
--- 2148,2164 ----
for ($self->{properties}{script_files}) {
$_ = shift if @_;
! next unless $_;
# Always coerce into a hash
return $_ if UNIVERSAL::isa($_, 'HASH');
! return $_ = { map {$_,1} @$_ } if UNIVERSAL::isa($_, 'ARRAY');
!
! die "'script_files' must be a hashref, arrayref, or string" if ref();
!
! return $_ = { map {$_,1} $self->_files_in( $_ ) } if -d $_;
! return $_ = {$_ => 1};
}
+
+ return $_ = { map {$_,1} $self->_files_in( File::Spec->catdir( $self->base_dir, 'bin' ) ) };
}
BEGIN { *scripts = \&script_files; }
|