[Bps-public-commit] r10465 - in bpsbuilder/Shipwright/lib/Shipwright: .

sunnavy at bestpractical.com sunnavy at bestpractical.com
Thu Jan 24 08:25:34 EST 2008


Author: sunnavy
Date: Thu Jan 24 08:25:33 2008
New Revision: 10465

Modified:
   bpsbuilder/Shipwright/lib/Shipwright/Backend.pm
   bpsbuilder/Shipwright/lib/Shipwright/Backend/SVK.pm
   bpsbuilder/Shipwright/lib/Shipwright/Backend/SVN.pm

Log:
refactor a bit

Modified: bpsbuilder/Shipwright/lib/Shipwright/Backend.pm
==============================================================================
--- bpsbuilder/Shipwright/lib/Shipwright/Backend.pm	(original)
+++ bpsbuilder/Shipwright/lib/Shipwright/Backend.pm	Thu Jan 24 08:25:33 2008
@@ -29,7 +29,8 @@
     return $module->new(%args);
 }
 
-our $WRAPPER = <<'EOF'
+my %scripts = (
+        wrapper => <<'EOF'
 #!/bin/sh
 if [ -z `which readlink` ]; then  
     # if we don't have readlink, we're on some pitiful platform like solaris
@@ -53,9 +54,8 @@
     exec $LINK "$@"
 fi
 EOF
-  ;
-
-our $UTILITY = <<'EOF'
+,
+utility => <<'EOF'
 #!/usr/bin/env perl
 use strict;
 use warnings;
@@ -127,9 +127,8 @@
 }
 
 EOF
-  ;
-
-our $BUILDER = <<'EOF'
+,
+    builder => <<'EOF'
 #!/usr/bin/env perl
 use warnings;
 use strict;
@@ -361,9 +360,22 @@
 }
 
 EOF
-  ;
+, 
+null => '',    
+);
+
+=head2 make_script
+
+help method to get scripts
+
+=cut
+
+sub make_script {
+    my $self = shift;
+    my $type = shift || 'null';
+    return $scripts{$type};
+}
 
-our $NULL = ''; # just for convience
 1;
 
 __END__

Modified: bpsbuilder/Shipwright/lib/Shipwright/Backend/SVK.pm
==============================================================================
--- bpsbuilder/Shipwright/lib/Shipwright/Backend/SVK.pm	(original)
+++ bpsbuilder/Shipwright/lib/Shipwright/Backend/SVK.pm	Thu Jan 24 08:25:33 2008
@@ -43,18 +43,17 @@
     }
 
     my %map = (
-        File::Spec->catfile( $dir, 'etc', 'shipwright-script-wrapper' ) => 'WRAPPER',
-        File::Spec->catfile( $dir, 'bin', 'shipwright-builder' )        => 'BUILDER',
-        File::Spec->catfile( $dir, 'bin', 'shipwright-utility' )        => 'UTILITY',
-        File::Spec->catfile( $dir, 't',   'test' )               => 'NULL',
-        File::Spec->catfile( $dir, 'shipwright', 'order.yml' )          => 'NULL',
+        File::Spec->catfile( $dir, 'etc', 'shipwright-script-wrapper' ) =>
+          'wrapper',
+        File::Spec->catfile( $dir, 'bin', 'shipwright-builder' ) => 'builder',
+        File::Spec->catfile( $dir, 'bin', 'shipwright-utility' ) => 'utility',
+        File::Spec->catfile( $dir, 't',   'test' )               => 'null',
+        File::Spec->catfile( $dir, 'shipwright', 'order.yml' ) => 'null',
     );
 
     for ( keys %map ) {
-        no strict 'refs';
         open my $fh, '>', $_ or die "can't open file $_: $!";
-        my $name = "Shipwright::Backend::$map{$_}";
-        print $fh $$name;
+        print $fh Shipwright::Backend->make_script($map{$_});
         close $fh;
     }
 

Modified: bpsbuilder/Shipwright/lib/Shipwright/Backend/SVN.pm
==============================================================================
--- bpsbuilder/Shipwright/lib/Shipwright/Backend/SVN.pm	(original)
+++ bpsbuilder/Shipwright/lib/Shipwright/Backend/SVN.pm	Thu Jan 24 08:25:33 2008
@@ -43,18 +43,17 @@
     }
 
     my %map = (
-        File::Spec->catfile( $dir, 'etc', 'shipwright-script-wrapper' ) => 'WRAPPER',
-        File::Spec->catfile( $dir, 'bin', 'shipwright-builder' )        => 'BUILDER',
-        File::Spec->catfile( $dir, 'bin', 'shipwright-utility' )        => 'UTILITY',
-        File::Spec->catfile( $dir, 't',   'test' )               => 'NULL',
-        File::Spec->catfile( $dir, 'shipwright', 'order.yml' )          => 'NULL',
+        File::Spec->catfile( $dir, 'etc', 'shipwright-script-wrapper' ) =>
+          'wrapper',
+        File::Spec->catfile( $dir, 'bin', 'shipwright-builder' ) => 'builder',
+        File::Spec->catfile( $dir, 'bin', 'shipwright-utility' ) => 'utility',
+        File::Spec->catfile( $dir, 't',   'test' )               => 'null',
+        File::Spec->catfile( $dir, 'shipwright', 'order.yml' ) => 'null',
     );
 
     for ( keys %map ) {
-        no strict 'refs';
         open my $fh, '>', $_ or die "can't open file $_: $!";
-        my $name = "Shipwright::Backend::$map{$_}";
-        print $fh $$name;
+        print $fh Shipwright::Backend->make_script($map{$_});
         close $fh;
     }
 



More information about the Bps-public-commit mailing list