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

filter: Statementstmt 100% 48 / 48 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod 100% 1 / 1 totaltotal 98.3% 59 / 60 CC 2 SCAR 1.8
CC
2
Cov
98%
_init
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.2
« blib/lib/WWW/Ohloh/API/Enlistment.pm ↑ Summary blib/lib/WWW/Ohloh/API/Enlistments.pm »
1 package WWW::Ohloh::API::KudoScore;
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 XML::Writer;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 15 our $VERSION = '0.3.2';
12  
13 15 my @xml_of : Field : Arg(xml);
14  
15 15 my @creation_time_of : Field : Get(created_at) : Set(_set_created_at);
16 15 my @kudo_rank_of : Field : Get(kudo_rank) : Set(_set_kudo_rank);
17 15 my @position_of : Field : Get(position) : Set(_set_position);
18 15 my @max_position_of : Field : Get(max_position) : Set(_set_max_position);
19 15 my @position_delta_of : Field : Get(position_delta) :
20 Set(_set_position_delta);
21  
22 sub _init : Init {
23 9 ▶ my $self = shift;
Subroutine _init: called CC=2 SCAR=7.0
24  
25 9 ▶ my $dom = $xml_of[$$self] or return;
Branch: 1 branch
BranchTrueFalseTotal
my $dom = $xml_of[$$self] or return 0 9 9
26  
27 9 $self->_set_created_at( $dom->findvalue('created_at/text()') );
28 9 $self->_set_kudo_rank( $dom->findvalue('kudo_rank/text()') );
29 9 $self->_set_position( $dom->findvalue('position/text()') );
30 9 $self->_set_max_position( $dom->findvalue('max_position/text()') );
31 9 $self->_set_position_delta( $dom->findvalue('position_delta/text()') );
32 15 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
33  
34 # aliases
35 15 *rank = *kudo_rank;
36  
37 sub as_xml {
38 3 ▶ my $self = shift;
Subroutine as_xml: called CC=1 SCAR=0.0
Pod documented
39 3 my $xml;
40 3 my $w = XML::Writer->new( OUTPUT => \$xml );
41  
42 3 $w->startTag('kudo_score');
43 3 $w->dataElement( 'created_at', $self->created_at );
44 3 $w->dataElement( 'kudo_rank', $self->kudo_rank );
45 3 $w->dataElement( 'position', $self->position );
46 3 $w->dataElement( 'max_position', $self->max_position );
47 3 $w->dataElement( 'position_delta', $self->position_delta );
48 3 $w->endTag;
49  
50 3 return $xml;
51 }
52  
53 15 'end of WWW::Ohloh::API::KudoScore';
54 __END__
55  
56  
57 =head1 NAME
58  
59 WWW::Ohloh::API::KudoScore - an Ohloh kudo score
60  
61 =head1 SYNOPSIS
62  
63 use WWW::Ohloh::API;
64  
65 my $ohloh = WWW::Ohloh::API->new( api_key => $my_api_key );
66 my $account $ohloh->get_account( id => 12933 );
67 my $kudo = $account->kudo_score;
68  
69 print $kudo->rank;
70  
71 =head1 DESCRIPTION
72  
73 W::O::A::KudoScore contains the kudo information associated with an Ohloh
74 account as defined at http://www.ohloh.net/api/reference/kudo_score.
75 To be properly populated, it must be retrieved via
76 the C<kudo_score> method of a L<WWW::Ohloh::API::Account> object.
77  
78 =head1 METHODS
79  
80 =head2 API Data Accessors
81  
82 =head3 created_at
83  
84 Return the time at which this KudoScore was calculated.
85  
86 =head3 rank, kudo_rank
87  
88 Return the KudoRank, which is an integer from 1 to 10.
89  
90 =head3 position
91  
92 Return an integer which orders all participants.
93 The person with `position` equals 1 is the highest-ranked person on Ohloh.
94  
95 =head3 max_position
96  
97 Return the total number of partcipants in the most recent KudoScore calculations. The person whose `position` equals `max_position` is the lowest-ranked person on Ohloh.
98  
99  
100 =head3 position_delta
101  
102 Return the change in this person's position since the previous kudo score calculations. Here, a negative number represents an improvement, since lower positions are better.
103  
104 =head2 Other Methods
105  
106 =head3 as_xml
107  
108 Return the kudo information
109 as an XML string. Note that this is not the exact xml document as returned
110 by the Ohloh server: due to the current XML parsing module used
111 by W::O::A (to wit: L<XML::Simple>), the ordering of the nodes can differ.
112  
113 =head1 SEE ALSO
114  
115 =over
116  
117 =item *
118  
119 L<WWW::Ohloh::API>, L<WWW::Ohloh::API::KudoScore>.
120  
121 =item *
122  
123 Ohloh API reference: http://www.ohloh.net/api/getting_started
124  
125 =item *
126  
127 Ohloh Account API reference: http://www.ohloh.net/api/reference/kudo_score
128  
129 =back
130  
131 =head1 VERSION
132  
133 This document describes WWW::Ohloh::API version 0.3.2
134  
135 =head1 BUGS AND LIMITATIONS
136  
137 WWW::Ohloh::API is very extremely alpha quality. It'll improve,
138 but till then: I<Caveat emptor>.
139  
140 The C<as_xml()> method returns a re-encoding of the account data, which
141 can differ of the original xml document sent by the Ohloh server.
142  
143 Please report any bugs or feature requests to
144 C<bug-www-ohloh-api@rt.cpan.org>, or through the web interface at
145 L<http://rt.cpan.org>.
146  
147  
148 =head1 AUTHOR
149  
150 Yanick Champoux C<< <yanick@cpan.org> >>
151  
152 =head1 LICENCE AND COPYRIGHT
153  
154 Copyright (c) 2008, Yanick Champoux C<< <yanick@cpan.org> >>. All rights reserved.
155  
156 This module is free software; you can redistribute it and/or
157 modify it under the same terms as Perl itself. See L<perlartistic>.
158  
« blib/lib/WWW/Ohloh/API/Enlistment.pm ↑ Summary blib/lib/WWW/Ohloh/API/Enlistments.pm »