| 1 | package WWW::Ohloh::API::ActivityFacts; | ||
| 2 | 29 | our $AUTHORITY = 'cpan:YANICK'; | |
| 3 | |||
| 4 | 29 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 29 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | |||
| 7 | 29 | ▶ | use Carp; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | 29 | ▶ | use Object::InsideOut; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | 29 | ▶ | use XML::LibXML; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 10 | 29 | ▶ | use Readonly; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 11 | 29 | ▶ | use List::MoreUtils qw/ any /; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 12 | 29 | ▶ | use WWW::Ohloh::API::ActivityFact; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 13 | |||
| 14 | 29 | our $VERSION = '1.0_1'; | |
| 15 | |||
| 16 | 29 | my @ohloh_of : Field : Arg(ohloh); | |
| 17 | 29 | my @project_of : Field : Arg(project); | |
| 18 | 29 | my @analysis_of : Field : Arg(analysis); | |
| 19 | 29 | my @facts_of : Field; | |
| 20 | |||
| 21 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| 22 | |||
| 23 | 1 | ▶ | sub _init : Init { |
|
Subroutine
_init: called CC=1 SCAR=0.0
| |||
| 24 | 1 | my $self = shift; | |
| 25 | |||
| 26 | 1 | 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 | 1 | [ map { WWW::Ohloh::API::ActivityFact->new( xml => $_ ) } | |
| 33 | $xml->findnodes('activity_fact') ]; | ||
| 34 | |||
| 35 | 1 | return; | |
| 36 | 29 | ▶ | } |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 37 | |||
| 38 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| 39 | |||
| 40 | 1 | ▶ | sub as_xml { |
|
Subroutine
as_xml: called CC=2 SCAR=6.9
Pod
documented
| |||
| 41 | 1 | my $self = shift; | |
| 42 | 1 | my $xml; | |
| 43 | 1 | my $w = XML::Writer->new( OUTPUT => \$xml ); | |
| 44 | |||
| 45 | 1 | $w->startTag('activity_facts'); | |
| 46 | |||
| 47 | 1 | $xml .= $_->as_xml for @{ $facts_of[$$self] }; | |
| 48 | |||
| 49 | 1 | $w->endTag; | |
| 50 | |||
| 51 | 1 | return $xml; | |
| 52 | } | ||
| 53 | |||
| 54 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| 55 | |||
| 56 | 1 | ▶ | sub all { |
|
Subroutine
all: called CC=1 SCAR=0.0
Pod
documented
| |||
| 57 | 1 | my $self = shift; | |
| 58 | |||
| 59 | 1 | return @{ $facts_of[$$self] }; | |
| 60 | } | ||
| 61 | |||
| 62 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| 63 | |||
| 64 | 1 | ▶ | sub latest { |
|
Subroutine
latest: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 65 | 1 | my $self = shift; | |
| 66 | 1 | return $facts_of[$$self][-1]; | |
| 67 | } | ||
| 68 | |||
| 69 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| 70 | |||
| 71 | 1 | ▶ | sub total { |
|
Subroutine
total: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 72 | 1 | my $self = shift; | |
| 73 | 1 | return scalar @{ $facts_of[$$self] }; | |
| 74 | } | ||
| 75 | |||
| 76 | 29 | 'end of WWW::Ohloh::API::ActivityFacts'; | |
| 77 | |||
| 78 | __END__ | ||