File Coverage

blib/lib/WWW/Ohloh/API/KudoScore.pm
Criterion Covered Total %
statement 32 39 82.0
branch 0 2 0.0
condition n/a
subroutine 8 9 88.8
pod 1 1 100.0
total 41 51 80.3


line stmt bran cond sub pod time code
1             package WWW::Ohloh::API::KudoScore;
2             our $AUTHORITY = 'cpan:YANICK';
3              
4 33     33   217309 use strict;
  33         113  
  33         1315  
5 33     33   175 use warnings;
  33         58  
  33         1642  
6              
7 33     33   186 use Carp;
  33         61  
  33         2387  
8 33     33   938 use Object::InsideOut;
  33         40800  
  33         274  
9 33     33   3760 use XML::LibXML;
  33         33024  
  33         244  
10 33     33   28041 use XML::Writer;
  33         290089  
  33         7502  
11              
12             our $VERSION = '1.0_1';
13              
14             my @xml_of : Field : Arg(xml);
15              
16             my @creation_time_of : Field : Get(created_at) : Set(_set_created_at);
17             my @kudo_rank_of : Field : Get(kudo_rank) : Set(_set_kudo_rank);
18             my @position_of : Field : Get(position) : Set(_set_position);
19             my @max_position_of : Field : Get(max_position) : Set(_set_max_position);
20             my @position_delta_of : Field : Get(position_delta) :
21             Set(_set_position_delta);
22              
23             sub _init : Init {
24 0     0   0 my $self = shift;
25              
26 0 0       0 my $dom = $xml_of[$$self] or return;
27              
28 0         0 $self->_set_created_at( $dom->findvalue('created_at/text()') );
29 0         0 $self->_set_kudo_rank( $dom->findvalue('kudo_rank/text()') );
30 0         0 $self->_set_position( $dom->findvalue('position/text()') );
31 0         0 $self->_set_max_position( $dom->findvalue('max_position/text()') );
32 0         0 $self->_set_position_delta( $dom->findvalue('position_delta/text()') );
33 33     33   329 }
  33         83  
  33         302  
34              
35             # aliases
36             *rank = *kudo_rank;
37              
38             sub as_xml {
39 3     3 1 23490 my $self = shift;
40 3         6 my $xml;
41 3         15 my $w = XML::Writer->new( OUTPUT => \$xml );
42              
43 3         693 $w->startTag('kudo_score');
44 3         291 $w->dataElement( 'created_at', $self->created_at );
45 3         442 $w->dataElement( 'kudo_rank', $self->kudo_rank );
46 3         497 $w->dataElement( 'position', $self->position );
47 3         453 $w->dataElement( 'max_position', $self->max_position );
48 3         443 $w->dataElement( 'position_delta', $self->position_delta );
49 3         372 $w->endTag;
50              
51 3         427 return $xml;
52             }
53              
54             'end of WWW::Ohloh::API::KudoScore';
55              
56             __END__