File Coverage

blib/lib/WWW/Ohloh/API/Repository.pm
Criterion Covered Total %
statement 31 31 100.0
branch n/a
condition n/a
subroutine 9 9 100.0
pod 1 2 50.0
total 41 42 97.6


line stmt bran cond sub pod time code
1             package WWW::Ohloh::API::Repository;
2             our $AUTHORITY = 'cpan:YANICK';
3              
4 32     32   421970 use strict;
  32         68  
  32         1238  
5 32     32   162 use warnings;
  32         83  
  32         1681  
6              
7 32     32   184 use Carp;
  32         57  
  32         2160  
8 32     32   817 use XML::LibXML;
  32         35872  
  32         241  
9 32     32   8301 use URI;
  32         29082  
  32         1298  
10              
11 32         232 use Object::InsideOut qw/
12             WWW::Ohloh::API::Role::Fetchable
13             WWW::Ohloh::API::Role::LoadXML
14 32     32   1892 /;
  32         124275  
15              
16             our $VERSION = '1.0_1';
17              
18             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             my @id_of : Field
32             : Set(_set_id)
33             : Get(id)
34             ;
35             my @type_of : Field
36             : Set(_set_type)
37             : Get(type);
38             my @url_of : Field
39             : Type(URI)
40             : Get(url)
41             ;
42             my @module_name_of : Field
43             : Set(_set_module_name)
44             : Get(module_name);
45             my @username_of : Field
46             : Set(_set_username)
47             : Get(username);
48             my @password_of : Field
49             : Set(_set_password)
50             : Get(password)
51             ;
52             my @logged_at_of : Field
53             : Set(_set_logged_at)
54             : Get(logged_at)
55             ;
56             my @commits_of : Field
57             : Set(_set_commits)
58             : Get(commits)
59             ;
60             my @ohloh_job_status_of : Field
61             : Set(_set_ohloh_job_status)
62             : Get(ohloh_job_status);
63             #>>>
64             #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
65              
66             sub load_xml {
67 2     2 0 23 my ( $self, $dom ) = @_;
68              
69 2         6 for my $f (@api_fields) {
70 18         8215 my $m = "_set_$f";
71              
72 18         78 $self->$m( $dom->findvalue("$f/text()") );
73             }
74             }
75              
76             #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
77              
78             sub _set_url {
79 2     2   102 my ( $self, $url ) = @_;
80 2         9 $url_of[$$self] = URI->new($url);
81             }
82              
83             #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
84              
85             sub as_xml {
86 1     1 1 1 my $self = shift;
87 1         2 my $xml;
88 1         3 my $w = XML::Writer->new( OUTPUT => \$xml );
89              
90 1         179 $w->startTag('repository');
91              
92 1         63 $w->dataElement( $_ => $self->$_ ) for @api_fields;
93              
94 1         796 $w->endTag;
95              
96 1         138 return $xml;
97             }
98              
99             'end of WWW::Ohloh::API::Repository';
100              
101             __END__