WWW::Ohloh::API::Enlistments - a set of Ohloh project enlistments


WWW-Ohloh-API documentation Contained in the WWW-Ohloh-API distribution.

Index


Code Index:

NAME

Top

WWW::Ohloh::API::Enlistments - a set of Ohloh project enlistments

SYNOPSIS

Top

    use WWW::Ohloh::API;
    use WWW::Ohloh::API::Enlistments;

    my $ohloh = WWW::Ohloh::API( api_key => $key );

    my $enlistments = $ohloh->get_enlistments( project_id => 123 );

    while ( my $e = $enlistments->next ) {
        print $e->repository->url;
    }

DESCRIPTION

Top

W::O::A::Enlistments returns a list of enlistments for a project.

The object doesn't retrieve all enlistmentss from the Ohloh server in one go, but rather fetch them in small groups as required. If you want to download all enlistments at the same time, you can use the all() method:

    my @e = $ohloh->get_enlistments( sort => 'module_name' )->all;

METHODS

Top

new( %args )

Creates a new W::O::A::Enlistments object. It accepts the following arguments:

Arguments

ohloh => $ohloh

Mandatory. Its value is the WWW::Ohloh::API object that will be used to query the Ohloh server.

max => $n

The maximum number of enlistments the set will contain. If you want to slurp'em all, set it to 'undef' (which is the default).

all

Returns the retrieved enlistments' information as WWW::Ohloh::API::Enlistment objects.

next( $n )

Returns the next $n enlistment (or all remaining enlistments if there are less than $n), or undef if there is no more enlistments to retrieve. After it returned undef, subsequent calls to next will reset the list. If $n is not given, defaults to 1 entry.

max

Returns the maximum number of enlistments the object will return, or undef if no maximum has been set.

total_entries

Returns the number of entries selected by the query.

Beware: this number can change during the life of the object! Each time the object retrieves a new batch of entries, this number is updated with the value returned by the Ohloh server, which could differ from its last invication is entries have been added or removed since the last retrieval.

SEE ALSO

Top

*

WWW::Ohloh::API, WWW::Ohloh::API::Enlistment.

*

Ohloh API reference: http://www.ohloh.net/api/getting_started

*

Ohloh Account API reference: http://www.ohloh.net/api/reference/enlistment

VERSION

Top

This document describes WWW::Ohloh::API version 0.3.1

BUGS AND LIMITATIONS

Top

WWW::Ohloh::API is very extremely alpha quality. It'll improve, but till then: Caveat emptor.

Please report any bugs or feature requests to bug-www-ohloh-api@rt.cpan.org, or through the web interface at http://rt.cpan.org.

AUTHOR

Top

Yuval Kogman and Yanick Champoux <yanick@cpan.org>

LICENCE AND COPYRIGHT

Top


WWW-Ohloh-API documentation Contained in the WWW-Ohloh-API distribution.

package WWW::Ohloh::API::Enlistments;

use strict;
use warnings;

use Object::InsideOut qw/ WWW::Ohloh::API::Collection /;

use Carp;
use XML::LibXML;
use Readonly;
use List::MoreUtils qw/ any /;
use WWW::Ohloh::API::Enlistment;

our $VERSION = '0.3.1';

my @ALLOWED_SORTING;
Readonly @ALLOWED_SORTING => qw/ module_name type url /;

my @project_id_of : Field : Arg(project_id) : Set(_set_project_id) :
  Get(project_id);

sub element      { return 'WWW::Ohloh::API::Enlistment' }
sub element_name { return 'enlistment' }

sub query_path {
    my $self = shift;
    return "projects/$project_id_of[$$self]/enlistments.xml";
}

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

sub is_allowed_sort {
    my $s = shift;
    return any { $s eq $_ } @ALLOWED_SORTING;
}

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

'end of WWW::Ohloh::API::Enlistments';
__END__