API/Enlistment.pm

filter: Statementstmt 100% 49 / 49 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 10 / 10 Podpod 100% 2 / 2 totaltotal 98.4% 62 / 63 CC 3 SCAR 2.9
CC
3
Cov
98%
_init
2.0
as_xml
2.0
BEGIN
1.0
CRAP 1.3
« API/Role/LoadXML.pm ↑ Summary API/KudoScore.pm »
1 package WWW::Ohloh::API::Enlistment;
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 ▶use WWW::Ohloh::API::Repository;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 30 our $VERSION = '1.0_1';
14  
15 30 my @ohloh_of : Field : Arg(ohloh) : Get(_ohloh);
16 30 my @request_url_of : Field : Arg(request_url) : Get( request_url );
17 30 my @xml_of : Field : Arg(xml);
18  
19 30 my @api_fields = qw/
20 id
21 project_id
22 repository_id
23 /;
24  
25 30 my @id_of : Field : Set(_set_id) : Get(id);
26 30 my @project_id_of : Field : Set(_set_project_id) : Get(project_id);
27 30 my @repository_id_of : Field : Set(_set_repository_id) : Get(repository_id);
28  
29 30 my @repository_of : Field;
30  
31 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
32  
33 1 ▶sub _init : Init {
Subroutine _init: called CC=2 SCAR=7.0
34 1 my $self = shift;
35  
36 1 ▶ my $dom = $xml_of[$$self] or return;
Branch: 1 branch
BranchTrueFalseTotal
my $dom = $xml_of[$$self] or return 1 0 1
37  
38 1 $self->_set_id( $dom->findvalue("id/text()") );
39 1 $self->_set_project_id( $dom->findvalue("project_id/text()") );
40 1 $self->_set_repository_id( $dom->findvalue("repository_id/text()") );
41  
42 1 $repository_of[$$self] = WWW::Ohloh::API::Repository->new(
43 xml => $dom->findnodes('repository[1]'),
44 ohloh => $self->_ohloh,
45 );
46 30 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
47  
48 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
49  
50 1 ▶sub repository {
Subroutine repository: called CC=1 SCAR=0.0
Pod documented
51 1 my $self = shift;
52  
53 1 return $repository_of[$$self];
54 }
55  
56 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
57  
58 1 ▶sub as_xml {
Subroutine as_xml: called CC=2 SCAR=6.9
Pod documented
59 1 my $self = shift;
60 1 my $xml;
61 1 my $w = XML::Writer->new( OUTPUT => \$xml );
62  
63 1 $w->startTag('enlistment');
64  
65 1 for my $attr (@api_fields) {
66 3 $w->dataElement( $attr => $self->$attr );
67 }
68  
69 1 $xml .= $self->repository->as_xml;
70  
71 1 $w->endTag;
72  
73 1 return $xml;
74 }
75  
76 30 'end of WWW::Ohloh::API::Enlistment';
77  
78 __END__
« API/Role/LoadXML.pm ↑ Summary API/KudoScore.pm »