File Coverage

blib/lib/WWW/Ohloh/API/Factoid.pm
Criterion Covered Total %
statement 26 35 74.2
branch 0 2 0.0
condition n/a
subroutine 7 8 87.5
pod 1 1 100.0
total 34 46 73.9


line stmt bran cond sub pod time code
1             package WWW::Ohloh::API::Factoid;
2             our $AUTHORITY = 'cpan:YANICK';
3              
4 29     29   228957 use strict;
  29         59  
  29         1125  
5 29     29   144 use warnings;
  29         78  
  29         1487  
6              
7 29     29   149 use Carp;
  29         51  
  29         1941  
8 29     29   851 use Object::InsideOut;
  29         53303  
  29         218  
9 29     29   3536 use XML::LibXML;
  29         55885  
  29         229  
10              
11             our $VERSION = '1.0_1';
12              
13             my @request_url_of : Field : Arg(request_url) : Get( request_url );
14             my @xml_of : Field : Arg(xml);
15              
16             my @api_fields = qw/
17             id
18             analysis_id
19             type
20             description
21             severity
22             license_id
23             /;
24              
25             my @id_of : Field : Set(_set_id) : Get(id);
26             my @analysis_id_of : Field : Set(_set_analysis_id) : Get(analysis_id);
27             my @type_of : Field : Set(_set_type) : Get(type);
28             my @description_of : Field : Set(_set_description) : Get(description);
29             my @severity_of : Field : Set(_set_severity) : Get(severity);
30             my @license_id_of : Field : Set(_set_license_id) : Get(license_id);
31              
32             my @ohloh_of : Field : Arg(ohloh);
33              
34             #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
35              
36             sub _init : Init {
37 0     0   0 my $self = shift;
38              
39 0 0       0 my $dom = $xml_of[$$self] or return;
40              
41 0         0 $self->_set_id( $dom->findvalue("id/text()") );
42 0         0 $self->_set_analysis_id( $dom->findvalue("analysis_id/text()") );
43 0         0 $self->_set_type( $dom->findvalue("type/text()") );
44 0         0 $self->_set_description( $dom->findvalue("description/text()") );
45 0         0 $self->_set_severity( $dom->findvalue("severity/text()") );
46 0         0 $self->_set_license_id( $dom->findvalue("license_id/text()") );
47              
48 0         0 return;
49 29     29   13356 }
  29         65  
  29         265  
50              
51             #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
52              
53             sub as_xml {
54 1     1 1 6166 my $self = shift;
55 1         2 my $xml;
56 1         14 my $w = XML::Writer->new( OUTPUT => \$xml );
57              
58 1         278 $w->startTag('factoid');
59              
60 1         117 for my $e (@api_fields) {
61 6         596 $w->dataElement( $e => $self->$e );
62             }
63              
64 1         173 $w->endTag;
65              
66 1         182 return $xml;
67             }
68              
69             #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
70              
71             'end of WWW::Ohloh::API::Factoid';
72              
73             __END__