r55107 - in /trunk/dh-make-perl: lib/Debian/Control/FromCPAN.pm lib/DhMakePerl.pm lib/DhMakePerl/Command/locate.pm lib/DhMakePerl/Command/make.pm lib/DhMakePerl/Utils.pm t/corelist.t

dmn at users.alioth.debian.org dmn at users.alioth.debian.org
Tue Mar 30 10:23:18 UTC 2010


Author: dmn
Date: Tue Mar 30 10:22:58 2010
New Revision: 55107

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=55107
Log:
move is_core_module in DhMakePerl::Utils

It doesn't need to be an object method and is used in unrelated places
like Control::FromCPAN, make and locate

Added:
    trunk/dh-make-perl/lib/DhMakePerl/Utils.pm
Modified:
    trunk/dh-make-perl/lib/Debian/Control/FromCPAN.pm
    trunk/dh-make-perl/lib/DhMakePerl.pm
    trunk/dh-make-perl/lib/DhMakePerl/Command/locate.pm
    trunk/dh-make-perl/lib/DhMakePerl/Command/make.pm
    trunk/dh-make-perl/t/corelist.t

Modified: trunk/dh-make-perl/lib/Debian/Control/FromCPAN.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/dh-make-perl/lib/Debian/Control/FromCPAN.pm?rev=55107&op=diff
==============================================================================
--- trunk/dh-make-perl/lib/Debian/Control/FromCPAN.pm (original)
+++ trunk/dh-make-perl/lib/Debian/Control/FromCPAN.pm Tue Mar 30 10:22:58 2010
@@ -19,6 +19,7 @@
 use base 'Debian::Control';
 
 use Debian::Version qw(deb_ver_cmp);
+use DhMakePerl::Utils qw(is_core_module);
 use File::Spec qw( catfile );
 use Module::Depends ();
 
@@ -251,7 +252,7 @@
 
     foreach my $module ( keys(%$dep_hash) ) {
         my $dep;
-        if ( my $ver = $self->is_core_module( $module, $dep_hash->{$module} )
+        if ( my $ver = is_core_module( $module, $dep_hash->{$module} )
         ) {
             print "= $module is a core module\n" if $self->cfg->verbose;
 

Modified: trunk/dh-make-perl/lib/DhMakePerl.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/dh-make-perl/lib/DhMakePerl.pm?rev=55107&op=diff
==============================================================================
--- trunk/dh-make-perl/lib/DhMakePerl.pm (original)
+++ trunk/dh-make-perl/lib/DhMakePerl.pm Tue Mar 30 10:22:58 2010
@@ -48,7 +48,6 @@
 
 use Debian::AptContents ();
 use DhMakePerl::Config;
-use Module::CoreList ();
 use version          ();
 
 =item run( I<%init> )
@@ -84,28 +83,6 @@
     my $self = $cmd_mod->new( \%c );
 
     return $self->execute;
-}
-
-=item is_core_module I<module>, I<version>
-
-Returns the version of the C<perl> package containing the given I<module> (at
-least version I<version>).
-
-Returns C<undef> if I<module> is not a core module.
-
-=cut
-
-sub is_core_module {
-    my ( $self, $module, $ver ) = @_;
-
-    my $v = Module::CoreList->first_release($module, $ver);   # 5.009002
-
-    return unless defined $v;
-
-    $v = version->new($v);                              # v5.9.2
-    ( $v = $v->normal ) =~ s/^v//;                      # "5.9.2"
-
-    return $v;
 }
 
 =item get_apt_contents

Modified: trunk/dh-make-perl/lib/DhMakePerl/Command/locate.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/dh-make-perl/lib/DhMakePerl/Command/locate.pm?rev=55107&op=diff
==============================================================================
--- trunk/dh-make-perl/lib/DhMakePerl/Command/locate.pm (original)
+++ trunk/dh-make-perl/lib/DhMakePerl/Command/locate.pm Tue Mar 30 10:22:58 2010
@@ -13,6 +13,8 @@
 use strict; use warnings;
 
 use base 'DhMakePerl';
+
+use DhMakePerl::Utils qw(is_core_module);
 
 =head1 METHODS
 
@@ -43,7 +45,7 @@
     }
     my $mod = $ARGV[0];
 
-    if ( defined( my $core_since = $self->is_core_module($mod) ) ) {
+    if ( defined( my $core_since = is_core_module($mod) ) ) {
         print "$mod is in Perl core (package perl)";
         print $core_since ? " since $core_since\n" : "\n";
         return 0;

Modified: trunk/dh-make-perl/lib/DhMakePerl/Command/make.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/dh-make-perl/lib/DhMakePerl/Command/make.pm?rev=55107&op=diff
==============================================================================
--- trunk/dh-make-perl/lib/DhMakePerl/Command/make.pm (original)
+++ trunk/dh-make-perl/lib/DhMakePerl/Command/make.pm Tue Mar 30 10:22:58 2010
@@ -50,6 +50,7 @@
 use Debian::Dependencies      ();
 use Debian::Dependency        ();
 use Debian::WNPP::Query;
+use DhMakePerl::Utils qw(is_core_module);
 use Email::Date::Format qw(email_date);
 use File::Basename qw( basename dirname );
 use File::Copy qw( copy move );
@@ -259,7 +260,7 @@
         $orig_pwd = $ENV{'PWD'};
 
         # Is the module a core module?
-        if ( $self->is_core_module( $self->cfg->cpan ) ) {
+        if ( is_core_module( $self->cfg->cpan ) ) {
             die $self->cfg->cpan 
             . " is a standard module. Will not build without --core-ok.\n"
                 unless $self->cfg->core_ok;

Added: trunk/dh-make-perl/lib/DhMakePerl/Utils.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/dh-make-perl/lib/DhMakePerl/Utils.pm?rev=55107&op=file
==============================================================================
--- trunk/dh-make-perl/lib/DhMakePerl/Utils.pm (added)
+++ trunk/dh-make-perl/lib/DhMakePerl/Utils.pm Tue Mar 30 10:22:58 2010
@@ -1,0 +1,73 @@
+package DhMakePerl::Utils;
+
+=head1 NAME
+
+DhMakePerl::Utils - helper routined for dh-make-perl and alike
+
+=head1 SYNOPSIS
+
+    use DhMakePerl::Utils qw(is_core_module);
+
+    my $v = is_core_module('Test::More', '1.002');
+
+=cut
+
+our @EXPORT_OK = qw( is_core_module );
+
+use base Exporter;
+
+use Module::CoreList ();
+
+=head1 FUNCTIONS
+
+None of he following functions is exported by default.
+
+=over
+
+=item is_core_module I<module>, I<version>
+
+Returns the version of the C<perl> package containing the given I<module> (at
+least version I<version>).
+
+Returns C<undef> if I<module> is not a core module.
+
+=cut
+
+sub is_core_module {
+    my ( $module, $ver ) = @_;
+
+    my $v = Module::CoreList->first_release($module, $ver);   # 5.009002
+
+    return unless defined $v;
+
+    $v = version->new($v);                              # v5.9.2
+    ( $v = $v->normal ) =~ s/^v//;                      # "5.9.2"
+
+    return $v;
+}
+
+=back
+
+=head1 COPYRIGHT & LICENSE
+
+=over
+
+=item Copyright (C) 2008, 2009, 2010 Damyan Ivanov <dmn at debian.org>
+
+=back
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License version 2 as published by the Free
+Software Foundation.
+
+This program is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along with
+this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
+Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+=cut
+
+1; # End of DhMakePerl

Modified: trunk/dh-make-perl/t/corelist.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/dh-make-perl/t/corelist.t?rev=55107&op=diff
==============================================================================
--- trunk/dh-make-perl/t/corelist.t (original)
+++ trunk/dh-make-perl/t/corelist.t Tue Mar 30 10:22:58 2010
@@ -5,15 +5,14 @@
 
 use Test::More tests => 7;
 
-use DhMakePerl;
+use DhMakePerl::Utils qw(is_core_module);
 use Config;
 use File::Find::Rule;
 
 # Check to see if our module list contains some obvious candidates.
-my $maker = DhMakePerl->new();
 
 foreach my $module ( qw(Fatal File::Copy FindBin CGI IO::Handle Safe) ) {
-    ok($maker->is_core_module($module), "$module should be a core module");
+    ok(is_core_module($module), "$module should be a core module");
 }
 
-ok( !$maker->is_core_module('Foo::Bar'), 'Foo::Bar is not a core module' );
+ok( !is_core_module('Foo::Bar'), 'Foo::Bar is not a core module' );




More information about the Pkg-perl-cvs-commits mailing list