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

filter: Statementstmt 89.8% 44 / 49 Branchbran 37.5% 3 / 8 Conditioncond 33.3% 2 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 86.6% 13 / 15 Podpod 0.0% 0 / 4 totaltotal 72.0% 62 / 86 CC 7 SCAR 11.0
CC
7
Cov
78%
_init
7.5
query_path
3.7
is_allowed_sort
2.0
CRAP 3.0
« blib/lib/WWW/Ohloh/API/Collection.pm ↑ Summary blib/lib/WWW/Ohloh/API/StackEntry.pm »
1 package WWW::Ohloh::API::Messages;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 ▶use Object::InsideOut qw/ WWW::Ohloh::API::Collection /;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use XML::LibXML;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use Readonly;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use List::MoreUtils qw/ any /;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use WWW::Ohloh::API::Message;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 1 our $VERSION = '0.3.2';
15  
16 1 my @account_of : Field : Arg(name => 'account') : Get(account);
17  
18 1 my @project_of : Field : Arg(name => 'project') : Get(project);
19  
20 1 my @ALLOWED_SORTING;
21 1 Readonly @ALLOWED_SORTING => qw/ /; # TODO
22  
23 1 ▶sub element { return 'WWW::Ohloh::API::Message' }
Subroutine element: called CC=1 SCAR=0.0
Pod undocumented
24 1 ▶sub element_name { return 'message' }
Subroutine element_name: called CC=1 SCAR=0.0
Pod undocumented
25  
26 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
27  
28 sub query_path {
29 1 ▶ my $self = shift;
Subroutine query_path: called CC=3 SCAR=13.0
Pod undocumented
30  
31 1 my $path;
32  
33 1 ▶ if ( $self->account ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->account) { } 1 0 1
elsif ($self->project) { } 0 0 0
34 1 $path = 'accounts/' . $self->account;
35 }
36 elsif ( $self->project ) {
37 0 $path = 'projects/' . $self->project;
38 }
39 else {
40 0 croak "needs to have either an acccount or a project";
41 }
42  
43 1 $path .= '/messages.xml';
44  
45 1 return $path;
46 }
47  
48 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
49  
50 sub _init : Init {
51 1 ▶ my $self = shift;
Subroutine _init: called CC=5 SCAR=20.1
52  
53 1 ▶ croak "must use only one of the arguments 'account' and 'project'"
Branch: 1 branch
BranchTrueFalseTotal
if $self->project and $self->account 0 1 1
Condition33%1/3
$self->project and $self->account
!ll&&!rl&&r
100
MC/DC0%0/2
$self->project and $self->account
$self->project $self->account
Truth table33%1/3
A and B
A= $self->projectB= $self->account
ABresult
0X0
100
111
54 if $self->project and $self->account;
55  
56 1 ▶ croak "must use one of the arguments 'account' or 'project'"
Branch: 1 branch
BranchTrueFalseTotal
unless $self->project or $self->account 0 1 1
Condition33%1/3
$self->project or $self->account
l!l&&r!l&&!r
010
MC/DC0%0/2
$self->project or $self->account
$self->project $self->account
Truth table33%1/3
A or B
A= $self->projectB= $self->account
ABresult
1X1
011
000
57 unless $self->project
58 or $self->account;
59 1 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
60  
61 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
62  
63 sub is_allowed_sort {
64 0 ▶ my $s = shift;
Subroutine is_allowed_sort: not called CC=1 SCAR=6.9
Pod undocumented
65 0 ▶ return any { $s eq $_ } @ALLOWED_SORTING;
Subroutine __ANON__: not called CC=1 SCAR=6.9
66 }
67  
68 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
69  
70 1 'end of WWW::Ohloh::API::Messages';
71 __END__
72  
73 =head1 NAME
74  
75 WWW::Ohloh::API::Languages - a set of Ohloh languages
76  
77 =head1 SYNOPSIS
78  
79 use WWW::Ohloh::API;
80 use WWW::Ohloh::API::Languages;
81  
82 my $ohloh = WWW::Ohloh::API( api_key => $key );
83  
84 my $languages = $ohloh->get_languages( sort => 'code' );
85  
86 while ( my $l = $languages->next ) {
87 print $l->nice_name;
88 }
89  
90 =head1 DESCRIPTION
91  
92 W::O::A::Languages returns a list of languages known to Ohloh.
93  
94 The object doesn't retrieve all languages from the Ohloh
95 server in one go, but rather fetch them in small groups as
96 required. If you want to download all languages at the
97 same time, you can use the B<all()> method:
98  
99 my @langs = $ohloh->get_languages( sort => 'code' )->all;
100  
101 =head1 METHODS
102  
103 =head2 new( %args )
104  
105 Creates a new W::O::A::Languages object. It accepts the following
106 arguments:
107  
108 =head3 Arguments
109  
110 =over
111  
112 =item ohloh => I<$ohloh>
113  
114 Mandatory. Its value is the L<WWW::Ohloh::API> object that will be used
115 to query the Ohloh server.
116  
117 =item max => I<$nbr_languages>
118  
119 The maximum number of languages the set will contain. If you want to
120 slurp'em all, set it to 'undef' (which is the default).
121  
122 =back
123  
124 =head2 all
125  
126 Returns the retrieved languages' information as
127 L<WWW::Ohloh::API::Language> objects.
128  
129 =head2 next( I<$n> )
130  
131 Returns the next I<$n> language (or all remaining languages if there are
132 less than I<$n>), or C<undef> if there is no more languages
133 to retrieve. After it returned C<undef>, subsequent calls to B<next> will reset
134 the list. If I<$n> is not given, defaults to 1 entry.
135  
136 =head2 max
137  
138 Returns the maximum number of languages the object will return, or C<undef>
139 if no maximum has been set.
140  
141 =head2 total_entries
142  
143 Returns the number of entries selected by the query.
144  
145 B<Beware>: this number can change during the life of the object! Each
146 time the object retrieves a new batch of entries, this number is updated
147 with the value returned by the Ohloh server, which could differ from its
148 last invication is
149 entries have been added or removed since the last retrieval.
150  
151 =head1 SEE ALSO
152  
153 =over
154  
155 =item *
156  
157 L<WWW::Ohloh::API>,
158 L<WWW::Ohloh::API::Language>.
159  
160  
161 =item *
162  
163 Ohloh API reference: http://www.ohloh.net/api/getting_started
164  
165 =item *
166  
167 Ohloh Account API reference: http://www.ohloh.net/api/reference/language
168  
169 =back
170  
171 =head1 VERSION
172  
173 This document describes WWW::Ohloh::API version 0.3.2
174  
175 =head1 BUGS AND LIMITATIONS
176  
177 WWW::Ohloh::API is very extremely alpha quality. It'll improve,
178 but till then: I<Caveat emptor>.
179  
180 Please report any bugs or feature requests to
181 C<bug-www-ohloh-api@rt.cpan.org>, or through the web interface at
182 L<http://rt.cpan.org>.
183  
184  
185 =head1 AUTHOR
186  
187 Yanick Champoux C<< <yanick@cpan.org> >>
188  
189 =head1 LICENCE AND COPYRIGHT
190  
191 Copyright (c) 2008, Yanick Champoux C<< <yanick@cpan.org> >>. All rights reserved.
192  
193 This module is free software; you can redistribute it and/or
194 modify it under the same terms as Perl itself. See L<perlartistic>.
195  
196 =cut
« blib/lib/WWW/Ohloh/API/Collection.pm ↑ Summary blib/lib/WWW/Ohloh/API/StackEntry.pm »