API/Kudo.pm

filter: Statementstmt 98.4% 63 / 64 Branchbran 62.5% 5 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 12 / 12 Podpod 25.0% 1 / 4 totaltotal 92.0% 81 / 88 CC 6 SCAR 5.5
CC
6
Cov
94%
as_xml
3.0
receiver
2.1
recipient_type
2.1
CRAP 1.7
« API/Account.pm ↑ Summary API/Role/Fetchable.pm »
1 package WWW::Ohloh::API::Kudo;
2 30 our $AUTHORITY = 'cpan:YANICK';
3  
4 30 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 30 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 30 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 30 ▶use Object::InsideOut;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 30 ▶use XML::LibXML;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 30 ▶use WWW::Ohloh::API::KudoScore;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 30 our $VERSION = '1.0_1';
13  
14 30 my @api_fields = qw/
15 created_at
16 sender_account_id
17 sender_account_name
18 receiver_account_name
19 receiver_account_id
20 project_id
21 project_name
22 contributor_id
23 contributor_name
24 /;
25  
26 30 my @created_at_of : Field : Set(_set_created_at) : Get(created_at);
27 30 my @sender_account_id_of : Field : Set(_set_sender_account_id) :
28 Get(sender_account_id);
29 30 my @sender_account_name_of : Field : Set(_set_sender_account_name) :
30 Get(sender_account_name);
31 30 my @receiver_account_name_of : Field : Set(_set_receiver_account_name) :
32 Get(receiver_account_name);
33 30 my @receiver_account_id_of : Field : Set(_set_receiver_account_id) :
34 Get(receiver_account_id);
35 30 my @project_id_of : Field : Set(_set_project_id) : Get(project_id);
36 30 my @project_name_of : Field : Set(_set_project_name) : Get(project_name);
37 30 my @contributor_id_of : Field : Set(_set_contributor_id) :
38 Get(contributor_id);
39 30 my @contributor_name_of : Field : Set(_set_contributor_name) :
40 Get(contributor_name);
41  
42 30 my @request_url_of : Field : Arg(request_url) : Get( request_url );
43 30 my @xml_of : Field : Arg(xml);
44 30 my @ohloh_of : Field : Arg(ohloh) : Get(_ohloh);
45  
46 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
47  
48 70 ▶sub _init : Init {
Subroutine _init: called CC=2 SCAR=6.9
49 70 my $self = shift;
50  
51 70 ▶ my $dom = $xml_of[$$self] or return;
Branch: 1 branch
BranchTrueFalseTotal
my $dom = $xml_of[$$self] or return 70 0 70
52  
53 70 $self->_set_created_at( $dom->findvalue("created_at/text()") );
54 70 $self->_set_sender_account_id(
55 $dom->findvalue("sender_account_id/text()") );
56 70 $self->_set_sender_account_name(
57 $dom->findvalue("sender_account_name/text()") );
58 70 $self->_set_receiver_account_name(
59 $dom->findvalue("receiver_account_name/text()") );
60 70 $self->_set_receiver_account_id(
61 $dom->findvalue("receiver_account_id/text()") );
62 70 $self->_set_project_id( $dom->findvalue("project_id/text()") );
63 70 $self->_set_project_name( $dom->findvalue("project_name/text()") );
64 70 $self->_set_contributor_id( $dom->findvalue("contributor_id/text()") );
65 70 $self->_set_contributor_name(
66 $dom->findvalue("contributor_name/text()") );
67 30 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
68  
69 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
70  
71 1 ▶sub recipient_type {
Subroutine recipient_type: called CC=2 SCAR=7.2
Pod undocumented
72 1 my $self = shift;
73  
74 1 ▶ return $self->receiver_account_id ? 'account' : 'contributor';
Branch: 1 branch
BranchTrueFalseTotal
$self->receiver_account_id ? : 1 0 1
75 }
76  
77 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
78  
79 1 ▶sub sender {
Subroutine sender: called CC=1 SCAR=0.0
Pod undocumented
80 1 my $self = shift;
81  
82 1 return $self->_ohloh->fetch_account( $self->sender_account_id );
83 }
84  
85 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
86  
87 1 ▶sub receiver {
Subroutine receiver: called CC=2 SCAR=7.6
Pod undocumented
88 1 my $self = shift;
89  
90 1 ▶ if ( my $id = $self->receiver_account_id ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $id = $self->receiver_account_id) 1 0 1
91 1 return $self->_ohloh->fetch_account($id);
92 }
93  
94 0 return;
95 }
96  
97 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
98  
99 36 ▶sub as_xml {
Subroutine as_xml: called CC=3 SCAR=11.0
Pod documented
100 36 my $self = shift;
101 36 my $xml;
102 36 my $w = XML::Writer->new( OUTPUT => \$xml );
103  
104 36 $w->startTag('kudo');
105 36 for my $e (@api_fields) {
106 324 ▶ $w->dataElement( $e => $self->$e ) if $self->$e;
Branch: 1 branch
BranchTrueFalseTotal
if $self->$e 190 134 324
107 }
108  
109 36 $w->endTag;
110  
111 36 return $xml;
112 }
113  
114 30 'end of WWW::Ohloh::API::Kudo';
115  
116 __END__
« API/Account.pm ↑ Summary API/Role/Fetchable.pm »