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

sunnavy at bestpractical.com sunnavy at bestpractical.com
Wed Feb 6 15:00:57 EST 2008


Author: sunnavy
Date: Wed Feb  6 15:00:56 2008
New Revision: 10737

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

Log:
use Util::Load or alike instead of Config::Load

Modified: Shipwright/lib/Shipwright/Backend/SVK.pm
==============================================================================
--- Shipwright/lib/Shipwright/Backend/SVK.pm	(original)
+++ Shipwright/lib/Shipwright/Backend/SVK.pm	Wed Feb  6 15:00:56 2008
@@ -317,7 +317,7 @@
     my ($string) = Shipwright::Util->run(
         [ 'svk', 'cat', $self->repository . "/scripts/$dist/require.yml" ], 1
         );
-    my $req = Shipwright::Config::Load($string) || {};
+    my $req = Shipwright::Util::Load($string) || {};
 
     if ( $req->{requires} ) {
         for (qw/requires recommends build_requires/) {
@@ -355,14 +355,14 @@
             target => $file,
         );
 
-        Shipwright::Config::DumpFile( $file, $order );
+        Shipwright::Util::DumpFile( $file, $order );
         $self->commit( path => $file, comment => "set order" );
         $self->checkout( detach => 1, target => $file );
     }
     else {
         my ($out) = Shipwright::Util->run(
             [ 'svk', 'cat', $self->repository . '/shipwright/order.yml' ] );
-        return Shipwright::Config::Load($out);
+        return Shipwright::Util::Load($out);
     }
 }
 

Modified: Shipwright/lib/Shipwright/Backend/SVN.pm
==============================================================================
--- Shipwright/lib/Shipwright/Backend/SVN.pm	(original)
+++ Shipwright/lib/Shipwright/Backend/SVN.pm	Wed Feb  6 15:00:56 2008
@@ -313,7 +313,7 @@
     my ($string) = Shipwright::Util->run(
         [ 'svn', 'cat', $self->repository . "/scripts/$_/require.yml" ], 1 );
 
-    my $req = Shipwright::Config::Load($string) || {};
+    my $req = Shipwright::Util::Load($string) || {};
 
     if ( $req->{requires} ) {
         for (qw/requires recommends build_requires/) {
@@ -351,14 +351,14 @@
             target => $dir,
         );
 
-        Shipwright::Config::DumpFile( $file, $order );
+        Shipwright::Util::DumpFile( $file, $order );
         $self->commit( path => $file, comment => "set order" );
 
     }
     else {
         my ($out) = Shipwright::Util->run(
             [ 'svn', 'cat', $self->repository . '/shipwright/order.yml' ] );
-        return Shipwright::Config::Load($out);
+        return Shipwright::Util::Load($out);
     }
 }
 

Modified: Shipwright/lib/Shipwright/Build.pm
==============================================================================
--- Shipwright/lib/Shipwright/Build.pm	(original)
+++ Shipwright/lib/Shipwright/Build.pm	Wed Feb  6 15:00:56 2008
@@ -90,7 +90,7 @@
         dircopy( 'etc', File::Spec->catfile( $self->install_base, 'etc' ) );
 
         $self->order(
-            Shipwright::Config::LoadFile(
+            Shipwright::Util::LoadFile(
                 File::Spec->catfile( 'shipwright', 'order.yml' )
             )
         );

Modified: Shipwright/lib/Shipwright/Script/Import.pm
==============================================================================
--- Shipwright/lib/Shipwright/Script/Import.pm	(original)
+++ Shipwright/lib/Shipwright/Script/Import.pm	Wed Feb  6 15:00:56 2008
@@ -127,11 +127,11 @@
     my $map_file = File::Spec->catfile( $dir, 'map.yml' );
 
     if ( -e $require_file ) {
-        my $req = Shipwright::Config::LoadFile($require_file);
+        my $req = Shipwright::Util::LoadFile($require_file);
         my $map = {};
 
         if ( -e $map_file ) {
-            $map = Shipwright::Config::LoadFile($map_file);
+            $map = Shipwright::Util::LoadFile($map_file);
         }
 
         opendir my ($d), $dir;

Modified: Shipwright/lib/Shipwright/Source/Base.pm
==============================================================================
--- Shipwright/lib/Shipwright/Source/Base.pm	(original)
+++ Shipwright/lib/Shipwright/Source/Base.pm	Wed Feb  6 15:00:56 2008
@@ -48,7 +48,7 @@
     my $map          = {};
 
     if ( -e $self->map_path ) {
-        $map = Shipwright::Config::LoadFile( $self->map_path );
+        $map = Shipwright::Util::LoadFile( $self->map_path );
     }
 
     if ( !-e $require_path ) {
@@ -106,7 +106,7 @@
 #      # that accroding to META.yml
 #            my $meta_path = File::Spec->catfile( $path, 'META.yml' );
 #            if ( -e $meta_path ) {
-#                my $meta = Shipwright::Config::LoadFile($meta_path);
+#                my $meta = Shipwright::Util::LoadFile($meta_path);
 #
 #                for (qw/recommends build_requires/) {
 #                    my $keep = 'keep_' . $_;
@@ -126,11 +126,11 @@
             }
         }
 
-        Shipwright::Config::DumpFile( $require_path, $require )
+        Shipwright::Util::DumpFile( $require_path, $require )
           or die "can't dump __require.yml: $!";
     }
 
-    if ( my $require = Shipwright::Config::LoadFile($require_path) ) {
+    if ( my $require = Shipwright::Util::LoadFile($require_path) ) {
 
        # if not have 'requires' key, all the keys in $require are supposed to be
        # requires type
@@ -203,7 +203,7 @@
 
                 # reload map
                 if ( -e $self->map_path ) {
-                    $map = Shipwright::Config::LoadFile( $self->map_path );
+                    $map = Shipwright::Util::LoadFile( $self->map_path );
                 }
 
                 $require->{$type}{ $map->{$module} || $name } =
@@ -211,7 +211,7 @@
             }
         }
 
-        Shipwright::Config::DumpFile( $require_path, $require );
+        Shipwright::Util::DumpFile( $require_path, $require );
     }
     else {
         croak "invalid __require.yml in $path";
@@ -228,12 +228,12 @@
 
     my $map = {};
     if ( -e $self->map_path ) {
-        $map = Shipwright::Config::LoadFile( $self->map_path );
+        $map = Shipwright::Util::LoadFile( $self->map_path );
     }
     return if $map->{$module};
 
     $map->{$module} = $dist;
-    Shipwright::Config::DumpFile( $self->map_path, $map );
+    Shipwright::Util::DumpFile( $self->map_path, $map );
 
 }
 

Modified: Shipwright/lib/Shipwright/Util.pm
==============================================================================
--- Shipwright/lib/Shipwright/Util.pm	(original)
+++ Shipwright/lib/Shipwright/Util.pm	Wed Feb  6 15:00:56 2008
@@ -7,6 +7,24 @@
 
 my $log = Log::Log4perl->get_logger('Shipwright::Util');
 
+BEGIN {
+    local $@;
+    eval { require YAML::Syck; };
+    if ($@) {
+        require YAML;
+        *Load     = *YAML::Load;
+        *Dump     = *YAML::Dump;
+        *LoadFile = *YAML::LoadFile;
+        *DumpFile = *YAML::DumpFile;
+    }
+    else {
+        *Load     = *YAML::Syck::Load;
+        *Dump     = *YAML::Syck::Dump;
+        *LoadFile = *YAML::Syck::LoadFile;
+        *DumpFile = *YAML::Syck::DumpFile;
+    }
+}
+
 =head2 run
 
 a wrapper of run3 sub in IPC::Run3.



More information about the Bps-public-commit mailing list