Changeset 229


Ignore:
Timestamp:
12/29/10 21:37:10 (13 years ago)
Author:
nanardon
Message:
  • complete docs for /rpms functions
  • rename some functions for coherency
Location:
server/trunk/web
Files:
2 edited
2 moved

Legend:

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

    r223 r229  
    6767} 
    6868 
    69 sub basicinfo : XMLRPCLocal { 
     69=head2 rpms.basicinfo( PKGID ) 
     70 
     71Return a struct about basic informations about rpm having pkgid C<PKGID>. 
     72 
     73Example of information return: 
     74 
     75    { 
     76          'arch' => 'x86_64', 
     77          'version' => '0.0.3', 
     78          'src' => '1', 
     79          'issrc' => '1', 
     80          'name' => 'ecap-samples', 
     81          'release' => '1mdv2010.2', 
     82          'description' => 'The sample contains three basic adapters.', 
     83          'pkgid' => 'aa17ce95dd816e0817da78d7af54abdb', 
     84          'summary' => 'Simple ecap samples', 
     85          'filename' => 'ecap-samples-0.0.3-1mdv2010.2.src.rpm', 
     86          'evr' => '0.0.3-1mdv2010.2' 
     87    }; 
     88 
     89=head2 Url: /rpms/<PKGID>/basicinfo?json 
     90 
     91Return a struct about basic informations about rpm having pkgid C<PKGID>. 
     92 
     93Example of information return: 
     94 
     95    { 
     96          'arch' => 'x86_64', 
     97          'version' => '0.0.3', 
     98          'src' => '1', 
     99          'issrc' => '1', 
     100          'name' => 'ecap-samples', 
     101          'release' => '1mdv2010.2', 
     102          'description' => 'The sample contains three basic adapters.', 
     103          'pkgid' => 'aa17ce95dd816e0817da78d7af54abdb', 
     104          'summary' => 'Simple ecap samples', 
     105          'filename' => 'ecap-samples-0.0.3-1mdv2010.2.src.rpm', 
     106          'evr' => '0.0.3-1mdv2010.2' 
     107    }; 
     108 
     109NB: This url works only in JSON format. 
     110 
     111=cut 
     112 
     113sub basicinfo :XMLRPCLocal :Chained('rpms_') :PathPart('basicinfo') :Args(0) { 
    70114    my ($self, $c, $pkgid) = @_; 
     115    $pkgid ||= $c->stash->{pkgid}; 
    71116 
    72117    my $rpm = $c->model('base::Rpms')->find( 
     
    96141} 
    97142 
    98  
    99 sub info : XMLRPCLocal { 
     143=head2 rpms.info( PKGID ) 
     144 
     145Like rpms.basicinfo return a struct containing single information about the request rpm. 
     146 
     147=head2 Url: /rpms/<PKGID>/info?json 
     148 
     149Like rpms/<PKGID>basicinfo return a struct containing single information about the request rpm. 
     150 
     151NB: This url works only in JSON format. 
     152 
     153=cut 
     154 
     155sub info : XMLRPCLocal :Chained('rpms_') :PathPart('info') :Args(0) { 
    100156    my ($self, $c, $pkgid) = @_; 
    101  
     157    $pkgid ||= $c->stash->{pkgid}; 
    102158 
    103159    my $info = $c->forward('basicinfo', [ $pkgid ]); 
     
    120176} 
    121177 
    122 sub deps : XMLRPCLocal { 
     178=head2 rpms.dependency(PKGID, DEPTYPE) 
     179 
     180Return a list of C<DEPTYPE> dependencies for package C<PKGID> where C<DEPTYPE> 
     181is one of: 
     182 
     183=over 4 
     184 
     185=item C<P> for Provides 
     186 
     187=item C<R> for Requires 
     188 
     189=item C<C> for Conflicts 
     190 
     191=item C<O> for Obsoletes 
     192 
     193=item C<E> for Enhanced 
     194 
     195=item C<S> for Suggests 
     196 
     197=back 
     198 
     199=cut 
     200 
     201sub xmlrpc_dependency : XMLRPCPath('dependency') { 
     202    my ($self, $c, @args) = @_; 
     203    $c->forward('dependency', [ @args ]); 
     204} 
     205 
     206=head2 Url: /rpms/<PKGID>/dependency/<DEPTYPE>?json 
     207 
     208Return a list of C<DEPTYPE> dependencies for package C<PKGID> where C<DEPTYPE> 
     209is one of: 
     210 
     211=over 4 
     212 
     213=item C<P> for Provides 
     214 
     215=item C<R> for Requires 
     216 
     217=item C<C> for Conflicts 
     218 
     219=item C<O> for Obsoletes 
     220 
     221=item C<E> for Enhanced 
     222 
     223=item C<S> for Suggests 
     224 
     225=back 
     226 
     227=cut 
     228 
     229sub dependency :XMLRPC :Chained('rpms_') :PathPart('dependency') :Args(1) { 
    123230    my ($self, $c, $pkgid, $deptype) = @_; 
     231    if (!$deptype) { 
     232        $deptype = $pkgid; 
     233        $pkgid = $c->stash->{pkgid}; 
     234    } 
    124235 
    125236    $c->stash->{xmlrpc} = [  
     
    263374    $c->forward('rpms_', [ $pkgid ]); 
    264375    for ($subpart || '') { 
    265         /^deps$/      and $c->go('alldeps',   [ $pkgid, @args ]); 
    266         /^files$/     and $c->go('files',     [ $pkgid, @args ]); 
    267         /^changelog$/ and $c->go('changelog', [ $pkgid, @args ]); 
    268         /^location$/  and $c->go('location',  [ $pkgid, @args ]); 
    269         /^analyse$/   and $c->go('analyse',  [ $pkgid, @args ]); 
    270         /./           and $c->go('/404/index'); # other subpart dont exists 
     376        /^deps$/       and $c->go('deps',        [ $pkgid, @args ]); 
     377        /^files$/      and $c->go('files',       [ $pkgid, @args ]); 
     378        /^changelog$/  and $c->go('changelog',   [ $pkgid, @args ]); 
     379        /^location$/   and $c->go('location',    [ $pkgid, @args ]); 
     380        /^basicinfo$/  and $c->go('basicinfo',   [ $pkgid, @args ]); 
     381        /^info$/       and $c->go('info',        [ $pkgid, @args ]); 
     382        /^analyse$/    and $c->go('analyse',     [ $pkgid, @args ]); 
     383        /^dependency$/ and $c->go('dependency',  [ $pkgid, @args ]); 
     384        /./            and $c->go('/404/index'); # other subpart dont exists 
    271385    } 
    272386    $c->stash->{rpmurl} = $c->req->path; 
     
    282396 
    283397 
    284 sub alldeps :Chained('rpms_') :PathPart('deps') :Args(0) :XMLRPCLocal { 
     398sub deps :Chained('rpms_') :PathPart('deps') :Args(0) :XMLRPCLocal { 
    285399    my ( $self, $c, $pkgid ) = @_; 
    286400    $c->stash->{rpmurl} = ($c->req->path =~ m:(.*)/[^/]+:)[0]; 
     
    441555        my @deplist = map { 
    442556            [ $_->{name}, $_->{sense}, $_->{evr} ] 
    443         } @{ $c->forward('deps', [ $pkgid, 'R' ]) }; 
     557        } @{ $c->forward('dependency', [ $pkgid, 'R' ]) }; 
    444558 
    445559        $c->stash->{xmlrpc} = $c->forward( 
  • server/trunk/web/root/templates/html/rpms/deps.html

    r228 r229  
    33[% INCLUDE 'rpms/menu.tt' %] 
    44 
    5 [% INCLUDE 'rpms/alldeps.tt' %] 
     5[% INCLUDE 'rpms/deps.tt' %] 
  • server/trunk/web/t/controller_Rpms.t

    r183 r229  
    22use warnings; 
    33use Test::More; 
     4use FindBin; 
     5require "$FindBin::Bin/xml.pl"; 
    46 
    57BEGIN { use_ok 'Catalyst::Test', 'Sophie' } 
     
    1416ok( request("/rpms/$pkgid/changelog")->is_success, 'Request a pkgid/changelog should succeed' ); 
    1517ok( request("/rpms/$pkgid/location")->is_success, 'Request a pkgid/location should succeed' ); 
     18 
     19ok( xmlrequest_ok('rpms.basicinfo', $pkgid), 'XMLRPC rpms.basicinfo' ); 
     20ok( request("/rpms/$pkgid/basicinfo?json"), "rpms/basicinfo?json" ); 
     21ok( xmlrequest_ok('rpms.info', $pkgid), 'XMLRPC rpms.basicinfo' ); 
     22ok( request("/rpms/$pkgid/info?json"), "rpms/basicinfo?json" ); 
     23ok( xmlrequest_ok('rpms.dependency', $pkgid, 'R'), 'XMLRPC rpms.dependency' ); 
     24ok( request("/rpms/$pkgid/dependency/R?json"), "rpms/dependency?json" ); 
     25 
    1626done_testing(); 
Note: See TracChangeset for help on using the changeset viewer.