Perl-Dist-WiX

changeset 1040:6d683fb22a32

NOW the multiple-modules stuff is tested and works!

(given that the required modules have been installed on the Perl being created)
author Curtis Jewell <perl@curtisjewell.name>
date Mon Jun 06 00:08:45 2011 -0600 (2011-06-06)
parents fdf15fdf6ece
children a86e6ccc997e
files lib/Perl/Dist/WiX/Asset/Module.pm lib/Perl/Dist/WiX/Mixin/Installation.pm lib/Perl/Dist/WiX/Role/Asset.pm lib/Perl/Dist/WiX/Types.pm
line diff
     1.1 --- a/lib/Perl/Dist/WiX/Asset/Module.pm	Sun Jun 05 21:04:17 2011 -0600
     1.2 +++ b/lib/Perl/Dist/WiX/Asset/Module.pm	Mon Jun 06 00:08:45 2011 -0600
     1.3 @@ -28,10 +28,11 @@
     1.4  #<<<
     1.5  use 5.010;
     1.6  use Moose;
     1.7 -use MooseX::Types::Moose         qw( Maybe Str Bool ArrayRef );
     1.8 +use MooseX::Types::Moose         qw( Maybe Str Bool );
     1.9 +use Perl::Dist::WiX::Types       qw( OneOrManyStr );
    1.10  use English                      qw( -no_match_vars );
    1.11  use File::Spec::Functions        qw( catdir catfile );
    1.12 -use File::Slurp                  qw( slurp_file );
    1.13 +use File::Slurp                  qw( read_file );
    1.14  use Perl::Dist::WiX::Exceptions  qw();
    1.15  use File::List::Object           qw();
    1.16  use IO::File                     qw();
    1.17 @@ -65,12 +66,11 @@
    1.18  
    1.19  =cut
    1.20  
    1.21 -
    1.22 -
    1.23  has name => (
    1.24  	is       => 'ro',
    1.25 -	isa      => Str | ArrayRef[Str]
    1.26 +	isa      => OneOrManyStr,
    1.27  	reader   => 'get_name',
    1.28 +	coerce   => 1,
    1.29  	required => 1,
    1.30  );
    1.31  
    1.32 @@ -188,14 +188,10 @@
    1.33  	    !$self->_get_parent()->portable()                    ? 1
    1.34  	  : ( $self->_get_parent()->perl_major_version() >= 12 ) ? 1
    1.35  	  :                                                        0;
    1.36 -	my $multiple_names = 0;
    1.37 -	my $name_ref = [$name];
    1.38   
    1.39 -	if (ref $name) { # We have multiple modules to install.
    1.40 -		$name_ref = $name;
    1.41 -		$multiple_names = 1;
    1.42 -		$name = join q{ }, @{$name_ref};
    1.43 -	}
    1.44 +	my $name_ref = $name;
    1.45 +	my $multiple_names = (scalar @$name > 1) ? 1 : 0;
    1.46 +	$name = join q{ }, @{$name_ref};
    1.47  	  
    1.48  	# Verify the existence of perl.
    1.49  	if ( not $self->_get_bin_perl() ) {
    1.50 @@ -254,9 +250,9 @@
    1.51  	my \$id = \$module->distribution()->pretty_id();
    1.52  	my \$module_id = \$name;
    1.53  	\$module_id =~ s{::}{_}gmsx;
    1.54 -	my \$filename = catfile("$output_dir", "\$module_id.output.txt");
    1.55 +	my \$filename = catfile('$output_dir', "\$module_id.output.txt");
    1.56  	write_file(\$filename, \$output);
    1.57 -	die "Installation of \$name failed: \$error\\n" if $error;
    1.58 +	die "Installation of \$name failed: \$error\\n" if \$error;
    1.59  
    1.60  	say \$cpan_fh "\$name;\$id;\$filename;"  or die "say: \$!";
    1.61  	print "Completed install of \$name\\n";
    1.62 @@ -271,7 +267,7 @@
    1.63  	# Scan the perl directory if that's needed.
    1.64  	my $filelist_sub;
    1.65  	if ( not $self->_get_packlist() ) {
    1.66 -		if ($multiple_modules) {
    1.67 +		if ($multiple_names) {
    1.68  			PDWiX::Parameter->throw(
    1.69  				parameter => 'packlist: Cannot be 0 when ' 
    1.70  				  . 'installing multiple modules at once.',
    1.71 @@ -316,7 +312,7 @@
    1.72  	if ( -r $dist_file ) {
    1.73  		my @dist_info;
    1.74  		eval { 
    1.75 -			@dist_info = slurp_file( $dist_file );
    1.76 +			@dist_info = read_file( $dist_file );
    1.77  			1;
    1.78  		} || PDWiX->throw("CPAN modules file error: $EVAL_ERROR");
    1.79  
    1.80 @@ -327,7 +323,7 @@
    1.81  				$self->_trace_line( 0,
    1.82  					"Module $module_name was up-to-date\n" );
    1.83  			} else {
    1.84 -				$self->_add_to_distributions_installed($dist_info);
    1.85 +				$self->_add_to_distributions_installed($dist_installed);
    1.86  				push @modules_installed, $module_name;
    1.87  				if ($packlist_flag) {
    1.88  					# The filelist is filtered during _search_packlist.
    1.89 @@ -354,7 +350,7 @@
    1.90  	}
    1.91  
    1.92  	# Returns the filelists.
    1.93 -	return \@filelists;
    1.94 +	return \%filelists;
    1.95  } ## end sub install
    1.96  
    1.97  no Moose;
     2.1 --- a/lib/Perl/Dist/WiX/Mixin/Installation.pm	Sun Jun 05 21:04:17 2011 -0600
     2.2 +++ b/lib/Perl/Dist/WiX/Mixin/Installation.pm	Mon Jun 06 00:08:45 2011 -0600
     2.3 @@ -284,7 +284,7 @@
     2.4  	my $filelists = $module->install();
     2.5  	my $feature   = $module->get_feature();
     2.6  	
     2.7 -	foreach $module_name (keys %{$filelists}) {
     2.8 +	foreach my $module_name (keys %{$filelists}) {
     2.9  		my $filelist = $filelists->{$module_name};
    2.10  
    2.11  		# Make legal fragment id.
    2.12 @@ -335,11 +335,17 @@
    2.13  		%args = %{ pop @_ };
    2.14  	}
    2.15  
    2.16 -	foreach my $name (@_) {
    2.17 +	# Install modules 5-at-a-time.
    2.18 +	my ($i, $j) = (0, 4);
    2.19 +	my $final = scalar @_;
    2.20 +	while ($i < $final) {
    2.21 +		$j = $i + 4;
    2.22 +		$j = $final - 1 unless $j < $final;
    2.23  		$self->install_module(
    2.24 -			name => $name,
    2.25 +			name => [@_[$i..$j]],
    2.26  			%args
    2.27  		);
    2.28 +		$i += 5;
    2.29  	}
    2.30  
    2.31  	return $self;
     3.1 --- a/lib/Perl/Dist/WiX/Role/Asset.pm	Sun Jun 05 21:04:17 2011 -0600
     3.2 +++ b/lib/Perl/Dist/WiX/Role/Asset.pm	Mon Jun 06 00:08:45 2011 -0600
     3.3 @@ -340,7 +340,7 @@
     3.4  
     3.5  		# Parse the output read in for filenames.
     3.6  		my @files_list =
     3.7 -		  map { ## no critic 'ProhibitComplexMappings'
     3.8 +		  map { ## no critic(ProhibitComplexMappings)
     3.9  			my $t = $_;
    3.10  			chomp $t;
    3.11  			( $t =~ / \A Installing [ ] (.*) \z /msx ) ? ($1) : ();
     4.1 --- a/lib/Perl/Dist/WiX/Types.pm	Sun Jun 05 21:04:17 2011 -0600
     4.2 +++ b/lib/Perl/Dist/WiX/Types.pm	Mon Jun 06 00:08:45 2011 -0600
     4.3 @@ -30,6 +30,7 @@
     4.4  	  ExistingSubdirectory ExistingDirectory_Spaceless
     4.5  	  ExistingDirectory_SaneSlashes
     4.6  	  DirectoryRef DirectoryTag
     4.7 +	  OneOrManyStr
     4.8  	  ) ];
     4.9  use MooseX::Types::Moose qw( Str Object ArrayRef );
    4.10  use MooseX::Types::Path::Class qw( Dir File );
    4.11 @@ -142,6 +143,12 @@
    4.12  
    4.13  class_type DirectoryTag, { class => 'Perl::Dist::WiX::Tag::Directory' };
    4.14  
    4.15 +subtype OneOrManyStr,
    4.16 +  as ArrayRef[ Str ];
    4.17 +  
    4.18 +coerce OneOrManyStr,
    4.19 +  from Str, via { [ $_ ] };
    4.20 +
    4.21  1;
    4.22  
    4.23  __END__