File Coverage

blib/lib/WWW/Ohloh/API/Message/Tag.pm
Criterion Covered Total %
statement 26 33 78.7
branch 1 2 50.0
condition n/a
subroutine 8 11 72.7
pod 1 4 25.0
total 36 50 72.0


line stmt bran cond sub pod time code
1             package WWW::Ohloh::API::Message::Tag;
2             our $AUTHORITY = 'cpan:YANICK';
3              
4 6     6   223784 use strict;
  6         12  
  6         225  
5 6     6   27 use warnings;
  6         12  
  6         339  
6              
7 6         43 use Object::InsideOut qw/
8             WWW::Ohloh::API::Role::Fetchable
9             WWW::Ohloh::API::Role::LoadXML
10 6     6   731 /;
  6         64295  
11              
12 6     6   1209 use Carp;
  6         13  
  6         540  
13 6     6   785 use XML::LibXML;
  6         51878  
  6         50  
14              
15 6     6   2464 use List::MoreUtils qw/ any /;
  6         28524  
  6         49  
16              
17             our $VERSION = '1.0_1';
18              
19             my @type_of : Field : Set(set_type) : Get(type);
20             my @uri_of : Field : Set(set_uri) : Get(uri);
21             my @content_of : Field : Set(set_content) : Get(content);
22              
23             #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
24              
25             sub load_xml {
26 1     1 0 13 my $self = shift;
27 1         3 my $dom = shift;
28              
29 1         36 my $type = $dom->nodeName;
30             die "tag is of type $type, should be 'project' or 'account'"
31 1 50   1   44 unless any { $_ eq $type } qw/ project account /;
  1         9  
32              
33 1         51 $self->set_type($type);
34 1         17 $self->set_uri( $dom->getAttribute('uri') );
35 1         102 $self->set_content( $dom->findvalue('text()') );
36             }
37              
38             #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
39              
40             sub as_xml {
41 0     0 1   my $self = shift;
42 0           my $xml;
43 0           my $w = XML::Writer->new( OUTPUT => \$xml );
44              
45 0           $w->dataElement( $self->type, $self->content, uri => $self->uri );
46              
47 0           return $xml;
48             }
49              
50             #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
51              
52             sub is_project {
53 0     0 0   return $_[0]->type eq 'project';
54             }
55              
56             #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
57              
58             sub is_account {
59 0     0 0   return $_[0]->type eq 'account';
60             }
61              
62             #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
63              
64             'end of WWW::Ohloh::API::Message::Tag';
65              
66             __END__