File Coverage

blib/lib/WWW/Ohloh/API/SizeFact.pm
Criterion Covered Total %
statement 37 42 88.1
branch 0 2 0.0
condition n/a
subroutine 11 12 91.6
pod 2 2 100.0
total 50 58 86.2


line stmt bran cond sub pod time code
1             package WWW::Ohloh::API::SizeFact;
2             our $AUTHORITY = 'cpan:YANICK';
3              
4 29     29   242975 use strict;
  29         61  
  29         1303  
5 29     29   158 use warnings;
  29         69  
  29         1596  
6              
7 29     29   179 use Carp;
  29         58  
  29         2696  
8 29     29   1166 use Object::InsideOut;
  29         71185  
  29         604  
9 29     29   3777 use XML::LibXML;
  29         55238  
  29         659  
10 29     29   5995 use WWW::Ohloh::API::KudoScore;
  29         77  
  29         241  
11              
12             our $VERSION = '1.0_1';
13              
14             my @ohloh_of : Field : Arg(ohloh) : Get(_ohloh);
15             my @request_url_of : Field : Arg(request_url) : Get( request_url );
16             my @xml_of : Field : Arg(xml);
17              
18             my @api_fields = qw/
19             month
20             code
21             comments
22             blanks
23             comment_ratio
24             commits
25             man_months
26             /;
27              
28             my @month_of : Field : Set(_set_month) : Get(month);
29             my @code_of : Field : Set(_set_code) : Get(code);
30             my @comments_of : Field : Set(_set_comments) : Get(comments);
31             my @blanks_of : Field : Set(_set_blanks) : Get(blanks);
32             my @comment_ratio_of : Field : Set(_set_comment_ratio) : Get(comment_ratio);
33             my @commits_of : Field : Set(_set_commits) : Get(commits);
34             my @man_months_of : Field : Set(_set_man_months) : Get(man_months);
35              
36             #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
37              
38             sub _init : Init {
39 0     0   0 my $self = shift;
40              
41 0 0       0 my $dom = $xml_of[$$self] or return;
42              
43 0         0 for my $f (@api_fields) {
44 0         0 my $m = "_set_$f";
45              
46 0         0 $self->$m( $dom->findvalue("$f/text()") );
47             }
48              
49 29     29   10840 }
  29         94  
  29         315  
50              
51             #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
52              
53             sub _overload_array_ref : Arrayify {
54 1     1   916 my $self = shift;
55              
56 1         5 return [ $self->stats ];
57 29     29   8648 }
  29         67  
  29         139  
58              
59             #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
60              
61             sub stats {
62 2     2 1 7746 my $self = shift;
63              
64 2         7 return map { $self->$_ } qw/
  14         411  
65             month
66             commits
67             code
68             blanks
69             comments
70             comment_ratio
71             man_months
72             /;
73             }
74              
75             #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
76              
77             sub as_xml {
78 1     1 1 823 my $self = shift;
79 1         3 my $xml;
80 1         12 my $w = XML::Writer->new( OUTPUT => \$xml );
81              
82 1         318 $w->startTag('size_fact');
83              
84 1         126 for my $attr (@api_fields) {
85 7         1052 $w->dataElement( $attr => $self->$attr );
86             }
87              
88 1         129 $w->endTag;
89              
90 1         183 return $xml;
91             }
92              
93             'end of WWW::Ohloh::API::SizeFact';
94              
95             __END__