Author: sparky
Date: Wed Sep 16 19:07:52 2009
New Revision: 10612

Modified:
   toys/rsget.pl/RSGet/Dispatch.pm
   toys/rsget.pl/RSGet/Processor.pm
Log:
- allow multiple uri:


Modified: toys/rsget.pl/RSGet/Dispatch.pm
==============================================================================
--- toys/rsget.pl/RSGet/Dispatch.pm     (original)
+++ toys/rsget.pl/RSGet/Dispatch.pm     Wed Sep 16 19:07:52 2009
@@ -238,9 +238,13 @@
 sub getter
 {
        my $uri = shift;
-       my @g = grep { $uri =~ m/^http:\/\/(:?www\.)?$_->{uri}/ } values 
%getters;
-       return undef unless @g;
-       return $g[0];
+       foreach my $getter ( values %getters ) {
+               foreach my $re ( @{ $getter->{uri} } ) {
+                       return $getter
+                               if $uri =~ m{^http://(?:www\.)?$re};
+               }
+       }
+       return undef;
 }
 
 

Modified: toys/rsget.pl/RSGet/Processor.pm
==============================================================================
--- toys/rsget.pl/RSGet/Processor.pm    (original)
+++ toys/rsget.pl/RSGet/Processor.pm    Wed Sep 16 19:07:52 2009
@@ -4,7 +4,7 @@
 use warnings;
 use RSGet::Tools;
 
-my $options = "name|short|uri|slots|cookie|status";
+my $options = "name|short|slots|cookie|status";
 my $parts = "pre|start|perl";
 
 my $processed = "";
@@ -56,7 +56,9 @@
 
        open F_IN, '<', $file;
 
-       my %opts;
+       my %opts = (
+               uri => [],
+       );
        my %parts = (
                pre => [],
                start => [],
@@ -85,6 +87,8 @@
 
                if ( /^($parts)\s*:/ ) {
                        $part = $1;
+               } elsif ( /^uri\s*:\s+(.*)$/ ) {
+                       push @{$opts{uri}}, $1;
                } elsif ( /^($options)\s*:\s+(.*)$/ ) {
                        $opts{$1} = $2;
                }
@@ -95,7 +99,11 @@
                p "Can't find 'start:'\n";
                return undef;
        }
-       foreach ( qw(name short uri) ) {
+       unless ( @{$opts{uri}} ) {
+               p "Can't find 'uri:'\n";
+               return undef;
+       }
+       foreach ( qw(name short) ) {
                next if $opts{$_};
                p "Can't find '$_:'\n";
                return undef;
@@ -115,7 +123,7 @@
        $space = "";
        $is_sub = 0;
 
-       $opts{uri} = eval $opts{uri};
+       $opts{uri} = [ map { eval $_ } @{$opts{uri}} ];
        $opts{class} = ${class};
        $opts{pkg} = "${class}::$opts{name}";
 
_______________________________________________
pld-cvs-commit mailing list
[email protected]
http://lists.pld-linux.org/mailman/listinfo/pld-cvs-commit

Reply via email to