[Bps-public-commit] r9773 - in bpsbuilder/BPB: lib/BPB lib/BPB/Source

sunnavy at bestpractical.com sunnavy at bestpractical.com
Sat Dec 1 10:04:08 EST 2007


Author: sunnavy
Date: Sat Dec  1 10:04:01 2007
New Revision: 9773

Modified:
   bpsbuilder/BPB/examples/config.yml
   bpsbuilder/BPB/lib/BPB/Source.pm
   bpsbuilder/BPB/lib/BPB/Source/Compressed.pm
   bpsbuilder/BPB/lib/BPB/Source/Directory.pm
   bpsbuilder/BPB/lib/BPB/Source/FTP.pm
   bpsbuilder/BPB/lib/BPB/Source/HTTP.pm

Log:
refactor source

Modified: bpsbuilder/BPB/examples/config.yml
==============================================================================
--- bpsbuilder/BPB/examples/config.yml	(original)
+++ bpsbuilder/BPB/examples/config.yml	Sat Dec  1 10:04:01 2007
@@ -7,3 +7,4 @@
         command:
             tar: '/usr/bin/tar'
         directory: '/tmp'
+        download_directory: '/tmp/download'

Modified: bpsbuilder/BPB/lib/BPB/Source.pm
==============================================================================
--- bpsbuilder/BPB/lib/BPB/Source.pm	(original)
+++ bpsbuilder/BPB/lib/BPB/Source.pm	Sat Dec  1 10:04:01 2007
@@ -64,18 +64,6 @@
     }
 }
 
-=head2 run
-
-=cut
-
-sub run {
-    my $self = shift;
-    my $path = shift;
-
-    # do build order stuff
-
-}
-
 1;
 
 __END__

Modified: bpsbuilder/BPB/lib/BPB/Source/Compressed.pm
==============================================================================
--- bpsbuilder/BPB/lib/BPB/Source/Compressed.pm	(original)
+++ bpsbuilder/BPB/lib/BPB/Source/Compressed.pm	Sat Dec  1 10:04:01 2007
@@ -5,17 +5,7 @@
 use Carp;
 use File::Spec;
 
-use base qw/Class::Accessor::Fast BPB::Source/;
-__PACKAGE__->mk_accessors(qw/source directory command/);
-
-=head2 new
-
-=cut
-
-sub new {
-    my $class = shift;
-    bless {@_}, $class;
-}
+use base qw/BPB::Source::Base/;
 
 =head2 run
 
@@ -23,9 +13,7 @@
 
 sub run {
     my $self = shift;
-    my $cmd  = $self->_cmd;
-    $self->_run($cmd);
-    $self->SUPER::run( $self->path );
+    $self->SUPER::run();
 }
 
 =head2 path
@@ -68,11 +56,6 @@
       $self->directory;
 }
 
-sub _run {
-    my $self = shift;
-    my $cmd  = shift;
-    system($cmd);
-}
 
 1;
 

Modified: bpsbuilder/BPB/lib/BPB/Source/Directory.pm
==============================================================================
--- bpsbuilder/BPB/lib/BPB/Source/Directory.pm	(original)
+++ bpsbuilder/BPB/lib/BPB/Source/Directory.pm	Sat Dec  1 10:04:01 2007
@@ -5,8 +5,7 @@
 use File::Spec;
 use File::Basename;
 
-use base qw/Class::Accessor::Fast BPB::Source/;
-__PACKAGE__->mk_accessors(qw/source directory command/);
+use base qw/BPB::Source::Base/;
 
 =head2 new
 
@@ -14,20 +13,9 @@
 
 sub new {
     my $class = shift;
-    my $self  = {@_};
+    my $self  = $class::SUPER->new(@_);
     $self->{source} =~ s{/$}{};    # trim the last / to let cp work as we like
-    bless $self, $class;
-}
-
-=head2 run
-
-=cut
-
-sub run {
-    my $self = shift;
-    my $cmd  = $self->_cmd;
-    $self->_run($cmd);
-    $self->SUPER::run( $self->path );
+    return $self;
 }
 
 sub path {
@@ -41,12 +29,6 @@
       $self->directory;
 }
 
-sub _run {
-    my $self = shift;
-    my $cmd  = shift;
-    system($cmd);
-}
-
 1;
 
 __END__

Modified: bpsbuilder/BPB/lib/BPB/Source/FTP.pm
==============================================================================
--- bpsbuilder/BPB/lib/BPB/Source/FTP.pm	(original)
+++ bpsbuilder/BPB/lib/BPB/Source/FTP.pm	Sat Dec  1 10:04:01 2007
@@ -6,17 +6,7 @@
 
 use BPB::Source::Compressed;
 
-use base qw/Class::Accessor::Fast BPB::Source/;
-__PACKAGE__->mk_accessors(qw/source directory command/);
-
-=head2 new
-
-=cut
-
-sub new {
-    my $class = shift;
-    bless {@_}, $class;
-}
+use base qw/BPB::Source::Base/;
 
 =head2 run
 
@@ -24,8 +14,8 @@
 
 sub run {
     my $self = shift;
-    my $cmd  = $self->_cmd;
-    $self->_run($cmd);
+    my $self = shift;
+    $self->SUPER::run();
     my $compressed = BPB::Source::Compressed->new( %$self );
     $compressed->run();
 }
@@ -41,7 +31,7 @@
     my $file;
     if ( $source =~ m{.*/(.+\.(tar\.gz|tgz|tar\.bz2))$} ) {
         $file = $1;
-        my $src_dir = File::Spec->catfile( $self->directory, 'src' );
+        my $src_dir = $self->download_directory;
         mkdir $src_dir unless -e $src_dir;
         $self->source( File::Spec->catfile( $src_dir, $file ) );
         return join ' ', $self->command->{ftp}, $source, '-O', $self->source;
@@ -51,13 +41,6 @@
     }
 }
 
-sub _run {
-    my $self = shift;
-    my $cmd  = shift;
-    system($cmd);
-}
-
-
 1;
 
 __END__

Modified: bpsbuilder/BPB/lib/BPB/Source/HTTP.pm
==============================================================================
--- bpsbuilder/BPB/lib/BPB/Source/HTTP.pm	(original)
+++ bpsbuilder/BPB/lib/BPB/Source/HTTP.pm	Sat Dec  1 10:04:01 2007
@@ -6,17 +6,7 @@
 use File::Spec;
 use BPB::Source::Compressed;
 
-use base qw/Class::Accessor::Fast BPB::Source/;
-__PACKAGE__->mk_accessors(qw/source directory command/);
-
-=head2 new
-
-=cut
-
-sub new {
-    my $class = shift;
-    bless {@_}, $class;
-}
+use base qw/BPB::Source::Base/;
 
 =head2 run
 
@@ -24,8 +14,7 @@
 
 sub run {
     my $self = shift;
-    my $cmd  = $self->_cmd;
-    $self->_run($cmd);
+    $self->SUPER::run();
     my $compressed = BPB::Source::Compressed->new( %$self );
     $compressed->run();
 }
@@ -41,7 +30,7 @@
     my $file;
     if ( $source =~ m{.*/(.+\.(tar\.gz|tgz|tar\.bz2))$} ) {
         $file = $1;
-        my $src_dir = File::Spec->catfile( $self->directory, 'src' );
+        my $src_dir = $self->download_directory;
         mkdir $src_dir unless -e $src_dir;
         $self->source( File::Spec->catfile( $src_dir, $file ) );
         return join ' ', $self->command->{http}, $source, '-O', $self->source;
@@ -51,12 +40,6 @@
     }
 }
 
-sub _run {
-    my $self = shift;
-    my $cmd  = shift;
-    system($cmd);
-}
-
 
 1;
 



More information about the Bps-public-commit mailing list