File Coverage

blib/lib/WWW/Ohloh/API/ContributorLanguageFact.pm
Criterion Covered Total %
statement 26 37 70.2
branch 0 2 0.0
condition n/a
subroutine 7 8 87.5
pod 1 1 100.0
total 34 48 70.8


line stmt bran cond sub pod time code
1             package WWW::Ohloh::API::ContributorLanguageFact;
2             our $AUTHORITY = 'cpan:YANICK';
3              
4 29     29   269016 use strict;
  29         66  
  29         1170  
5 29     29   156 use warnings;
  29         56  
  29         1514  
6              
7 29     29   192 use Carp;
  29         80  
  29         2213  
8 29     29   875 use Object::InsideOut;
  29         57521  
  29         287  
9 29     29   3946 use XML::LibXML;
  29         49847  
  29         225  
10              
11             our $VERSION = '1.0_1';
12              
13             my @ohloh_of : Field : Arg(ohloh) : Get(_ohloh);
14             my @request_url_of : Field : Arg(request_url) : Get( request_url );
15             my @xml_of : Field : Arg(xml);
16              
17             my @api_fields = qw/
18             analysis_id
19             contributor_id
20             contributor_name
21             language_id
22             language_nice_name
23             comment_ratio
24             man_months
25             commits
26             median_commits
27             /;
28              
29             my @analysis_id_of : Field : Set(_set_analysis_id) : Get(analysis_id);
30             my @contributor_id_of : Field : Set(_set_contributor_id) :
31             Get(contributor_id);
32             my @contributor_name_of : Field : Set(_set_contributor_name) :
33             Get(contributor_name);
34             my @language_id_of : Field : Set(_set_language_id) : Get(language_id);
35             my @language_nice_name_of : Field : Set(_set_language_nice_name) :
36             Get(language_nice_name);
37             my @comment_ratio_of : Field : Set(_set_comment_ratio) : Get(comment_ratio);
38             my @man_months_of : Field : Set(_set_man_months) : Get(man_months);
39             my @commits_of : Field : Set(_set_commits) : Get(commits);
40             my @median_commits_of : Field : Set(_set_median_commits) :
41             Get(median_commits);
42              
43             #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
44              
45             sub _init : Init {
46 0     0   0 my $self = shift;
47              
48 0 0       0 my $dom = $xml_of[$$self] or return;
49              
50 0         0 $self->_set_analysis_id( $dom->findvalue("analysis_id/text()") );
51 0         0 $self->_set_contributor_id( $dom->findvalue("contributor_id/text()") );
52 0         0 $self->_set_contributor_name(
53             $dom->findvalue("contributor_name/text()") );
54 0         0 $self->_set_language_id( $dom->findvalue("language_id/text()") );
55 0         0 $self->_set_language_nice_name(
56             $dom->findvalue("language_nice_name/text()") );
57 0         0 $self->_set_comment_ratio( $dom->findvalue("comment_ratio/text()") );
58 0         0 $self->_set_man_months( $dom->findvalue("man_months/text()") );
59 0         0 $self->_set_commits( $dom->findvalue("commits/text()") );
60 0         0 $self->_set_median_commits( $dom->findvalue("median_commits/text()") );
61              
62 29     29   17154 }
  29         61  
  29         229  
63              
64             sub as_xml {
65 1     1 1 11355 my $self = shift;
66 1         3 my $xml;
67 1         15 my $w = XML::Writer->new( OUTPUT => \$xml );
68              
69 1         318 $w->startTag('contributor_language_fact');
70              
71 1         205 for my $attr (@api_fields) {
72 9         1618 $w->dataElement( $attr => $self->$attr );
73             }
74              
75 1         128 $w->endTag;
76              
77 1         253 return $xml;
78             }
79              
80             'end of WWW::Ohloh::API::ContributorLanguageFact';
81              
82             __END__