API/Repository.pm

filter: Statementstmt 100% 44 / 44 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod 50.0% 1 / 2 totaltotal 98.1% 54 / 55 CC 3 SCAR 3.1
CC
3
Cov
100%
load_xml
2.0
as_xml
2.0
BEGIN
1.0
CRAP 1.4
« API/ContributorLanguageFact.pm ↑ Summary API/Role/LoadXML.pm »
1 package WWW::Ohloh::API::Repository;
2 32 our $AUTHORITY = 'cpan:YANICK';
3  
4 32 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 32 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 32 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 32 ▶use XML::LibXML;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 32 ▶use URI;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 32 ▶use Object::InsideOut qw/
Subroutine BEGIN: called CC=1 SCAR=0.0
12 WWW::Ohloh::API::Role::Fetchable
13 WWW::Ohloh::API::Role::LoadXML
14 32 /;
15  
16 32 our $VERSION = '1.0_1';
17  
18 32 my @api_fields = qw/
19 id
20 type
21 url
22 module_name
23 username
24 password
25 logged_at
26 commits
27 ohloh_job_status
28 /;
29  
30 #<<<
31 32 my @id_of : Field
32 : Set(_set_id)
33 : Get(id)
34 ;
35 32 my @type_of : Field
36 : Set(_set_type)
37 : Get(type);
38 32 my @url_of : Field
39 : Type(URI)
40 : Get(url)
41 ;
42 32 my @module_name_of : Field
43 : Set(_set_module_name)
44 : Get(module_name);
45 32 my @username_of : Field
46 : Set(_set_username)
47 : Get(username);
48 32 my @password_of : Field
49 : Set(_set_password)
50 : Get(password)
51 ;
52 32 my @logged_at_of : Field
53 : Set(_set_logged_at)
54 : Get(logged_at)
55 ;
56 32 my @commits_of : Field
57 : Set(_set_commits)
58 : Get(commits)
59 ;
60 32 my @ohloh_job_status_of : Field
61 : Set(_set_ohloh_job_status)
62 : Get(ohloh_job_status);
63 #>>>
64 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
65  
66 2 ▶sub load_xml {
Subroutine load_xml: called CC=2 SCAR=6.9
Pod undocumented
67 2 my ( $self, $dom ) = @_;
68  
69 2 for my $f (@api_fields) {
70 18 my $m = "_set_$f";
71  
72 18 $self->$m( $dom->findvalue("$f/text()") );
73 }
74 }
75  
76 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
77  
78 2 ▶sub _set_url {
Subroutine _set_url: called CC=1 SCAR=0.0
79 2 my ( $self, $url ) = @_;
80 2 $url_of[$$self] = URI->new($url);
81 }
82  
83 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
84  
85 1 ▶sub as_xml {
Subroutine as_xml: called CC=2 SCAR=6.9
Pod documented
86 1 my $self = shift;
87 1 my $xml;
88 1 my $w = XML::Writer->new( OUTPUT => \$xml );
89  
90 1 $w->startTag('repository');
91  
92 1 $w->dataElement( $_ => $self->$_ ) for @api_fields;
93  
94 1 $w->endTag;
95  
96 1 return $xml;
97 }
98  
99 32 'end of WWW::Ohloh::API::Repository';
100  
101 __END__
« API/ContributorLanguageFact.pm ↑ Summary API/Role/LoadXML.pm »