[Bps-public-commit] r10175 - bpsbuilder/BPB/lib/BPB/Source

sunnavy at bestpractical.com sunnavy at bestpractical.com
Fri Dec 28 04:24:28 EST 2007


Author: sunnavy
Date: Fri Dec 28 04:24:28 2007
New Revision: 10175

Modified:
   bpsbuilder/BPB/lib/BPB/Source/Base.pm

Log:
refactor _require.yml's format

Modified: bpsbuilder/BPB/lib/BPB/Source/Base.pm
==============================================================================
--- bpsbuilder/BPB/lib/BPB/Source/Base.pm	(original)
+++ bpsbuilder/BPB/lib/BPB/Source/Base.pm	Fri Dec 28 04:24:28 2007
@@ -11,7 +11,7 @@
 use base qw/Class::Accessor::Fast/;
 __PACKAGE__->mk_accessors(
     qw/source directory download_directory follow min_perl_version map_path
-    skip map keep_recommends/
+      skip map keep_recommends/
 );
 
 =head2 new
@@ -58,21 +58,22 @@
         my $require = {};
         if ( -e $meta_path ) {
             my $meta = BPB::Config::LoadFile($meta_path);
-            if ( $self->keep_recommends ) {
-                %$require = (
-                    %{ $meta->{requires}   || {} },
-                    %{ $meta->{recommends} || {} }
-                );
+
+            for my $module ( keys %{ $meta->{requires} } ) {
+                $require->{$module}{version} = $meta->{requires}{$module};
             }
-            else {
-                %$require = %{$meta->{requires} || {} };
+
+            if ( $self->keep_recommends && $meta->{recommends} ) {
+                for my $module ( keys %{ $meta->{recommends} } ) {
+                    $require->{$module}{version} = $meta->{recommends}{$module};
+                }
             }
         }
         BPB::Config::DumpFile( $require_path, $require );
     }
 
     if ( my $require = BPB::Config::LoadFile($require_path) ) {
-        while ( my ( $module, $version ) = each %$require ) {
+        for my $module ( keys %$require ) {
 
             # we don't want to require perl
             if ( $module eq 'perl' ) {
@@ -80,9 +81,12 @@
                 next;
             }
 
-            if (   Module::CoreList->first_release( $module, $version )
-                && Module::CoreList->first_release( $module, $version ) <=
-                $self->min_perl_version )
+            if (
+                Module::CoreList->first_release( $module,
+                    $require->{$module}{version} )
+                && Module::CoreList->first_release( $module,
+                    $require->{$module}{version} ) <= $self->min_perl_version
+              )
             {
                 delete $require->{$module};
                 next;



More information about the Bps-public-commit mailing list