In perl.git, the branch blead has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/0dee1c27c65612712346c083a2ec5ea1af81405c?hp=c77945c3ac1accefe435a4ba5074a4f9257b4bf9>

- Log -----------------------------------------------------------------
commit 0dee1c27c65612712346c083a2ec5ea1af81405c
Author: David Golden <[email protected]>
Date:   Mon Oct 19 21:42:28 2009 -0400

    Revised Module::CoreList::is_deprecated
    
    The is_deprecated() function now expects to be called as a function,
    not a method to be consistent with other Module::CoreList functions.
    
    The %deprecated hash now is versioned by Perl version, so tests
    and is_deprecated are revised accordingly.

M       dist/Module-CoreList/lib/Module/CoreList.pm
M       dist/Module-CoreList/t/deprecated.t

commit a762e0540fbc9804c533c635cdd3dda69e1e7a5c
Author: David Golden <[email protected]>
Date:   Tue Oct 20 23:25:40 2009 -0400

    Auto-generate deprecation list via corelist.pl

M       Porting/corelist.pl
M       dist/Module-CoreList/lib/Module/CoreList.pm
-----------------------------------------------------------------------

Summary of changes:
 Porting/corelist.pl                         |   15 ++++++++++-
 dist/Module-CoreList/lib/Module/CoreList.pm |   35 +++++++++++++++++++-------
 dist/Module-CoreList/t/deprecated.t         |   29 ++++++++++++++++++----
 3 files changed, 63 insertions(+), 16 deletions(-)

diff --git a/Porting/corelist.pl b/Porting/corelist.pl
index 5e4e5b1..87d61e6 100644
--- a/Porting/corelist.pl
+++ b/Porting/corelist.pl
@@ -16,6 +16,7 @@ use lib "Porting";
 use Maintainers qw(%Modules files_to_modules);
 use File::Spec;
 use Parse::CPAN::Meta;
+use IPC::Cmd 'can_run';
 
 my $corelist_file = 'dist/Module-CoreList/lib/Module/CoreList.pm';
 
@@ -47,8 +48,9 @@ if ($cpan) {
         warn "Reading the module list from $modlistfile";
         open $fh, '<', $modlistfile or die "Couldn't open $modlistfile: $!";
     } elsif ( -e $modlistfile . ".gz" ) {
+        my $zcat = can_run('gzcat') || can_run('zcat') or die "Can't find 
gzcat or zcat";
         warn "Reading the module list from $modlistfile.gz";
-        open $fh, '-|', "gzcat $modlistfile.gz" or die "Couldn't zcat 
$modlistfile.gz: $!";
+        open $fh, '-|', "$zcat $modlistfile.gz" or die "Couldn't zcat 
$modlistfile.gz: $!";
     } else {
         warn "About to fetch 02packages from ftp.funet.fi. This may take a few 
minutes\n";
         $content = 
fetch_url('http://ftp.funet.fi/pub/CPAN/modules/02packages.details.txt');
@@ -137,11 +139,13 @@ my $file_to_M = files_to_modules( values %module_to_file 
);
 my %module_to_upstream;
 my %module_to_dist;
 my %dist_to_meta_YAML;
+my %module_to_deprecated;
 while ( my ( $module, $file ) = each %module_to_file ) {
     my $M = $file_to_M->{$file};
     next unless $M;
     next if $Modules{$M}{MAINTAINER} eq 'p5p';
     $module_to_upstream{$module} = $Modules{$M}{UPSTREAM};
+    $module_to_deprecated{$module} = 1 if $Modules{$M}{DEPRECATED};
     next
         if defined $module_to_upstream{$module}
             && $module_to_upstream{$module} =~ /^(?:blead|first-come)$/;
@@ -192,6 +196,15 @@ $upstream_stanza .= ");";
 
 $corelist =~ s/^%upstream .*? ;$/$upstream_stanza/ismx;
 
+# Deprecation generation
+my $deprecated_stanza = "    " . $perl_vnum . " => {\n";
+foreach my $module ( sort keys %module_to_deprecated ) {
+    my $deprecated = defined $module_to_deprecated{$module} ? 
"'$module_to_deprecated{$module}'" : 'undef';
+    $deprecated_stanza .= sprintf "\t%-24s=> %s,\n", "'$module'", $deprecated;
+}
+$deprecated_stanza .= "    },\n";
+$corelist =~ s/^(%deprecated\s*=\s*.*?)(^\);)$/$1$deprecated_stanza$2/xism;
+
 my $tracker = "%bug_tracker = (\n";
 foreach my $module ( sort keys %module_to_upstream ) {
     my $upstream = defined $module_to_upstream{$module};
diff --git a/dist/Module-CoreList/lib/Module/CoreList.pm 
b/dist/Module-CoreList/lib/Module/CoreList.pm
index f5ccf0e..bdfbbe2 100644
--- a/dist/Module-CoreList/lib/Module/CoreList.pm
+++ b/dist/Module-CoreList/lib/Module/CoreList.pm
@@ -49,6 +49,10 @@ Since 2.11, Module::CoreList::first_release() returns the 
first release
 in the order of perl version numbers. If you want to get the earliest
 perl release instead, use Module::CoreList::first_release_by_date().
 
+New in 2.22, Module::CoreList::deprecated(MODULE,PERL_VERSION) returns true
+if MODULE is marked as deprecated in PERL_VERSION.  If PERL_VERSION is
+omitted, it defaults to the current version of Perl.
+
 =head1 CAVEATS
 
 Module::CoreList currently covers the 5.000, 5.001, 5.002, 5.003_07, 5.004,
@@ -139,11 +143,10 @@ sub find_version {
 }
 
 sub is_deprecated {
-    my ($discard, $module, $perl) = @_;
-    return unless $module and exists $deprecated{ $module };
-    $perl = $] unless $perl and exists $version{ $perl };
-    return $deprecated{ $module } if 
-           $perl >= $deprecated{ $module };
+    my ($module, $perl_version) = @_;
+    $perl_version ||= $];
+    return unless $module && exists $deprecated{$perl_version}{$module};
+    return $deprecated{$perl_version}{$module};
 }
 
 # When things escaped.
@@ -10904,6 +10907,21 @@ for my $version ( sort { $a <=> $b } keys %released ) {
     },
 );
 
+%deprecated = (
+    5.011 => {
+       'Class::ISA'            => '1',
+       'Pod::Plainer'          => '1',
+       'Shell'                 => '1',
+       'Switch'                => '1',
+    },
+    5.011001 => {
+       'Class::ISA'            => '1',
+       'Pod::Plainer'          => '1',
+       'Shell'                 => '1',
+       'Switch'                => '1',
+    },
+);
+
 %upstream = (
     'App::Prove'            => undef,
     'App::Prove::State'     => undef,
@@ -11856,11 +11874,6 @@ for my $version ( sort { $a <=> $b } keys %released ) {
     'version'               => undef,
 );
 
-# Deprecated modules and the version they were deprecated
-%deprecated = (
-    'Switch'                => '5.011',
-);
-
 # Create aliases with trailing zeros for $] use
 
 $released{'5.000'} = $released{5};
@@ -11871,5 +11884,7 @@ $version{'5.000'} = $version{5};
 $version{'5.010000'} = $version{5.01};
 $version{'5.011000'} = $version{5.011};
 
+$deprecated{'5.011000'} = $deprecated{5.011};
+
 1;
 __END__
diff --git a/dist/Module-CoreList/t/deprecated.t 
b/dist/Module-CoreList/t/deprecated.t
index 151b6c0..8ee1825 100644
--- a/dist/Module-CoreList/t/deprecated.t
+++ b/dist/Module-CoreList/t/deprecated.t
@@ -1,8 +1,27 @@
 #!perl -w
 use strict;
-use Module::CoreList;
-use Test::More tests => 3;
+use Test::More tests => 7;
 
-is(Module::CoreList->is_deprecated('Switch',5.011),'5.011','Switch is 
deprecated');
-is(Module::CoreList->is_deprecated('Switch',5.011000),'5.011','Switch is 
deprecated using $]');
-is(Module::CoreList->is_deprecated('Switch',5.010),'','Switch is not 
deprecated');
+require_ok('Module::CoreList');
+
+ok($Module::CoreList::deprecated{5.011000}, "5.011000 (deprecated list)");
+
+ok(!exists $Module::CoreList::deprecated{5.011000}{'File::Spec'},
+   "File::Spec not deprecated in 5.011000 (hash)"
+);
+
+ok(! Module::CoreList::is_deprecated('File::Spec'),
+   "File::Spec not deprecated in 5.011000 (function)"
+);
+
+ok(exists $Module::CoreList::deprecated{5.011000}{'Switch'},
+   "Switch deprecated in 5.011000 (hash)"
+);
+
+is(!! Module::CoreList::is_deprecated('Switch'), !! $] >= 5.011,
+   "Switch deprecated current perl (function)"
+);
+
+ok(! Module::CoreList::is_deprecated('Switch', 5.010000), 
+   "Switch not deprecated in 5.010000 (function w/ perl version)"
+);

--
Perl5 Master Repository

Reply via email to