File Coverage

blib/lib/WWW/Ohloh/API/Enlistment.pm
Criterion Covered Total %
statement 32 38 84.2
branch 0 2 0.0
condition n/a
subroutine 9 10 90.0
pod 2 2 100.0
total 43 52 82.6


line stmt bran cond sub pod time code
1             package WWW::Ohloh::API::Enlistment;
2             our $AUTHORITY = 'cpan:YANICK';
3              
4 30     30   264330 use strict;
  30         66  
  30         1164  
5 30     30   144 use warnings;
  30         57  
  30         1544  
6              
7 30     30   232 use Carp;
  30         58  
  30         2221  
8 30     30   1139 use Object::InsideOut;
  30         72073  
  30         398  
9 30     30   3975 use XML::LibXML;
  30         53512  
  30         217  
10              
11 30     30   21929 use WWW::Ohloh::API::Repository;
  30         128  
  30         1553  
12              
13             our $VERSION = '1.0_1';
14              
15             my @ohloh_of : Field : Arg(ohloh) : Get(_ohloh);
16             my @request_url_of : Field : Arg(request_url) : Get( request_url );
17             my @xml_of : Field : Arg(xml);
18              
19             my @api_fields = qw/
20             id
21             project_id
22             repository_id
23             /;
24              
25             my @id_of : Field : Set(_set_id) : Get(id);
26             my @project_id_of : Field : Set(_set_project_id) : Get(project_id);
27             my @repository_id_of : Field : Set(_set_repository_id) : Get(repository_id);
28              
29             my @repository_of : Field;
30              
31             #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
32              
33             sub _init : Init {
34 0     0   0 my $self = shift;
35              
36 0 0       0 my $dom = $xml_of[$$self] or return;
37              
38 0         0 $self->_set_id( $dom->findvalue("id/text()") );
39 0         0 $self->_set_project_id( $dom->findvalue("project_id/text()") );
40 0         0 $self->_set_repository_id( $dom->findvalue("repository_id/text()") );
41              
42 0         0 $repository_of[$$self] = WWW::Ohloh::API::Repository->new(
43             xml => $dom->findnodes('repository[1]'),
44             ohloh => $self->_ohloh,
45             );
46 30     30   10788 }
  30         1090  
  30         1592  
47              
48             #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
49              
50             sub repository {
51 1     1 1 1 my $self = shift;
52              
53 1         4 return $repository_of[$$self];
54             }
55              
56             #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
57              
58             sub as_xml {
59 1     1 1 2525 my $self = shift;
60 1         3 my $xml;
61 1         12 my $w = XML::Writer->new( OUTPUT => \$xml );
62              
63 1         283 $w->startTag('enlistment');
64              
65 1         91 for my $attr (@api_fields) {
66 3         219 $w->dataElement( $attr => $self->$attr );
67             }
68              
69 1         75 $xml .= $self->repository->as_xml;
70              
71 1         4 $w->endTag;
72              
73 1         73 return $xml;
74             }
75              
76             'end of WWW::Ohloh::API::Enlistment';
77              
78             __END__