API/Message.pm

filter: Statementstmt 80.9% 51 / 63 Branchbran 50.0% 2 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 78.5% 11 / 14 Podpod 33.3% 2 / 6 totaltotal 75.8% 66 / 87 CC 5 SCAR 7.0
CC
5
Cov
79%
as_xml
6.0
_init
2.1
tags
2.0
CRAP 2.0
« API/ContributorFact.pm ↑ Summary API/Language.pm »
1 package WWW::Ohloh::API::Message;
2 5 our $AUTHORITY = 'cpan:YANICK';
3  
4 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 5 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 5 ▶use Object::InsideOut;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 5 ▶use XML::LibXML;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 5 ▶use WWW::Ohloh::API::Message::Tag;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 5 our $VERSION = '1.0_1';
14  
15 5 my @request_url_of : Field : Arg(request_url) : Get( request_url );
16 5 my @ohloh_of : Field : Arg(ohloh);
17  
18 5 my @api_fields = qw/ id account avatar created_at body /;
19  
20 5 my @id_of : Field : Set(_set_id) : Get(id);
21 5 my @account_of : Field : Set(_set_account) : Get(account);
22 5 my @avatar_of : Field : Set(_set_avatar) : Get(avatar);
23 5 my @creation_time_of : Field : Set(_set_creation_time) : Get(creation_time);
24 5 my @body_of : Field : Set(_set_body) : Get(body);
25 5 my @tags_of : Field;
26  
27 5 my %init_args : InitArgs = ( 'xml' => '', );
28  
29 4 ▶sub _init : Init {
Subroutine _init: called CC=2 SCAR=7.2
30 4 my ( $self, $args ) = @_;
31  
32 4 ▶ $self->load_xml( $args->{xml} ) if $args->{xml};
Branch: 1 branch
BranchTrueFalseTotal
if $args->{"xml"} 4 0 4
33 5 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
34  
35 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
36  
37 4 ▶sub load_xml {
Subroutine load_xml: called CC=2 SCAR=6.9
Pod undocumented
38 4 my $self = shift;
39 4 my $dom = shift;
40  
41 4 $self->_set_id( $dom->findvalue("id/text()") );
42 4 $self->_set_account( $dom->findvalue("account/text()") );
43 4 $self->_set_avatar( $dom->findvalue('avatar/@uri') );
44 4 $self->_set_creation_time( $dom->findvalue("created_at/text()") );
45 4 $self->_set_body( $dom->findvalue("body/text()") );
46  
47 4 for ( $dom->findnodes('tags/*') ) {
48 1 $self->insert_tag(
49 WWW::Ohloh::API::Message::Tag->new(
50 ohloh => $ohloh_of[$$self],
51 xml => $_,
52 ) );
53 }
54  
55 }
56  
57 1 ▶sub tags {
Subroutine tags: called CC=2 SCAR=7.1
Pod documented
58 1 my $self = shift;
59 1 ▶ return $tags_of[$$self] ? @{ $tags_of[$$self] } : ();
Branch: 1 branch
BranchTrueFalseTotal
$tags_of[$$self] ? : 1 0 1
60 }
61  
62 1 ▶sub insert_tag {
Subroutine insert_tag: called CC=1 SCAR=0.0
Pod undocumented
63 1 my $self = shift;
64 1 push @{ $tags_of[$$self] }, @_;
65 }
66  
67 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
68  
69 0 ▶sub as_xml {
Subroutine as_xml: not called CC=2 SCAR=17.9
Pod documented
70 0 my $self = shift;
71 0 my $xml;
72 0 my $w = XML::Writer->new( OUTPUT => \$xml );
73  
74 0 $w->startTag('language');
75  
76 0 for my $e (@api_fields) {
77 0 $w->dataElement( $e => $self->$e );
78 }
79  
80 0 $w->endTag;
81  
82 0 return $xml;
83 }
84  
85 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
86  
87 0 ▶sub is_code {
Subroutine is_code: not called CC=1 SCAR=6.9
Pod undocumented
88 0 my $self = shift;
89  
90 0 return $self->category eq 'code';
91 }
92  
93 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
94  
95 0 ▶sub is_markup {
Subroutine is_markup: not called CC=1 SCAR=6.9
Pod undocumented
96 0 my $self = shift;
97  
98 0 return $self->category eq 'markup';
99 }
100  
101 5 'end of WWW::Ohloh::API::Language';
102  
103 __END__
« API/ContributorFact.pm ↑ Summary API/Language.pm »