| 1 | package WWW::Ohloh::API::ActivityFact; | ||||||||||
| 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 Carp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 15 | ▶ | use Object::InsideOut; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 15 | ▶ | use XML::LibXML; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | 15 | our $VERSION = '0.3.2'; | |||||||||
| 11 | |||||||||||
| 12 | 15 | my @request_url_of : Field : Arg(request_url) : Get( request_url ); | |||||||||
| 13 | 15 | my @xml_of : Field : Arg(xml); | |||||||||
| 14 | |||||||||||
| 15 | 15 | my @api_fields = qw/ | |||||||||
| 16 | month | ||||||||||
| 17 | code_added | ||||||||||
| 18 | code_removed | ||||||||||
| 19 | comments_added | ||||||||||
| 20 | comments_removed | ||||||||||
| 21 | blanks_added | ||||||||||
| 22 | blanks_removed | ||||||||||
| 23 | commits | ||||||||||
| 24 | contributors | ||||||||||
| 25 | /; | ||||||||||
| 26 | |||||||||||
| 27 | 15 | my @month_of : Field : Set(_set_month) : Get(month); | |||||||||
| 28 | 15 | my @code_added_of : Field : Set(_set_code_added) : Get(code_added); | |||||||||
| 29 | 15 | my @code_removed_of : Field : Set(_set_code_removed) : Get(code_removed); | |||||||||
| 30 | 15 | my @comments_added_of : Field : Set(_set_comments_added) : | |||||||||
| 31 | Get(comments_added); | ||||||||||
| 32 | 15 | my @comments_removed_of : Field : Set(_set_comments_removed) : | |||||||||
| 33 | Get(comments_removed); | ||||||||||
| 34 | 15 | my @blanks_added_of : Field : Set(_set_blanks_added) : Get(blanks_added); | |||||||||
| 35 | 15 | my @blanks_removed_of : Field : Set(_set_blanks_removed) : | |||||||||
| 36 | Get(blanks_removed); | ||||||||||
| 37 | 15 | my @commits_of : Field : Set(_set_commits) : Get(commits); | |||||||||
| 38 | 15 | my @contributors_of : Field : Set(_set_contributors) : Get(contributors); | |||||||||
| 39 | |||||||||||
| 40 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||||||||||
| 41 | |||||||||||
| 42 | sub _init : Init { | ||||||||||
| 43 | 70 | ▶ | my $self = shift; | ||||||||
|
Subroutine
_init: called CC=2 SCAR=6.9
| |||||||||||
| 44 | |||||||||||
| 45 | 70 | ▶ | my $dom = $xml_of[$$self] or return; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 46 | |||||||||||
| 47 | 70 | $self->_set_month( $dom->findvalue("month/text()") ); | |||||||||
| 48 | 70 | $self->_set_code_added( $dom->findvalue("code_added/text()") ); | |||||||||
| 49 | 70 | $self->_set_code_removed( $dom->findvalue("code_removed/text()") ); | |||||||||
| 50 | 70 | $self->_set_comments_added( $dom->findvalue("comments_added/text()") ); | |||||||||
| 51 | 70 | $self->_set_comments_removed( | |||||||||
| 52 | $dom->findvalue("comments_removed/text()") ); | ||||||||||
| 53 | 70 | $self->_set_blanks_added( $dom->findvalue("blanks_added/text()") ); | |||||||||
| 54 | 70 | $self->_set_blanks_removed( $dom->findvalue("blanks_removed/text()") ); | |||||||||
| 55 | 70 | $self->_set_commits( $dom->findvalue("commits/text()") ); | |||||||||
| 56 | 70 | $self->_set_contributors( $dom->findvalue("contributors/text()") ); | |||||||||
| 57 | |||||||||||
| 58 | 70 | return; | |||||||||
| 59 | 15 | ▶ | } | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 60 | |||||||||||
| 61 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||||||||||
| 62 | |||||||||||
| 63 | sub as_xml { | ||||||||||
| 64 | 70 | ▶ | my $self = shift; | ||||||||
|
Subroutine
as_xml: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 65 | 70 | my $xml; | |||||||||
| 66 | 70 | my $w = XML::Writer->new( OUTPUT => \$xml ); | |||||||||
| 67 | |||||||||||
| 68 | 70 | $w->startTag('activity_fact'); | |||||||||
| 69 | |||||||||||
| 70 | 70 | for my $e (@api_fields) { | |||||||||
| 71 | 630 | $w->dataElement( $e => $self->$e ); | |||||||||
| 72 | } | ||||||||||
| 73 | |||||||||||
| 74 | 70 | $w->endTag; | |||||||||
| 75 | |||||||||||
| 76 | 70 | return $xml; | |||||||||
| 77 | } | ||||||||||
| 78 | |||||||||||
| 79 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||||||||||
| 80 | |||||||||||
| 81 | 15 | 'end of WWW::Ohloh::API::ActivityFact'; | |||||||||
| 82 | |||||||||||
| 83 | __END__ | ||||||||||
| 84 | |||||||||||
| 85 | =head1 NAME | ||||||||||
| 86 | |||||||||||
| 87 | WWW::Ohloh::API::ActivityFact - collection of statistics about an Ohloh project | ||||||||||
| 88 | |||||||||||
| 89 | =head1 SYNOPSIS | ||||||||||
| 90 | |||||||||||
| 91 | use WWW::Ohloh::API; | ||||||||||
| 92 | |||||||||||
| 93 | my $ohloh = WWW::Ohloh::API->new( api_key => $my_api_key ); | ||||||||||
| 94 | my $facts = $ohloh->get_activity_facts( $project_id, $analysis); | ||||||||||
| 95 | my $fact = $facts->latest; | ||||||||||
| 96 | |||||||||||
| 97 | print $fact->month, ": ", $fact->contributors; | ||||||||||
| 98 | |||||||||||
| 99 | =head1 DESCRIPTION | ||||||||||
| 100 | |||||||||||
| 101 | W::O::A::ActivityFact contains monthly statistics about an Ohloh-registered | ||||||||||
| 102 | project. | ||||||||||
| 103 | To be properly populated, it must be retrieved via | ||||||||||
| 104 | a L<WWW::Ohloh::API::ActivityFacts> object. | ||||||||||
| 105 | |||||||||||
| 106 | =head1 METHODS | ||||||||||
| 107 | |||||||||||
| 108 | =head2 API Data Accessors | ||||||||||
| 109 | |||||||||||
| 110 | =head3 month | ||||||||||
| 111 | |||||||||||
| 112 | Return the month covered by this activity fact. | ||||||||||
| 113 | |||||||||||
| 114 | =head3 code_added, code_removed, comments_added, comments_removed, | ||||||||||
| 115 | blanks_added, blanks_removed | ||||||||||
| 116 | |||||||||||
| 117 | Return the number of lines of code/comments/blanks added/removed during this | ||||||||||
| 118 | month. | ||||||||||
| 119 | |||||||||||
| 120 | =head3 commits | ||||||||||
| 121 | |||||||||||
| 122 | Return the number of commits made during that month. | ||||||||||
| 123 | |||||||||||
| 124 | =head3 contributors | ||||||||||
| 125 | |||||||||||
| 126 | Return the number of contributors having made at least one commit during | ||||||||||
| 127 | this month. | ||||||||||
| 128 | |||||||||||
| 129 | =head2 Other Methods | ||||||||||
| 130 | |||||||||||
| 131 | =head3 as_xml | ||||||||||
| 132 | |||||||||||
| 133 | Return the activity fact information | ||||||||||
| 134 | as an XML string. Note that this is not the exact xml document as returned | ||||||||||
| 135 | by the Ohloh server. | ||||||||||
| 136 | |||||||||||
| 137 | =head1 SEE ALSO | ||||||||||
| 138 | |||||||||||
| 139 | =over | ||||||||||
| 140 | |||||||||||
| 141 | =item * | ||||||||||
| 142 | |||||||||||
| 143 | L<WWW::Ohloh::API>, | ||||||||||
| 144 | L<WWW::Ohloh::ActivitieFacts>, | ||||||||||
| 145 | L<WWW::Ohloh::API::KudoScore>. | ||||||||||
| 146 | |||||||||||
| 147 | =item * | ||||||||||
| 148 | |||||||||||
| 149 | Ohloh API reference: http://www.ohloh.net/api/getting_started | ||||||||||
| 150 | |||||||||||
| 151 | =item * | ||||||||||
| 152 | |||||||||||
| 153 | Ohloh Account API reference: http://www.ohloh.net/api/reference/activity_fact | ||||||||||
| 154 | |||||||||||
| 155 | =back | ||||||||||
| 156 | |||||||||||
| 157 | =head1 VERSION | ||||||||||
| 158 | |||||||||||
| 159 | This document describes WWW::Ohloh::API version 0.3.2 | ||||||||||
| 160 | |||||||||||
| 161 | =head1 BUGS AND LIMITATIONS | ||||||||||
| 162 | |||||||||||
| 163 | WWW::Ohloh::API is very extremely alpha quality. It'll improve, | ||||||||||
| 164 | but till then: I<Caveat emptor>. | ||||||||||
| 165 | |||||||||||
| 166 | The C<as_xml()> method returns a re-encoding of the activity fact data, which | ||||||||||
| 167 | can differ of the original xml document sent by the Ohloh server. | ||||||||||
| 168 | |||||||||||
| 169 | Please report any bugs or feature requests to | ||||||||||
| 170 | C<bug-www-ohloh-api@rt.cpan.org>, or through the web interface at | ||||||||||
| 171 | L<http://rt.cpan.org>. | ||||||||||
| 172 | |||||||||||
| 173 | |||||||||||
| 174 | =head1 AUTHOR | ||||||||||
| 175 | |||||||||||
| 176 | Yanick Champoux C<< <yanick@cpan.org> >> | ||||||||||
| 177 | |||||||||||
| 178 | =head1 LICENCE AND COPYRIGHT | ||||||||||
| 179 | |||||||||||
| 180 | Copyright (c) 2008, Yanick Champoux C<< <yanick@cpan.org> >>. All rights reserved. | ||||||||||
| 181 | |||||||||||
| 182 | This module is free software; you can redistribute it and/or | ||||||||||
| 183 | modify it under the same terms as Perl itself. See L<perlartistic>. | ||||||||||
| 184 | |||||||||||
| 185 | =cut | ||||||||||
| 186 | |||||||||||
| 187 | |||||||||||