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