r27860 - /trunk/dh-make-perl/dh-make-perl

dmn at users.alioth.debian.org dmn at users.alioth.debian.org
Sun Dec 7 17:14:03 UTC 2008


Author: dmn
Date: Sun Dec  7 17:14:00 2008
New Revision: 27860

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=27860
Log:
Dep: add support for relations for versioned dependencies

Modified:
    trunk/dh-make-perl/dh-make-perl

Modified: trunk/dh-make-perl/dh-make-perl
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/dh-make-perl/dh-make-perl?rev=27860&op=diff
==============================================================================
--- trunk/dh-make-perl/dh-make-perl (original)
+++ trunk/dh-make-perl/dh-make-perl Sun Dec  7 17:14:00 2008
@@ -375,6 +375,8 @@
 #
 #   my $d = Dep->new( 'perl' );             # simple dependency
 #   my $d = Dep->new( 'perl', '5.10' );     # dependency with a version
+#   my $d = Dep->new( 'perl', '>=', '5.10' );
+#                               # dependency with version and relation
 #   print $d->pkg;  # 'perl'
 #   print $d->ver;  # '5.10
 #
@@ -394,7 +396,7 @@
 package Dep;
 
 use base qw(Class::Accessor);
-__PACKAGE__->mk_accessors(qw(pkg ver));
+__PACKAGE__->mk_accessors(qw( pkg ver rel ));
 
 use overload
     '""'    => \&stringify;
@@ -402,11 +404,18 @@
     my $class = shift;
     $class = ref($class) if ref($class);
 
-    return (
-        ref( $_[0] )
-        ? $class->SUPER::new(@_)
-        : $class->SUPER::new( { pkg => $_[0], ver => $_[1] } )
-    );
+    return $class->SUPER::new(@_) if ref( $_[0] );
+
+    return $class->SUPER::new( { pkg => $_[0] } )
+        if @_ == 1;
+
+    return $class->SUPER::new( { pkg => $_[0], rel => '>=', ver => $_[1] } )
+        if @_ == 2;
+
+    return $class->SUPER::new( { pkg => $_[0], rel => $_[1], ver => $_[2] } )
+        if @_ == 3;
+
+    die "Unsupported number of arguments";
 }
 
 sub stringify {
@@ -414,7 +423,7 @@
 
     return (
         $self->ver
-        ? $self->pkg . ' (>= ' . $self->ver . ')'
+        ? $self->pkg . ' (' . $self->rel . ' ' . $self->ver . ')'
         : $self->pkg
     );
 }




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