File Coverage

blib/lib/WWW/Ohloh/API/ActivityFacts.pm
Criterion Covered Total %
statement 43 48 89.5
branch n/a
condition n/a
subroutine 13 14 92.8
pod 2 4 50.0
total 58 66 87.8


line stmt bran cond sub pod time code
1             package WWW::Ohloh::API::ActivityFacts;
2             our $AUTHORITY = 'cpan:YANICK';
3              
4 29     29   221998 use strict;
  29         62  
  29         1122  
5 29     29   141 use warnings;
  29         48  
  29         1386  
6              
7 29     29   152 use Carp;
  29         55  
  29         1786  
8 29     29   1134 use Object::InsideOut;
  29         73556  
  29         194  
9 29     29   3913 use XML::LibXML;
  29         53783  
  29         246  
10 29     29   5967 use Readonly;
  29         5899  
  29         1775  
11 29     29   914 use List::MoreUtils qw/ any /;
  29         20913  
  29         331  
12 29     29   24880 use WWW::Ohloh::API::ActivityFact;
  29         68  
  29         207  
13              
14             our $VERSION = '1.0_1';
15              
16             my @ohloh_of : Field : Arg(ohloh);
17             my @project_of : Field : Arg(project);
18             my @analysis_of : Field : Arg(analysis);
19             my @facts_of : Field;
20              
21             #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
22              
23             sub _init : Init {
24 0     0   0 my $self = shift;
25              
26 0         0 my ( $url, $xml ) =
27             $ohloh_of[$$self]
28             ->_query_server( "projects/$project_of[ $$self ]/analyses/"
29             . "$analysis_of[ $$self ]/activity_facts.xml" );
30              
31             $facts_of[$$self] =
32 0         0 [ map { WWW::Ohloh::API::ActivityFact->new( xml => $_ ) }
  0         0  
33             $xml->findnodes('activity_fact') ];
34              
35 0         0 return;
36 29     29   9120 }
  29         76  
  29         217  
37              
38             #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
39              
40             sub as_xml {
41 1     1 1 6607 my $self = shift;
42 1         2 my $xml;
43 1         11 my $w = XML::Writer->new( OUTPUT => \$xml );
44              
45 1         186 $w->startTag('activity_facts');
46              
47 1         113 $xml .= $_->as_xml for @{ $facts_of[$$self] };
  1         7  
48              
49 1         4 $w->endTag;
50              
51 1         122 return $xml;
52             }
53              
54             #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
55              
56             sub all {
57 1     1 1 53 my $self = shift;
58              
59 1         1 return @{ $facts_of[$$self] };
  1         6  
60             }
61              
62             #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
63              
64             sub latest {
65 1     1 0 1065 my $self = shift;
66 1         4 return $facts_of[$$self][-1];
67             }
68              
69             #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
70              
71             sub total {
72 1     1 0 831 my $self = shift;
73 1         18 return scalar @{ $facts_of[$$self] };
  1         5  
74             }
75              
76             'end of WWW::Ohloh::API::ActivityFacts';
77              
78             __END__