API/ContributorFact.pm

filter: Statementstmt 100% 70 / 70 Branchbran 50.0% 4 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod 50.0% 1 / 2 totaltotal 94.3% 84 / 89 CC 6 SCAR 7.1
CC
6
Cov
95%
account
3.1
as_xml
3.0
_init
2.0
CRAP 2.0
« API/Kudos.pm ↑ Summary API/Message.pm »
1 package WWW::Ohloh::API::ContributorFact;
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  
11 30 our $VERSION = '1.0_1';
12  
13 30 my @ohloh_of : Field : Arg(ohloh) : Get(_ohloh);
14 30 my @request_url_of : Field : Arg(request_url) : Get( request_url );
15 30 my @xml_of : Field : Arg(xml);
16  
17 30 my @api_fields = qw/
18 analysis_id
19 contributor_id
20 contributor_name
21 account_id
22 account_name
23 primary_language_id
24 primary_language_nice_name
25 comment_ratio
26 first_commit_time
27 last_commit_time
28 man_months
29 commits
30 median_commits
31 contributor_language_facts
32 /;
33  
34 30 my @analysis_id_of : Field : Set(_set_analysis_id) : Get(analysis_id);
35 30 my @contributor_id_of : Field : Set(_set_contributor_id) :
36 Get(contributor_id);
37 30 my @contributor_name_of : Field : Set(_set_contributor_name) :
38 Get(contributor_name);
39 30 my @account_id_of : Field : Set(_set_account_id) : Get(account_id);
40 30 my @account_name_of : Field : Set(_set_account_name) : Get(account_name);
41 30 my @primary_language_id_of : Field : Set(_set_primary_language_id) :
42 Get(primary_language_id);
43 30 my @primary_language_nice_name_of : Field :
44 Set(_set_primary_language_nice_name) : Get(primary_language_nice_name);
45 30 my @comment_ratio_of : Field : Set(_set_comment_ratio) : Get(comment_ratio);
46 30 my @first_commit_time_of : Field : Set(_set_first_commit_time) :
47 Get(first_commit_time);
48 30 my @last_commit_time_of : Field : Set(_set_last_commit_time) :
49 Get(last_commit_time);
50 30 my @man_months_of : Field : Set(_set_man_months) : Get(man_months);
51 30 my @commits_of : Field : Set(_set_commits) : Get(commits);
52 30 my @median_commits_of : Field : Set(_set_median_commits) :
53 Get(median_commits);
54 30 my @contributor_language_facts_of : Field :
55 Set(_set_contributor_language_facts) : Get(contributor_language_facts);
56  
57 30 my @account_of : Field;
58  
59 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
60  
61 1 ▶sub _init : Init {
Subroutine _init: called CC=2 SCAR=6.9
62 1 my $self = shift;
63  
64 1 ▶ my $dom = $xml_of[$$self] or return;
Branch: 1 branch
BranchTrueFalseTotal
my $dom = $xml_of[$$self] or return 1 0 1
65  
66 1 $self->_set_analysis_id( $dom->findvalue("analysis_id/text()") );
67 1 $self->_set_contributor_id( $dom->findvalue("contributor_id/text()") );
68 1 $self->_set_contributor_name(
69 $dom->findvalue("contributor_name/text()") );
70 1 $self->_set_account_id( $dom->findvalue("account_id/text()") );
71 1 $self->_set_account_name( $dom->findvalue("account_name/text()") );
72 1 $self->_set_primary_language_id(
73 $dom->findvalue("primary_language_id/text()") );
74 1 $self->_set_primary_language_nice_name(
75 $dom->findvalue("primary_language_nice_name/text()") );
76 1 $self->_set_comment_ratio( $dom->findvalue("comment_ratio/text()") );
77 1 $self->_set_first_commit_time(
78 $dom->findvalue("first_commit_time/text()") );
79 1 $self->_set_last_commit_time(
80 $dom->findvalue("last_commit_time/text()") );
81 1 $self->_set_man_months( $dom->findvalue("man_months/text()") );
82 1 $self->_set_commits( $dom->findvalue("commits/text()") );
83 1 $self->_set_median_commits( $dom->findvalue("median_commits/text()") );
84 1 $self->_set_contributor_language_facts(
85 $dom->findvalue("contributor_language_facts/text()") );
86  
87 30 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
88  
89 1 ▶sub as_xml {
Subroutine as_xml: called CC=3 SCAR=11.0
Pod documented
90 1 my $self = shift;
91 1 my $xml;
92 1 my $w = XML::Writer->new( OUTPUT => \$xml );
93  
94 1 $w->startTag('contributor_fact');
95  
96 1 for my $attr (@api_fields) {
97 14 $w->dataElement( $attr => $self->$attr );
98 }
99  
100 1 ▶ if ( my $a = $account_of[$$self] ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $a = $account_of[$$self]) 1 0 1
101 1 $xml .= $a->as_xml;
102 }
103  
104 1 $w->endTag;
105  
106 1 return $xml;
107 }
108  
109 1 ▶sub account {
Subroutine account: called CC=3 SCAR=11.4
Pod undocumented
110 1 my $self = shift;
111  
112 1 ▶ return $account_of[$$self] if $account_of[$$self];
Branch: 1 branch
BranchTrueFalseTotal
if $account_of[$$self] 0 1 1
113  
114 1 ▶ my $id = $self->account_id or return;
Branch: 1 branch
BranchTrueFalseTotal
my $id = $self->account_id or return 1 0 1
115  
116 1 return $account_of[$$self] = $self->_ohloh->fetch_account($id);
117 }
118  
119 30 'end of WWW::Ohloh::API::ContributorFact';
120  
121 __END__
« API/Kudos.pm ↑ Summary API/Message.pm »