[Bps-public-commit] r18742 - Shipwright/trunk/lib/Shipwright/Source

sunnavy at bestpractical.com sunnavy at bestpractical.com
Mon Mar 9 08:31:20 EDT 2009


Author: sunnavy
Date: Mon Mar  9 08:31:19 2009
New Revision: 18742

Modified:
   Shipwright/trunk/lib/Shipwright/Source/Base.pm
   Shipwright/trunk/lib/Shipwright/Source/CPAN.pm

Log:
added Bundle:: modules support

Modified: Shipwright/trunk/lib/Shipwright/Source/Base.pm
==============================================================================
--- Shipwright/trunk/lib/Shipwright/Source/Base.pm	(original)
+++ Shipwright/trunk/lib/Shipwright/Source/Base.pm	Mon Mar  9 08:31:19 2009
@@ -99,7 +99,51 @@
         my $require = {};
         chdir catdir($path);
 
-        if ( -e 'Build.PL' ) {
+        if ( $path =~ /\bcpan-Bundle-(.*)/ ) {
+
+            my $file = $1;
+            $file =~ s!-!/!;
+            $file .= '.pm';
+
+            # so it's a bundle module
+            open my $fh, '<', 'MANIFEST' or confess "no manifest found: $!";
+            while (<$fh>) {
+                chomp;
+                if (/$file/) {
+                    $file = $_;
+                    last;
+                }
+            }
+            open $fh, '<', $file or confess "can't open $file: $!";
+            my $flip;
+            while (<$fh>) {
+                chomp;
+                next if /^\s*$/;
+
+                if (/^=head1\s+CONTENTS/) {
+                    $flip = 1;
+                    next;
+                }
+                elsif (/^=(?!head1\s+CONTENTS)/) {
+                    $flip = 0;
+                }
+
+                next unless $flip;
+                my $info;
+                if (/(.*?)-/) {
+
+                    # things following '-' are comments which we don't want here
+                    $info = $1;
+                }
+                else {
+                    $info = $_;
+                }
+                my ( $module, $version ) = split /\s+/, $info;
+                $require->{requires}{$module} = $version || 0;
+            }
+
+        }
+        elsif ( -e 'Build.PL' ) {
             Shipwright::Util->run(
                 [
                     $^X,               '-Mversion',
@@ -324,7 +368,6 @@
 
                     opendir my $dir, $self->directory;
                     my @sources = readdir $dir;
-
                     close $dir;
 
                     #reload map

Modified: Shipwright/trunk/lib/Shipwright/Source/CPAN.pm
==============================================================================
--- Shipwright/trunk/lib/Shipwright/Source/CPAN.pm	(original)
+++ Shipwright/trunk/lib/Shipwright/Source/CPAN.pm	Mon Mar  9 08:31:19 2009
@@ -130,7 +130,8 @@
     else {
 
         # it's a module
-        my $module = CPAN::Shell->expand( 'Module', $self->source );
+        my $type = $self->source =~ /^Bundle/ ? 'Bundle' : 'Module';
+        my $module = CPAN::Shell->expand( $type, $self->source );
 
         unless ($module) {
             $self->log->warn( "can't find "
@@ -173,6 +174,7 @@
     $self->_update_map( $self->source, 'cpan-' . $name );
 
     $self->source($distribution->get_file_onto_local_disk);
+
     return 1;
 }
 



More information about the Bps-public-commit mailing list