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

filter: Statementstmt 100% 52 / 52 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod 100% 1 / 1 totaltotal 98.4% 62 / 63 CC 3 SCAR 3.4
CC
3
Cov
98%
_init
2.0
as_xml
2.0
BEGIN
1.0
CRAP 1.4
« blib/lib/WWW/Ohloh/API/ActivityFact.pm ↑ Summary blib/lib/WWW/Ohloh/API/Repository.pm »
1 package WWW::Ohloh::API::ContributorLanguageFact;
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  
10 16 our $VERSION = '1.0_1';
11  
12 16 my @ohloh_of : Field : Arg(ohloh) : Get(_ohloh);
13 16 my @request_url_of : Field : Arg(request_url) : Get( request_url );
14 16 my @xml_of : Field : Arg(xml);
15  
16 16 my @api_fields = qw/
17 analysis_id
18 contributor_id
19 contributor_name
20 language_id
21 language_nice_name
22 comment_ratio
23 man_months
24 commits
25 median_commits
26 /;
27  
28 16 my @analysis_id_of : Field : Set(_set_analysis_id) : Get(analysis_id);
29 16 my @contributor_id_of : Field : Set(_set_contributor_id) :
30 Get(contributor_id);
31 16 my @contributor_name_of : Field : Set(_set_contributor_name) :
32 Get(contributor_name);
33 16 my @language_id_of : Field : Set(_set_language_id) : Get(language_id);
34 16 my @language_nice_name_of : Field : Set(_set_language_nice_name) :
35 Get(language_nice_name);
36 16 my @comment_ratio_of : Field : Set(_set_comment_ratio) : Get(comment_ratio);
37 16 my @man_months_of : Field : Set(_set_man_months) : Get(man_months);
38 16 my @commits_of : Field : Set(_set_commits) : Get(commits);
39 16 my @median_commits_of : Field : Set(_set_median_commits) :
40 Get(median_commits);
41  
42 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
43  
44 sub _init : Init {
45 7 ▶ my $self = shift;
Subroutine _init: called CC=2 SCAR=6.9
46  
47 7 ▶ my $dom = $xml_of[$$self] or return;
Branch: 1 branch
BranchTrueFalseTotal
my $dom = $xml_of[$$self] or return 0 7 7
48  
49 7 $self->_set_analysis_id( $dom->findvalue("analysis_id/text()") );
50 7 $self->_set_contributor_id( $dom->findvalue("contributor_id/text()") );
51 7 $self->_set_contributor_name(
52 $dom->findvalue("contributor_name/text()") );
53 7 $self->_set_language_id( $dom->findvalue("language_id/text()") );
54 7 $self->_set_language_nice_name(
55 $dom->findvalue("language_nice_name/text()") );
56 7 $self->_set_comment_ratio( $dom->findvalue("comment_ratio/text()") );
57 7 $self->_set_man_months( $dom->findvalue("man_months/text()") );
58 7 $self->_set_commits( $dom->findvalue("commits/text()") );
59 7 $self->_set_median_commits( $dom->findvalue("median_commits/text()") );
60  
61 16 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
62  
63 sub as_xml {
64 1 ▶ my $self = shift;
Subroutine as_xml: called CC=2 SCAR=6.9
Pod documented
65 1 my $xml;
66 1 my $w = XML::Writer->new( OUTPUT => \$xml );
67  
68 1 $w->startTag('contributor_language_fact');
69  
70 1 for my $attr (@api_fields) {
71 9 $w->dataElement( $attr => $self->$attr );
72 }
73  
74 1 $w->endTag;
75  
76 1 return $xml;
77 }
78  
79 16 'end of WWW::Ohloh::API::ContributorLanguageFact';
80  
81 __END__
82  
83 =head1 NAME
84  
85 WWW::Ohloh::API::ContributorLanguageFact - Ohloh stats about a project's
86 contributor for a specific language
87  
88 =head1 SYNOPSIS
89  
90 use WWW::Ohloh::API;
91  
92 my $ohloh = WWW::Ohloh::API->new( api_key => $my_api_key );
93 my @facts = $ohloh->get_contributor_language_facts(
94 project_id => 12933,
95 contributor_id => 1234
96 );
97
98 =head1 DESCRIPTION
99  
100 W::O::A::ContributorLanguageFact contains the information associated with
101 a language-specific contribution of a member of a project
102 as defined at http://www.ohloh.net/api/reference/contributor_language_fact.
103 To be properly populated, it must be created via
104 the C<get_contributor_language_facts> method of a
105 L<WWW::Ohloh::API> object.
106  
107 =head1 METHODS
108  
109 =head2 API Data Accessors
110  
111 =head3 analysis_id
112  
113 Return the id of the analysis which provided the data for
114 the contributor_language_fact.
115  
116 =head3 contributor_id
117  
118 Return the id of the contributor, which is unique
119 within the scope of the project, but not globally.
120  
121 =head3 contributor_name
122  
123 Return the name used by the contrinutor when committing to
124 the source control server.
125  
126 =head3 language_id
127  
128 Return the id of the language measured.
129  
130 =head3 language_nice_name
131  
132 Return the name of the language measured.
133  
134 =head3 comment_ratio
135  
136 Return the ratio of lines committed by this contributor
137 that are comments.
138  
139 =head3 man_months
140  
141 The total number of months for which this contributor made at least
142 one commit.
143  
144 =head3 commits
145  
146 Return the total number of commits made by this contributor.
147  
148 =head3 median_commits
149  
150 Return the median number of commits by this contributor
151 by active month.
152  
153 =head2 Other Methods
154  
155 =head3 as_xml
156  
157 Return the account information
158 as an XML string. Note that this is not the exact xml document as returned
159 by the Ohloh server.
160  
161 =head1 SEE ALSO
162  
163 =over
164  
165 =item *
166  
167 L<WWW::Ohloh::API>, L<WWW::Ohloh::API::KudoScore>,
168 L<WWW::Ohloh::API::ContributorFact>.
169  
170 =item *
171  
172 Ohloh API reference: http://www.ohloh.net/api/getting_started
173  
174 =item *
175  
176 Ohloh Account API reference:
177 http://www.ohloh.net/api/reference/contributor_language_fact
178  
179 =back
180  
181 =head1 VERSION
182  
183 This document describes WWW::Ohloh::API::ContributorLanguageFact
184 version 0.0.6
185  
186 =head1 BUGS AND LIMITATIONS
187  
188 WWW::Ohloh::API is very extremely alpha quality. It'll improve,
189 but till then: I<Caveat emptor>.
190  
191 The C<as_xml()> method returns a re-encoding of the account data, which
192 can differ of the original xml document sent by the Ohloh server.
193  
194 Please report any bugs or feature requests to
195 C<bug-www-ohloh-api@rt.cpan.org>, or through the web interface at
196 L<http://rt.cpan.org>.
197  
198  
199 =head1 AUTHOR
200  
201 Yanick Champoux C<< <yanick@cpan.org> >>
202  
203 =head1 LICENCE AND COPYRIGHT
204  
205 Copyright (c) 2008, Yanick Champoux C<< <yanick@cpan.org> >>. All rights reserved.
206  
207 This module is free software; you can redistribute it and/or
208 modify it under the same terms as Perl itself. See L<perlartistic>.
209  
210  
211  
« blib/lib/WWW/Ohloh/API/ActivityFact.pm ↑ Summary blib/lib/WWW/Ohloh/API/Repository.pm »