blib/lib/WWW/Ohloh/API/Enlistments.pm

filter: Statementstmt 91.6% 33 / 36 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 84.6% 11 / 13 Podpod 0.0% 0 / 4 totaltotal 83.0% 44 / 53 CC 1 SCAR 1.4
CC
1
Cov
92%
is_allowed_sort
2.0
__ANON__
2.0
BEGIN
1.0
CRAP 1.2
« blib/lib/WWW/Ohloh/API/KudoScore.pm ↑ Summary blib/lib/WWW/Ohloh/API/Languages.pm »
1 package WWW::Ohloh::API::Enlistments;
2  
3 15 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 15 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 15 ▶use Object::InsideOut qw/ WWW::Ohloh::API::Collection /;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 15 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 15 ▶use XML::LibXML;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 15 ▶use Readonly;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 15 ▶use List::MoreUtils qw/ any /;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 15 ▶use WWW::Ohloh::API::Enlistment;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 15 our $VERSION = '0.3.2';
15  
16 15 my @ALLOWED_SORTING;
17 15 Readonly @ALLOWED_SORTING => qw/ module_name type url /;
18  
19 15 my @project_id_of : Field : Arg(project_id) : Set(_set_project_id) :
20 Get(project_id);
21  
22 1 ▶sub element { return 'WWW::Ohloh::API::Enlistment' }
Subroutine element: called CC=1 SCAR=0.0
Pod undocumented
23 1 ▶sub element_name { return 'enlistment' }
Subroutine element_name: called CC=1 SCAR=0.0
Pod undocumented
24  
25 sub query_path {
26 1 ▶ my $self = shift;
Subroutine query_path: called CC=1 SCAR=0.0
Pod undocumented
27 1 return "projects/$project_id_of[$$self]/enlistments.xml";
28 }
29  
30 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
31  
32 sub is_allowed_sort {
33 0 ▶ my $s = shift;
Subroutine is_allowed_sort: not called CC=1 SCAR=6.9
Pod undocumented
34 0 ▶ return any { $s eq $_ } @ALLOWED_SORTING;
Subroutine __ANON__: not called CC=1 SCAR=6.9
35 }
36  
37 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
38  
39 15 'end of WWW::Ohloh::API::Enlistments';
40 __END__
41  
42 =head1 NAME
43  
44 WWW::Ohloh::API::Enlistments - a set of Ohloh project enlistments
45  
46 =head1 SYNOPSIS
47  
48 use WWW::Ohloh::API;
49 use WWW::Ohloh::API::Enlistments;
50  
51 my $ohloh = WWW::Ohloh::API( api_key => $key );
52  
53 my $enlistments = $ohloh->get_enlistments( project_id => 123 );
54  
55 while ( my $e = $enlistments->next ) {
56 print $e->repository->url;
57 }
58  
59 =head1 DESCRIPTION
60  
61 W::O::A::Enlistments returns a list of enlistments for a project.
62  
63 The object doesn't retrieve all enlistmentss from the Ohloh
64 server in one go, but rather fetch them in small groups as
65 required. If you want to download all enlistments at the
66 same time, you can use the B<all()> method:
67  
68 my @e = $ohloh->get_enlistments( sort => 'module_name' )->all;
69  
70 =head1 METHODS
71  
72 =head2 new( %args )
73  
74 Creates a new W::O::A::Enlistments object. It accepts the following
75 arguments:
76  
77 =head3 Arguments
78  
79 =over
80  
81 =item ohloh => I<$ohloh>
82  
83 Mandatory. Its value is the L<WWW::Ohloh::API> object that will be used
84 to query the Ohloh server.
85  
86 =item max => I<$n>
87  
88 The maximum number of enlistments the set will contain. If you want to
89 slurp'em all, set it to 'undef' (which is the default).
90  
91 =back
92  
93 =head2 all
94  
95 Returns the retrieved enlistments' information as
96 L<WWW::Ohloh::API::Enlistment> objects.
97  
98 =head2 next( I<$n> )
99  
100 Returns the next I<$n> enlistment (or all remaining enlistments if there are
101 less than I<$n>), or C<undef> if there is no more enlistments
102 to retrieve. After it returned C<undef>, subsequent calls to B<next> will reset
103 the list. If I<$n> is not given, defaults to 1 entry.
104  
105 =head2 max
106  
107 Returns the maximum number of enlistments the object will return, or C<undef>
108 if no maximum has been set.
109  
110 =head2 total_entries
111  
112 Returns the number of entries selected by the query.
113  
114 B<Beware>: this number can change during the life of the object! Each
115 time the object retrieves a new batch of entries, this number is updated
116 with the value returned by the Ohloh server, which could differ from its
117 last invication is
118 entries have been added or removed since the last retrieval.
119  
120 =head1 SEE ALSO
121  
122 =over
123  
124 =item *
125  
126 L<WWW::Ohloh::API>,
127 L<WWW::Ohloh::API::Enlistment>.
128  
129  
130 =item *
131  
132 Ohloh API reference: http://www.ohloh.net/api/getting_started
133  
134 =item *
135  
136 Ohloh Account API reference: http://www.ohloh.net/api/reference/enlistment
137  
138 =back
139  
140 =head1 VERSION
141  
142 This document describes WWW::Ohloh::API version 0.3.2
143  
144 =head1 BUGS AND LIMITATIONS
145  
146 WWW::Ohloh::API is very extremely alpha quality. It'll improve,
147 but till then: I<Caveat emptor>.
148  
149 Please report any bugs or feature requests to
150 C<bug-www-ohloh-api@rt.cpan.org>, or through the web interface at
151 L<http://rt.cpan.org>.
152  
153  
154 =head1 AUTHOR
155  
156 Yuval Kogman and
157 Yanick Champoux C<< <yanick@cpan.org> >>
158  
159 =head1 LICENCE AND COPYRIGHT
160  
161 Copyright (c) 2008, Yanick Champoux C<< <yanick@cpan.org> >>. All rights reserved.
162  
163 This module is free software; you can redistribute it and/or
164 modify it under the same terms as Perl itself. See L<perlartistic>.
165  
166 =cut
167  
« blib/lib/WWW/Ohloh/API/KudoScore.pm ↑ Summary blib/lib/WWW/Ohloh/API/Languages.pm »