| 1 | package WWW::Ohloh::API::Factoid; | ||||||||||
| 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 | |||||||||||
| 11 | 29 | our $VERSION = '1.0_1'; | |||||||||
| 12 | |||||||||||
| 13 | 29 | my @request_url_of : Field : Arg(request_url) : Get( request_url ); | |||||||||
| 14 | 29 | my @xml_of : Field : Arg(xml); | |||||||||
| 15 | |||||||||||
| 16 | 29 | my @api_fields = qw/ | |||||||||
| 17 | id | ||||||||||
| 18 | analysis_id | ||||||||||
| 19 | type | ||||||||||
| 20 | description | ||||||||||
| 21 | severity | ||||||||||
| 22 | license_id | ||||||||||
| 23 | /; | ||||||||||
| 24 | |||||||||||
| 25 | 29 | my @id_of : Field : Set(_set_id) : Get(id); | |||||||||
| 26 | 29 | my @analysis_id_of : Field : Set(_set_analysis_id) : Get(analysis_id); | |||||||||
| 27 | 29 | my @type_of : Field : Set(_set_type) : Get(type); | |||||||||
| 28 | 29 | my @description_of : Field : Set(_set_description) : Get(description); | |||||||||
| 29 | 29 | my @severity_of : Field : Set(_set_severity) : Get(severity); | |||||||||
| 30 | 29 | my @license_id_of : Field : Set(_set_license_id) : Get(license_id); | |||||||||
| 31 | |||||||||||
| 32 | 29 | my @ohloh_of : Field : Arg(ohloh); | |||||||||
| 33 | |||||||||||
| 34 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||||||||||
| 35 | |||||||||||
| 36 | 8 | ▶ | sub _init : Init { | ||||||||
|
Subroutine
_init: called CC=2 SCAR=6.9
| |||||||||||
| 37 | 8 | my $self = shift; | |||||||||
| 38 | |||||||||||
| 39 | 8 | ▶ | my $dom = $xml_of[$$self] or return; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 40 | |||||||||||
| 41 | 8 | $self->_set_id( $dom->findvalue("id/text()") ); | |||||||||
| 42 | 8 | $self->_set_analysis_id( $dom->findvalue("analysis_id/text()") ); | |||||||||
| 43 | 8 | $self->_set_type( $dom->findvalue("type/text()") ); | |||||||||
| 44 | 8 | $self->_set_description( $dom->findvalue("description/text()") ); | |||||||||
| 45 | 8 | $self->_set_severity( $dom->findvalue("severity/text()") ); | |||||||||
| 46 | 8 | $self->_set_license_id( $dom->findvalue("license_id/text()") ); | |||||||||
| 47 | |||||||||||
| 48 | 8 | return; | |||||||||
| 49 | 29 | ▶ | } | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 50 | |||||||||||
| 51 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||||||||||
| 52 | |||||||||||
| 53 | 1 | ▶ | sub as_xml { | ||||||||
|
Subroutine
as_xml: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 54 | 1 | my $self = shift; | |||||||||
| 55 | 1 | my $xml; | |||||||||
| 56 | 1 | my $w = XML::Writer->new( OUTPUT => \$xml ); | |||||||||
| 57 | |||||||||||
| 58 | 1 | $w->startTag('factoid'); | |||||||||
| 59 | |||||||||||
| 60 | 1 | for my $e (@api_fields) { | |||||||||
| 61 | 6 | $w->dataElement( $e => $self->$e ); | |||||||||
| 62 | } | ||||||||||
| 63 | |||||||||||
| 64 | 1 | $w->endTag; | |||||||||
| 65 | |||||||||||
| 66 | 1 | return $xml; | |||||||||
| 67 | } | ||||||||||
| 68 | |||||||||||
| 69 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||||||||||
| 70 | |||||||||||
| 71 | 29 | 'end of WWW::Ohloh::API::Factoid'; | |||||||||
| 72 | |||||||||||
| 73 | __END__ | ||||||||||