| 1 | package WWW::Ohloh::API::ActivityFacts; | ||
| 2 | |||
| 3 | 16 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 16 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | |||
| 6 | 16 | ▶ | use Carp; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | 16 | ▶ | use Object::InsideOut; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | 16 | ▶ | use XML::LibXML; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | 16 | ▶ | use Readonly; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 10 | 16 | ▶ | use List::MoreUtils qw/ any /; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 11 | 16 | ▶ | use WWW::Ohloh::API::ActivityFact; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 12 | |||
| 13 | 16 | our $VERSION = '1.0_1'; | |
| 14 | |||
| 15 | 16 | my @ohloh_of : Field : Arg(ohloh); | |
| 16 | 16 | my @project_of : Field : Arg(project); | |
| 17 | 16 | my @analysis_of : Field : Arg(analysis); | |
| 18 | 16 | my @facts_of : Field; | |
| 19 | |||
| 20 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| 21 | |||
| 22 | sub _init : Init { | ||
| 23 | 1 | ▶ | my $self = shift; |
|
Subroutine
_init: called CC=1 SCAR=0.0
| |||
| 24 | |||
| 25 | 1 | my ( $url, $xml ) = | |
| 26 | $ohloh_of[$$self] | ||
| 27 | ->_query_server( "projects/$project_of[ $$self ]/analyses/" | ||
| 28 | . "$analysis_of[ $$self ]/activity_facts.xml" ); | ||
| 29 | |||
| 30 | $facts_of[$$self] = | ||
| 31 | 1 | [ map { WWW::Ohloh::API::ActivityFact->new( xml => $_ ) } | |
| 32 | $xml->findnodes('activity_fact') ]; | ||
| 33 | |||
| 34 | 1 | return; | |
| 35 | 16 | ▶ | } |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 36 | |||
| 37 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| 38 | |||
| 39 | sub as_xml { | ||
| 40 | 1 | ▶ | my $self = shift; |
|
Subroutine
as_xml: called CC=2 SCAR=6.9
Pod
documented
| |||
| 41 | 1 | my $xml; | |
| 42 | 1 | my $w = XML::Writer->new( OUTPUT => \$xml ); | |
| 43 | |||
| 44 | 1 | $w->startTag('activity_facts'); | |
| 45 | |||
| 46 | 1 | $xml .= $_->as_xml for @{ $facts_of[$$self] }; | |
| 47 | |||
| 48 | 1 | $w->endTag; | |
| 49 | |||
| 50 | 1 | return $xml; | |
| 51 | } | ||
| 52 | |||
| 53 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| 54 | |||
| 55 | sub all { | ||
| 56 | 1 | ▶ | my $self = shift; |
|
Subroutine
all: called CC=1 SCAR=0.0
Pod
documented
| |||
| 57 | |||
| 58 | 1 | return @{ $facts_of[$$self] }; | |
| 59 | } | ||
| 60 | |||
| 61 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| 62 | |||
| 63 | sub latest { | ||
| 64 | 1 | ▶ | my $self = shift; |
|
Subroutine
latest: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 65 | 1 | return $facts_of[$$self][-1]; | |
| 66 | } | ||
| 67 | |||
| 68 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| 69 | |||
| 70 | sub total { | ||
| 71 | 1 | ▶ | my $self = shift; |
|
Subroutine
total: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 72 | 1 | return scalar @{ $facts_of[$$self] }; | |
| 73 | } | ||
| 74 | |||
| 75 | 16 | 'end of WWW::Ohloh::API::ActivityFacts'; | |
| 76 | __END__ | ||
| 77 | |||
| 78 | =head1 NAME | ||
| 79 | |||
| 80 | WWW::Ohloh::API::ActivityFacts - an Ohloh project's set of activity facts | ||
| 81 | |||
| 82 | =head1 SYNOPSIS | ||
| 83 | |||
| 84 | use WWW::Ohloh::API; | ||
| 85 | |||
| 86 | my $ohloh = WWW::Ohloh::API->new( api_key => $my_api_key ); | ||
| 87 | my $project = $ohloh->get_project( $project_id ); | ||
| 88 | my $facts = $ohloh->activity_facts; | ||
| 89 | |||
| 90 | print "number of facts for the project: ", $facts->total; | ||
| 91 | |||
| 92 | =head1 DESCRIPTION | ||
| 93 | |||
| 94 | W::O::A::ActivityFacts gathers all the activity facts known | ||
| 95 | about a project. | ||
| 96 | To be properly populated, it must be retrieved via | ||
| 97 | the C<get_activity_facts> method of a L<WWW::Ohloh::API> object, | ||
| 98 | or the C<activity_facts()> method of a L<WWW::Ohloh::API::Project> | ||
| 99 | object. | ||
| 100 | |||
| 101 | =head1 METHODS | ||
| 102 | |||
| 103 | =head2 all | ||
| 104 | |||
| 105 | Return the retrieved activity facts as a list of | ||
| 106 | L<WWW::Ohloh::API::ActivityFact> objects. | ||
| 107 | |||
| 108 | Example: | ||
| 109 | |||
| 110 | # sum the overall number of commits for the project | ||
| 111 | my $commits; | ||
| 112 | for my $fact ( $facts->all ) { | ||
| 113 | $commits += $fact->commits; | ||
| 114 | } | ||
| 115 | |||
| 116 | =head3 as_xml | ||
| 117 | |||
| 118 | Return the activity facts | ||
| 119 | as an XML string. Note that this is not the exact xml document as returned | ||
| 120 | by the Ohloh server. | ||
| 121 | |||
| 122 | =head1 SEE ALSO | ||
| 123 | |||
| 124 | =over | ||
| 125 | |||
| 126 | =item * | ||
| 127 | |||
| 128 | L<WWW::Ohloh::API>, | ||
| 129 | L<WWW::Ohloh::API::ActivityFact>, | ||
| 130 | L<WWW::Ohloh::API::Language>, | ||
| 131 | L<WWW::Ohloh::API::Project>, | ||
| 132 | L<WWW::Ohloh::API::Analysis>, | ||
| 133 | L<WWW::Ohloh::API::Account>. | ||
| 134 | |||
| 135 | |||
| 136 | =item * | ||
| 137 | |||
| 138 | Ohloh API reference: http://www.ohloh.net/api/getting_started | ||
| 139 | |||
| 140 | =item * | ||
| 141 | |||
| 142 | Ohloh Account API reference: http://www.ohloh.net/api/reference/activity_fact | ||
| 143 | |||
| 144 | =back | ||
| 145 | |||
| 146 | =head1 VERSION | ||
| 147 | |||
| 148 | This document describes WWW::Ohloh::API version 1.0_1 | ||
| 149 | |||
| 150 | =head1 BUGS AND LIMITATIONS | ||
| 151 | |||
| 152 | WWW::Ohloh::API is very extremely alpha quality. It'll improve, | ||
| 153 | but till then: I<Caveat emptor>. | ||
| 154 | |||
| 155 | Please report any bugs or feature requests to | ||
| 156 | C<bug-www-ohloh-api@rt.cpan.org>, or through the web interface at | ||
| 157 | L<http://rt.cpan.org>. | ||
| 158 | |||
| 159 | |||
| 160 | =head1 AUTHOR | ||
| 161 | |||
| 162 | Yanick Champoux C<< <yanick@cpan.org> >> | ||
| 163 | |||
| 164 | =head1 LICENCE AND COPYRIGHT | ||
| 165 | |||
| 166 | Copyright (c) 2008, Yanick Champoux C<< <yanick@cpan.org> >>. All rights reserved. | ||
| 167 | |||
| 168 | This module is free software; you can redistribute it and/or | ||
| 169 | modify it under the same terms as Perl itself. See L<perlartistic>. | ||
| 170 | |||
| 171 | =cut | ||
| 172 | |||
| 173 | |||