[Bps-public-commit] Shipwright branch, master, updated. 139b41188989101e7a30cbb5592ee6b9dbc1ba20

sunnavy at bestpractical.com sunnavy at bestpractical.com
Thu Mar 11 08:28:18 EST 2010


The branch, master has been updated
       via  139b41188989101e7a30cbb5592ee6b9dbc1ba20 (commit)
      from  21e0a810b044f530b6e5c4e0c12f512542eb5630 (commit)

Summary of changes:
 lib/Shipwright/Script/Import.pm |   14 ++------------
 lib/Shipwright/Util.pm          |   14 ++++++++++++++
 2 files changed, 16 insertions(+), 12 deletions(-)

- Log -----------------------------------------------------------------
commit 139b41188989101e7a30cbb5592ee6b9dbc1ba20
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Thu Mar 11 21:27:57 2010 +0800

    move parent_dir() to Util.pm

diff --git a/lib/Shipwright/Script/Import.pm b/lib/Shipwright/Script/Import.pm
index 8383b9c..80adab3 100644
--- a/lib/Shipwright/Script/Import.pm
+++ b/lib/Shipwright/Script/Import.pm
@@ -158,7 +158,7 @@ sub run {
               Shipwright::Util::LoadFile( $shipwright->source->version_path );
             my $name = ( splitdir( $source ) )[-1];
 
-            my $base = $self->_parent_dir($source);
+            my $base = Shipwright::Util->parent_dir($source);
 
             my $script_dir;
             if ( -e catdir( $base, '__scripts', $name ) ) {
@@ -259,7 +259,7 @@ sub _import_req {
     $require_file = catfile( $script_dir, 'require.yml' )
       unless -e catfile( $source, '__require.yml' );
 
-    my $dir = $self->_parent_dir($source);
+    my $dir = Shipwright::Util->parent_dir($source);
 
     my $map_file = catfile( $dir, 'map.yml' );
 
@@ -404,16 +404,6 @@ EOF
     close $fh;
 }
 
-# _parent_dir: return parent dir
-
-sub _parent_dir {
-    my $self   = shift;
-    my $source = shift;
-    my @dirs   = splitdir($source);
-    pop @dirs;
-    return catdir(@dirs);
-}
-
 1;
 
 __END__
diff --git a/lib/Shipwright/Util.pm b/lib/Shipwright/Util.pm
index ece8b60..8d907ea 100644
--- a/lib/Shipwright/Util.pm
+++ b/lib/Shipwright/Util.pm
@@ -246,6 +246,20 @@ sub shipwright_user_root {
     return $ENV{SHIPWRIGHT_USER_ROOT} || catdir( user_home, '.shipwright' );
 }
 
+=head3 parent_dir
+
+return the dir's parent dir, the arg must be a dir path
+
+=cut
+
+sub parent_dir {
+    my $self = shift;
+    my $dir  = shift;
+    my @dirs = splitdir($dir);
+    pop @dirs;
+    return catdir(@dirs);
+}
+
 1;
 
 __END__

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list