Changeset 446


Ignore:
Timestamp:
06/29/12 14:53:43 (12 years ago)
Author:
grenoya
Message:
  • create listlc to have the same behavior as list but returns lowercase
  • factorisation of list and listlc -> creation of listQuery
File:
1 edited

Legend:

Unmodified
Added
Removed
  • server/trunk/web/lib/Sophie/Controller/Chat/Cmd.pm

    r432 r446  
    392392    my ($self, $c, $reqspec, @args) = @_; 
    393393 
    394     my $distrib = { 
    395         distribution => $args[0], 
    396         release      => $args[1], 
    397         arch         => $args[2], 
    398     }; 
    399  
    400     if (!$c->forward('/distrib/exists', [ $distrib ])) { 
     394    my $list = $c->forward('_listQuery' , [ @args ]); 
     395 
     396    if (!@$list) {  
    401397        return $c->stash->{xmlrpc} = { 
    402398            message => [ "I don't have any distribution matching: " 
     
    405401    } 
    406402 
    407     my @list = @{ $c->forward('/distrib/list', [ $distrib ]) }; 
    408403    return $c->stash->{xmlrpc} = { 
    409404        message => [  
     
    412407                : '') . 
    413408            join(', ', @list) ], 
     409    } 
     410} 
     411 
     412#=head2 _listlc [distribution [release [arch]]] 
     413# 
     414#List available distribution, release, architecture matching given arguments, in 
     415#lower case. 
     416# 
     417#=cut 
     418 
     419sub _listlc : private { 
     420    my ($self, $c, $reqspec, @args) = @_; 
     421 
     422    # call for the common list query 
     423    my $list = $c->forward('_listQuery' , [ @args ]); 
     424 
     425    # lowercase of the list and return 
     426    return [ map( lc, @{ $list || [] } ) ]; 
     427} 
     428 
     429=head2 _listQuery [distribution [release [arch]]] 
     430 
     431#List available distribution, release, architecture matching given arguments. 
     432 
     433=cut 
     434 
     435sub _listQuery : Private { 
     436    my ($self, $c, $reqspec, @args) = @_; 
     437 
     438    my $distrib = { 
     439        distribution => $args[0], 
     440        release      => $args[1], 
     441        arch         => $args[2], 
     442    }; 
     443 
     444    if (!$c->forward('/distrib/exists', [ $distrib ])) { 
     445        return []; 
     446    } 
     447 
     448    return @{ $c->forward('/distrib/list', [ $distrib ]) }; 
    414449    } 
    415450} 
Note: See TracChangeset for help on using the changeset viewer.