Changeset 137


Ignore:
Timestamp:
12/18/10 18:11:06 (13 years ago)
Author:
nanardon
Message:
  • factorize code
File:
1 edited

Legend:

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

    r136 r137  
    185185    my ($self, $c, $reqspec, @args) = @_; 
    186186 
     187    $c->forward('qf', [ $reqspec, @args, '%{packager}' ]); 
     188} 
     189 
     190=head2 p 
     191 
     192Is an alias for C<packager> command. 
     193 
     194=cut 
     195 
     196sub p : XMLRPC { 
     197    my ($self, $c, @args) = @_; 
     198    $c->forward('packager', [ @args ]); 
     199} 
     200 
     201=head2 arch [-s] NAME 
     202 
     203Show the architecture of package C<NAME>. 
     204 
     205=cut  
     206 
     207sub arch : XMLRPC { 
     208    my ($self, $c, $reqspec, @args) = @_; 
     209 
     210    $c->forward('qf', [ $reqspec, @args, '%{arch}' ]); 
     211} 
     212 
     213=head2 a 
     214 
     215Is an alias to C<arch> command. 
     216 
     217=cut  
     218 
     219sub a : XMLRPC { 
     220    my ($self, $c, @args) = @_; 
     221    $c->forward('arch', [ @args ]); 
     222} 
     223 
     224=head2 group [-s] NAME 
     225 
     226Show the group of package C<NAME>. 
     227 
     228=cut  
     229 
     230sub group : XMLRPC { 
     231    my ($self, $c, $reqspec, @args) = @_; 
     232 
     233    $c->forward('qf', [ $reqspec, @args, '%{group}' ]); 
     234} 
     235 
     236=head2 g 
     237 
     238Is an alias to C<group> command. 
     239 
     240=cut  
     241 
     242sub g : XMLRPC { 
     243    my ($self, $c, @args) = @_; 
     244    $c->forward('group', [ @args ]); 
     245} 
     246 
     247=head2 license [-s] NAME 
     248 
     249Show the license of package C<NAME>. 
     250 
     251=cut  
     252 
     253sub license : XMLRPC { 
     254    my ($self, $c, $reqspec, @args) = @_; 
     255 
     256    $c->forward('qf', [ $reqspec, @args, '%{license}' ]); 
     257} 
     258 
     259=head2 l 
     260 
     261Is an alias to C<license> command. 
     262 
     263=cut  
     264 
     265sub l : XMLRPC { 
     266    my ($self, $c, @args) = @_; 
     267    $c->forward('license', [ @args ]); 
     268} 
     269 
     270=head2 buildtime [-s] NAME 
     271 
     272Show the build time of package C<NAME>. 
     273 
     274=cut 
     275 
     276sub buildtime : XMLRPC { 
     277    my ($self, $c, $reqspec, @args) = @_; 
     278 
     279    $c->forward('qf', [ $reqspec, @args, '%{buildtime:date}' ]); 
     280} 
     281 
     282=head2 builddate 
     283 
     284Is an alias for C<buildtime> command. 
     285 
     286=cut 
     287 
     288sub builddate : XMLRPC { 
     289    my ($self, $c, @args) = @_; 
     290    $c->forward('buildtime', [ @args ]); 
     291} 
     292 
     293=head2 builddate 
     294 
     295Is an alias for C<buildtime> command. 
     296 
     297=cut 
     298 
     299sub b : XMLRPC { 
     300    my ($self, $c, @args) = @_; 
     301    $c->forward('builddate', [ @args ]); 
     302} 
     303 
     304=head2 qf rpmname format 
     305 
     306Perform an rpm -q --qf on package named C<rpmname> 
     307 
     308=cut 
     309 
     310sub qf : XMLRPC { 
     311    my ($self, $c, $reqspec, @args) = @_; 
    187312    my @message; 
    188313    $reqspec->{src} = 0; 
     
    198323    my $rpmlist = $c->forward('/search/byname', [ $reqspec, $args[0] ]); 
    199324    foreach (@{ $rpmlist->{results} }) { 
    200         my $info = $c->forward('/rpms/queryformat', [ $_, '%{packager}' ]); 
    201         push @message, $info . ' // ' . 
    202             $c->forward('_fmt_location', [ $_ ]); 
     325        my $info = $c->forward('/rpms/queryformat', [ $_, $args[1] ]); 
     326        push @message, $info; 
    203327    } 
    204328    return $c->stash->{xmlrpc} = { 
     
    207331} 
    208332 
    209 =head2 p 
    210  
    211 Is an alias for C<packager> command. 
    212  
    213 =cut 
    214  
    215 sub p : XMLRPC { 
    216     my ($self, $c, @args) = @_; 
    217     $c->forward('packager', [ @args ]); 
    218 } 
    219  
    220 =head2 arch [-s] NAME 
    221  
    222 Show the architecture of package C<NAME>. 
    223  
    224 =cut  
    225  
    226 sub arch : XMLRPC { 
    227     my ($self, $c, $reqspec, @args) = @_; 
    228  
    229     my @message; 
    230     $reqspec->{src} = 0; 
    231  
    232     @args = @{ $c->forward('_getopt', [ 
    233         { 
    234             'd=s' => \$reqspec->{distribution}, 
    235             'v=s' => \$reqspec->{release}, 
    236             'a=s' => \$reqspec->{arch}, 
    237             's'   => sub { $reqspec->{src} = 1 }, 
    238         }, @args ]) }; 
    239  
    240     my $rpmlist = $c->forward('/search/byname', [ $reqspec, $args[0] ]); 
    241     foreach (@{ $rpmlist->{results} }) { 
    242         my $info = $c->forward('/rpms/queryformat', [ $_, '%{arch}' ]); 
    243         push @message, $info . ' // ' . 
    244             $c->forward('_fmt_location', [ $_ ]); 
    245     } 
    246     return $c->stash->{xmlrpc} = { 
    247         message => \@message, 
    248     } 
    249 } 
    250  
    251 =head2 a 
    252  
    253 Is an alias to C<arch> command. 
    254  
    255 =cut  
    256  
    257 sub a : XMLRPC { 
    258     my ($self, $c, @args) = @_; 
    259     $c->forward('arch', [ @args ]); 
    260 } 
    261  
    262 =head2 group [-s] NAME 
    263  
    264 Show the group of package C<NAME>. 
    265  
    266 =cut  
    267  
    268 sub group : XMLRPC { 
    269     my ($self, $c, $reqspec, @args) = @_; 
    270  
    271     my @message; 
    272     $reqspec->{src} = 0; 
    273  
    274     @args = @{ $c->forward('_getopt', [ 
    275         { 
    276             'd=s' => \$reqspec->{distribution}, 
    277             'v=s' => \$reqspec->{release}, 
    278             'a=s' => \$reqspec->{arch}, 
    279             's'   => sub { $reqspec->{src} = 1 }, 
    280         }, @args ]) }; 
    281  
    282     my $rpmlist = $c->forward('/search/byname', [ $reqspec, $args[0] ]); 
    283     foreach (@{ $rpmlist->{results} }) { 
    284         my $info = $c->forward('/rpms/queryformat', [ $_, '%{group}' ]); 
    285         push @message, $info . ' // ' . 
    286             $c->forward('_fmt_location', [ $_ ]); 
    287     } 
    288     return $c->stash->{xmlrpc} = { 
    289         message => \@message, 
    290     } 
    291 } 
    292  
    293 =head2 g 
    294  
    295 Is an alias to C<group> command. 
    296  
    297 =cut  
    298  
    299 sub g : XMLRPC { 
    300     my ($self, $c, @args) = @_; 
    301     $c->forward('group', [ @args ]); 
    302 } 
    303  
    304 =head2 license [-s] NAME 
    305  
    306 Show the license of package C<NAME>. 
    307  
    308 =cut  
    309  
    310 sub group : XMLRPC { 
    311     my ($self, $c, $reqspec, @args) = @_; 
    312  
    313     my @message; 
    314     $reqspec->{src} = 0; 
    315  
    316     @args = @{ $c->forward('_getopt', [ 
    317         { 
    318             'd=s' => \$reqspec->{distribution}, 
    319             'v=s' => \$reqspec->{release}, 
    320             'a=s' => \$reqspec->{arch}, 
    321             's'   => sub { $reqspec->{src} = 1 }, 
    322         }, @args ]) }; 
    323  
    324     my $rpmlist = $c->forward('/search/byname', [ $reqspec, $args[0] ]); 
    325     foreach (@{ $rpmlist->{results} }) { 
    326         my $info = $c->forward('/rpms/queryformat', [ $_, '%{license}' ]); 
    327         push @message, $info . ' // ' . 
    328             $c->forward('_fmt_location', [ $_ ]); 
    329     } 
    330     return $c->stash->{xmlrpc} = { 
    331         message => \@message, 
    332     } 
    333 } 
    334  
    335 =head2 l 
    336  
    337 Is an alias to C<license> command. 
    338  
    339 =cut  
    340  
    341 sub l : XMLRPC { 
    342     my ($self, $c, @args) = @_; 
    343     $c->forward('license', [ @args ]); 
    344 } 
    345  
    346 =head2 buildtime [-s] NAME 
    347  
    348 Show the build time of package C<NAME>. 
    349  
    350 =cut 
    351  
    352 sub buildtime : XMLRPC { 
    353     my ($self, $c, $reqspec, @args) = @_; 
    354  
    355     my @message; 
    356     $reqspec->{src} = 0; 
    357  
    358     @args = @{ $c->forward('_getopt', [ 
    359         { 
    360             'd=s' => \$reqspec->{distribution}, 
    361             'v=s' => \$reqspec->{release}, 
    362             'a=s' => \$reqspec->{arch}, 
    363             's'   => sub { $reqspec->{src} = 1 }, 
    364         }, @args ]) }; 
    365  
    366     my $rpmlist = $c->forward('/search/byname', [ $reqspec, $args[0] ]); 
    367     foreach (@{ $rpmlist->{results} }) { 
    368         my $info = $c->forward('/rpms/queryformat', [ $_, '%{buildtime:date}' ]); 
    369         push @message, $info . ' // ' . 
    370             $c->forward('_fmt_location', [ $_ ]); 
    371     } 
    372     return $c->stash->{xmlrpc} = { 
    373         message => \@message, 
    374     } 
    375 } 
    376  
    377 =head2 builddate 
    378  
    379 Is an alias for C<buildtime> command. 
    380  
    381 =cut 
    382  
    383 sub builddate : XMLRPC { 
    384     my ($self, $c, @args) = @_; 
    385     $c->forward('buildtime', [ @args ]); 
    386 } 
    387  
    388 =head2 builddate 
    389  
    390 Is an alias for C<buildtime> command. 
    391  
    392 =cut 
    393  
    394 sub b : XMLRPC { 
    395     my ($self, $c, @args) = @_; 
    396     $c->forward('builddate', [ @args ]); 
    397 } 
    398  
    399 =head2 qf rpmname format 
    400  
    401 Perform an rpm -q --qf on package named C<rpmname> 
    402  
    403 =cut 
    404  
    405 sub qf : XMLRPC { 
    406     my ($self, $c, $reqspec, @args) = @_; 
    407     my @message; 
    408     $reqspec->{src} = 0; 
    409  
    410     @args = @{ $c->forward('_getopt', [ 
    411         { 
    412             'd=s' => \$reqspec->{distribution}, 
    413             'v=s' => \$reqspec->{release}, 
    414             'a=s' => \$reqspec->{arch}, 
    415             's'   => sub { $reqspec->{src} = 1 }, 
    416         }, @args ]) }; 
    417  
    418     my $rpmlist = $c->forward('/search/byname', [ $reqspec, $args[0] ]); 
    419     foreach (@{ $rpmlist->{results} }) { 
    420         my $info = $c->forward('/rpms/queryformat', [ $_, $args[1] ]); 
    421         push @message, $info; 
    422     } 
    423     return $c->stash->{xmlrpc} = { 
    424         message => \@message, 
    425     } 
    426 } 
    427  
    428333=head1 AUTHOR 
    429334 
Note: See TracChangeset for help on using the changeset viewer.