| 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
| |||||||||||
| 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__ | ||||||||||