[Bps-public-commit] r10790 - in Shipwright/lib: Shipwright Shipwright/Backend Shipwright/Source

sunnavy at bestpractical.com sunnavy at bestpractical.com
Sun Feb 10 09:10:35 EST 2008


Author: sunnavy
Date: Sun Feb 10 09:10:34 2008
New Revision: 10790

Modified:
   Shipwright/lib/Shipwright.pm
   Shipwright/lib/Shipwright/Backend/SVK.pm
   Shipwright/lib/Shipwright/Backend/SVN.pm
   Shipwright/lib/Shipwright/Build.pm
   Shipwright/lib/Shipwright/Source.pm
   Shipwright/lib/Shipwright/Source/Base.pm

Log:
move log init into new

Modified: Shipwright/lib/Shipwright.pm
==============================================================================
--- Shipwright/lib/Shipwright.pm	(original)
+++ Shipwright/lib/Shipwright.pm	Sun Feb 10 09:10:34 2008
@@ -34,14 +34,10 @@
 
     if ( $args{source} ) {
         $self->source( Shipwright::Source->new(%args) );
-        $self->source->log( Log::Log4perl->get_logger( ref $self->source ) );
     }
 
     $self->build( Shipwright::Build->new(%args) );
 
-    for my $comp (qw/backend build/) {
-        $self->$comp->log( Log::Log4perl->get_logger( ref $self->$comp ) );
-    }
     return $self;
 }
 

Modified: Shipwright/lib/Shipwright/Backend/SVK.pm
==============================================================================
--- Shipwright/lib/Shipwright/Backend/SVK.pm	(original)
+++ Shipwright/lib/Shipwright/Backend/SVK.pm	Sun Feb 10 09:10:34 2008
@@ -24,9 +24,11 @@
 
 sub new {
     my $class = shift;
-    my %args  = @_;
+    my $self  = {@_};
 
-    bless {%args}, $class;
+    bless $self, $class;
+    $self->log( Log::Log4perl->get_logger( ref $self ) );
+    return $self;
 }
 
 =head2 initialize

Modified: Shipwright/lib/Shipwright/Backend/SVN.pm
==============================================================================
--- Shipwright/lib/Shipwright/Backend/SVN.pm	(original)
+++ Shipwright/lib/Shipwright/Backend/SVN.pm	Sun Feb 10 09:10:34 2008
@@ -24,9 +24,11 @@
 
 sub new {
     my $class = shift;
-    my %args  = @_;
+    my $self  = {@_};
 
-    bless {%args}, $class;
+    bless $self, $class;
+    $self->log( Log::Log4perl->get_logger( ref $self ) );
+    return $self;
 }
 
 =head2 initialize

Modified: Shipwright/lib/Shipwright/Build.pm
==============================================================================
--- Shipwright/lib/Shipwright/Build.pm	(original)
+++ Shipwright/lib/Shipwright/Build.pm	Sun Feb 10 09:10:34 2008
@@ -27,6 +27,8 @@
     my $self  = {@_};
     bless $self, $class;
 
+    $self->log( Log::Log4perl->get_logger( ref $self ) );
+
     $self->{build_base} =
       File::Spec->catfile( tempdir( CLEANUP => 0 ), 'build' );
 
@@ -95,8 +97,7 @@
             )
         );
 
-
-        for my $dist (@{$self->order}) {
+        for my $dist ( @{ $self->order } ) {
             unless ( grep { $dist eq $_ } @{ $self->skip || [] } ) {
                 $self->_install($dist);
             }
@@ -117,7 +118,7 @@
     my $self = shift;
     my $dir  = shift;
 
-    my @cmds = read_file(File::Spec->catfile( 'scripts', $dir, 'build' ));
+    my @cmds = read_file( File::Spec->catfile( 'scripts', $dir, 'build' ) );
     chomp @cmds;
     @cmds = map { $self->_substitute($_) } @cmds;
 
@@ -136,7 +137,7 @@
             $cmd  = $_;
         }
 
-        if ( $self->skip_test && $type eq 'test') {
+        if ( $self->skip_test && $type eq 'test' ) {
             $self->log->info("skip build $type part in $dir");
             next;
         }
@@ -147,7 +148,8 @@
             $self->log->error("build $dir with failure when run $type: $!");
             if ( $self->force && $type eq 'error' ) {
                 $self->log->error(
-"although tests failed, will install anyway since we have force arg\n" );
+"although tests failed, will install anyway since we have force arg\n"
+                );
             }
             else {
                 die "install failed";
@@ -158,7 +160,6 @@
     $self->log->info("build $dir with success!");
 }
 
-
 # wrap the bin files, mainly for ENV
 sub _wrapper {
     my $self = shift;
@@ -177,11 +178,10 @@
         if ( -T $file ) {
             open my $fh, '<', $file or die "can't open $file: $!";
             my $shebang = <$fh>;
-            my $base = quotemeta $self->install_base;
-            my $perl = quotemeta $self->perl || $^X;
+            my $base    = quotemeta $self->install_base;
+            my $perl    = quotemeta $self->perl || $^X;
 
-            if ( $shebang =~ m{$perl} )
-            {
+            if ( $shebang =~ m{$perl} ) {
                 $type = 'perl';
             }
             elsif (
@@ -199,8 +199,9 @@
 
     # if we have this $type(e.g. perl) installed and have that specific wrapper,
     # then link to it, else link to the normal one
-        if ( $type && grep( { $_ eq $type } @{$self->order} )
-            && !( grep { $_ eq $type } @{ $self->skip || [] } ) 
+        if (   $type
+            && grep( { $_ eq $type } @{ $self->order } )
+            && !( grep { $_ eq $type } @{ $self->skip || [] } )
             && -e File::Spec->catfile( '..', 'etc', "shipwright-$type-wrapper" )
           )
         {
@@ -231,9 +232,9 @@
 
     return unless $text;
 
-    my $perl         = $self->perl || $^X;
+    my $perl          = $self->perl || $^X;
     my $perl_archname = `$perl -MConfig -e 'print \$Config{archname}'`;
-    my $install_base = $self->install_base;
+    my $install_base  = $self->install_base;
     $text =~ s/%%PERL%%/$perl/g;
     $text =~ s/%%PERL_ARCHNAME%%/$perl_archname/g;
     $text =~ s/%%INSTALL_BASE%%/$install_base/g;
@@ -249,11 +250,10 @@
 sub test {
     my $self = shift;
 
-    my @cmds = read_file(
-        File::Spec->catfile( 't', 'test' ));
+    my @cmds = read_file( File::Spec->catfile( 't', 'test' ) );
     chomp @cmds;
     @cmds = map { $self->_substitute($_) } @cmds;
-    $self->log->info( 'run tests:' );
+    $self->log->info('run tests:');
 
     for (@cmds) {
         my ( $type, $cmd );
@@ -269,7 +269,7 @@
         }
         $self->log->info("run tests $type:");
         if ( system($cmd) ) {
-            $self->log->error( "tests failed" );
+            $self->log->error("tests failed");
             die;
         }
     }

Modified: Shipwright/lib/Shipwright/Source.pm
==============================================================================
--- Shipwright/lib/Shipwright/Source.pm	(original)
+++ Shipwright/lib/Shipwright/Source.pm	Sun Feb 10 09:10:34 2008
@@ -20,6 +20,11 @@
 $DEFAULT{map_path} = File::Spec->catfile( $DEFAULT{directory}, 'map.yml' );
 $DEFAULT{url_path} = File::Spec->catfile( $DEFAULT{directory}, 'url.yml' );
 
+for ( qw/map_path url_path/ ) {
+    open my $fh, '>', $DEFAULT{$_} or die "can't write to $DEFAULT{$_}: $!";
+    close $fh;
+}
+
 =head2 new
 
 =cut

Modified: Shipwright/lib/Shipwright/Source/Base.pm
==============================================================================
--- Shipwright/lib/Shipwright/Source/Base.pm	(original)
+++ Shipwright/lib/Shipwright/Source/Base.pm	Sun Feb 10 09:10:34 2008
@@ -22,7 +22,10 @@
 
 sub new {
     my $class = shift;
-    bless {@_}, $class;
+    my $self  = {@_};
+    bless $self, $class;
+    $self->log( Log::Log4perl->get_logger( ref $self ) );
+    return $self;
 }
 
 =head2 run



More information about the Bps-public-commit mailing list