| 1 | package WWW::Ohloh::API::SizeFact; | ||||||||||
| 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 | 15 | ▶ | use WWW::Ohloh::API::KudoScore; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | |||||||||||
| 11 | 15 | our $VERSION = '0.3.2'; | |||||||||
| 12 | |||||||||||
| 13 | 15 | my @ohloh_of : Field : Arg(ohloh) : Get(_ohloh); | |||||||||
| 14 | 15 | my @request_url_of : Field : Arg(request_url) : Get( request_url ); | |||||||||
| 15 | 15 | my @xml_of : Field : Arg(xml); | |||||||||
| 16 | |||||||||||
| 17 | 15 | my @api_fields = qw/ | |||||||||
| 18 | month | ||||||||||
| 19 | code | ||||||||||
| 20 | comments | ||||||||||
| 21 | blanks | ||||||||||
| 22 | comment_ratio | ||||||||||
| 23 | commits | ||||||||||
| 24 | man_months | ||||||||||
| 25 | /; | ||||||||||
| 26 | |||||||||||
| 27 | 15 | my @month_of : Field : Set(_set_month) : Get(month); | |||||||||
| 28 | 15 | my @code_of : Field : Set(_set_code) : Get(code); | |||||||||
| 29 | 15 | my @comments_of : Field : Set(_set_comments) : Get(comments); | |||||||||
| 30 | 15 | my @blanks_of : Field : Set(_set_blanks) : Get(blanks); | |||||||||
| 31 | 15 | my @comment_ratio_of : Field : Set(_set_comment_ratio) : Get(comment_ratio); | |||||||||
| 32 | 15 | my @commits_of : Field : Set(_set_commits) : Get(commits); | |||||||||
| 33 | 15 | my @man_months_of : Field : Set(_set_man_months) : Get(man_months); | |||||||||
| 34 | |||||||||||
| 35 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||||||||||
| 36 | |||||||||||
| 37 | sub _init : Init { | ||||||||||
| 38 | 73 | ▶ | my $self = shift; | ||||||||
|
Subroutine
_init: called CC=3 SCAR=11.1
| |||||||||||
| 39 | |||||||||||
| 40 | 73 | ▶ | my $dom = $xml_of[$$self] or return; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 41 | |||||||||||
| 42 | 73 | for my $f (@api_fields) { | |||||||||
| 43 | 511 | my $m = "_set_$f"; | |||||||||
| 44 | |||||||||||
| 45 | 511 | $self->$m( $dom->findvalue("$f/text()") ); | |||||||||
| 46 | } | ||||||||||
| 47 | |||||||||||
| 48 | 15 | ▶ | } | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 49 | |||||||||||
| 50 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||||||||||
| 51 | |||||||||||
| 52 | sub _overload_array_ref : Arrayify { | ||||||||||
| 53 | 1 | ▶ | my $self = shift; | ||||||||
|
Subroutine
_overload_array_ref: called CC=1 SCAR=0.0
| |||||||||||
| 54 | |||||||||||
| 55 | 1 | return [ $self->stats ]; | |||||||||
| 56 | 15 | ▶ | } | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 57 | |||||||||||
| 58 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||||||||||
| 59 | |||||||||||
| 60 | sub stats { | ||||||||||
| 61 | 2 | ▶ | my $self = shift; | ||||||||
|
Subroutine
stats: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 62 | |||||||||||
| 63 | 2 | return map { $self->$_ } qw/ | |||||||||
| 64 | month | ||||||||||
| 65 | commits | ||||||||||
| 66 | code | ||||||||||
| 67 | blanks | ||||||||||
| 68 | comments | ||||||||||
| 69 | comment_ratio | ||||||||||
| 70 | man_months | ||||||||||
| 71 | /; | ||||||||||
| 72 | } | ||||||||||
| 73 | |||||||||||
| 74 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||||||||||
| 75 | |||||||||||
| 76 | sub as_xml { | ||||||||||
| 77 | 1 | ▶ | my $self = shift; | ||||||||
|
Subroutine
as_xml: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 78 | 1 | my $xml; | |||||||||
| 79 | 1 | my $w = XML::Writer->new( OUTPUT => \$xml ); | |||||||||
| 80 | |||||||||||
| 81 | 1 | $w->startTag('size_fact'); | |||||||||
| 82 | |||||||||||
| 83 | 1 | for my $attr (@api_fields) { | |||||||||
| 84 | 7 | $w->dataElement( $attr => $self->$attr ); | |||||||||
| 85 | } | ||||||||||
| 86 | |||||||||||
| 87 | 1 | $w->endTag; | |||||||||
| 88 | |||||||||||
| 89 | 1 | return $xml; | |||||||||
| 90 | } | ||||||||||
| 91 | |||||||||||
| 92 | 15 | 'end of WWW::Ohloh::API::SizeFact'; | |||||||||
| 93 | __END__ | ||||||||||
| 94 | |||||||||||
| 95 | =head1 NAME | ||||||||||
| 96 | |||||||||||
| 97 | WWW::Ohloh::API::SizeFact - statistics about a Project source code | ||||||||||
| 98 | |||||||||||
| 99 | =head1 SYNOPSIS | ||||||||||
| 100 | |||||||||||
| 101 | use WWW::Ohloh::API; | ||||||||||
| 102 | |||||||||||
| 103 | my $ohloh = WWW::Ohloh::API->new( api_key => $my_api_key ); | ||||||||||
| 104 | my @size_facts = $ohloh->get_size_facts( $project_id ); | ||||||||||
| 105 | |||||||||||
| 106 | my $size_fact = shift @size_facts; | ||||||||||
| 107 | |||||||||||
| 108 | print $size_fact->month; | ||||||||||
| 109 | |||||||||||
| 110 | =head1 DESCRIPTION | ||||||||||
| 111 | |||||||||||
| 112 | W::O::A::SizeFact contains the statistics associated with an Ohloh | ||||||||||
| 113 | project. | ||||||||||
| 114 | To be properly populated, it must be created via | ||||||||||
| 115 | the C<get_size_facts> method of a L<WWW::Ohloh::API> object. | ||||||||||
| 116 | |||||||||||
| 117 | =head1 METHODS | ||||||||||
| 118 | |||||||||||
| 119 | =head2 API Data Accessors | ||||||||||
| 120 | |||||||||||
| 121 | =head3 month | ||||||||||
| 122 | |||||||||||
| 123 | Indicate the month covered by this SizeFact. | ||||||||||
| 124 | |||||||||||
| 125 | =head3 code | ||||||||||
| 126 | |||||||||||
| 127 | The total net lines of code, excluding comments and blanks, as of the end of this month. | ||||||||||
| 128 | |||||||||||
| 129 | =head3 comments | ||||||||||
| 130 | |||||||||||
| 131 | The total net lines of comments as of the end of this month. | ||||||||||
| 132 | |||||||||||
| 133 | =head3 blanks | ||||||||||
| 134 | |||||||||||
| 135 | The total net blank lines as of the end of this month. | ||||||||||
| 136 | |||||||||||
| 137 | =head3 comment_ratio | ||||||||||
| 138 | |||||||||||
| 139 | The fraction of net lines which are comments as of the end of this month. | ||||||||||
| 140 | |||||||||||
| 141 | =head3 man_months | ||||||||||
| 142 | |||||||||||
| 143 | The cumulative total months of effort expended by all contributors on this project, including this month. | ||||||||||
| 144 | |||||||||||
| 145 | =head3 stats | ||||||||||
| 146 | |||||||||||
| 147 | ( $month, $commits, $code, $blanks, $comments, $comment_ratio, $man_month ) | ||||||||||
| 148 | = $size_fact->stats; | ||||||||||
| 149 | |||||||||||
| 150 | Return the facts as an array. | ||||||||||
| 151 | |||||||||||
| 152 | =head2 Other Methods | ||||||||||
| 153 | |||||||||||
| 154 | =head3 as_xml | ||||||||||
| 155 | |||||||||||
| 156 | Return the size fact | ||||||||||
| 157 | as an XML string. Note that this is not the exact xml document as returned | ||||||||||
| 158 | by the Ohloh server. | ||||||||||
| 159 | |||||||||||
| 160 | =head2 Overloading | ||||||||||
| 161 | |||||||||||
| 162 | =head3 Array reference | ||||||||||
| 163 | |||||||||||
| 164 | @stats = @$size_fact; # equivalent to | ||||||||||
| 165 | # @stats = $size_fact->stats | ||||||||||
| 166 | |||||||||||
| 167 | Using the object as an array reference can be used as a | ||||||||||
| 168 | shortcut for the method I<stats>. | ||||||||||
| 169 | |||||||||||
| 170 | =head1 SEE ALSO | ||||||||||
| 171 | |||||||||||
| 172 | =over | ||||||||||
| 173 | |||||||||||
| 174 | =item * | ||||||||||
| 175 | |||||||||||
| 176 | L<WWW::Ohloh::API>. | ||||||||||
| 177 | |||||||||||
| 178 | =item * | ||||||||||
| 179 | |||||||||||
| 180 | Ohloh API reference: http://www.ohloh.net/api/getting_started | ||||||||||
| 181 | |||||||||||
| 182 | =item * | ||||||||||
| 183 | |||||||||||
| 184 | Ohloh size_fact API reference: | ||||||||||
| 185 | http://www.ohloh.net/api/reference/size_fact | ||||||||||
| 186 | |||||||||||
| 187 | =back | ||||||||||
| 188 | |||||||||||
| 189 | =head1 VERSION | ||||||||||
| 190 | |||||||||||
| 191 | This document describes WWW::Ohloh::API version 0.3.2 | ||||||||||
| 192 | |||||||||||
| 193 | =head1 BUGS AND LIMITATIONS | ||||||||||
| 194 | |||||||||||
| 195 | WWW::Ohloh::API is very extremely alpha quality. It'll improve, | ||||||||||
| 196 | but till then: I<Caveat emptor>. | ||||||||||
| 197 | |||||||||||
| 198 | The C<as_xml()> method returns a re-encoding of the account data, which | ||||||||||
| 199 | can differ of the original xml document sent by the Ohloh server. | ||||||||||
| 200 | |||||||||||
| 201 | Please report any bugs or feature requests to | ||||||||||
| 202 | C<bug-www-ohloh-api@rt.cpan.org>, or through the web interface at | ||||||||||
| 203 | L<http://rt.cpan.org>. | ||||||||||
| 204 | |||||||||||
| 205 | |||||||||||
| 206 | =head1 AUTHOR | ||||||||||
| 207 | |||||||||||
| 208 | Yanick Champoux C<< <yanick@cpan.org> >> | ||||||||||
| 209 | |||||||||||
| 210 | =head1 LICENCE AND COPYRIGHT | ||||||||||
| 211 | |||||||||||
| 212 | Copyright (c) 2008, Yanick Champoux C<< <yanick@cpan.org> >>. All rights reserved. | ||||||||||
| 213 | |||||||||||
| 214 | This module is free software; you can redistribute it and/or | ||||||||||
| 215 | modify it under the same terms as Perl itself. See L<perlartistic>. | ||||||||||
| 216 | |||||||||||