blib/lib/WWW/Ohloh/API/Repository.pm

filter: Statementstmt 100% 43 / 43 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod 50.0% 1 / 2 totaltotal 98.1% 53 / 54 CC 3 SCAR 3.1
CC
3
Cov
100%
load_xml
2.0
as_xml
2.0
BEGIN
1.0
CRAP 1.4
« blib/lib/WWW/Ohloh/API/ContributorLanguageFact.pm ↑ Summary blib/lib/WWW/Ohloh/API/Role/LoadXML.pm »
1 package WWW::Ohloh::API::Repository;
2  
3 17 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 17 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 17 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 17 ▶use XML::LibXML;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 17 ▶use URI;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 17 use Object::InsideOut qw/
11 WWW::Ohloh::API::Role::Fetchable
12 WWW::Ohloh::API::Role::LoadXML
13 17 ▶ /;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 17 our $VERSION = '1.0_1';
16  
17 17 my @api_fields = qw/
18 id
19 type
20 url
21 module_name
22 username
23 password
24 logged_at
25 commits
26 ohloh_job_status
27 /;
28  
29 #<<<
30 17 my @id_of : Field
31 : Set(_set_id)
32 : Get(id)
33 ;
34 17 my @type_of : Field
35 : Set(_set_type)
36 : Get(type);
37 17 my @url_of : Field
38 : Type(URI)
39 : Get(url)
40 ;
41 17 my @module_name_of : Field
42 : Set(_set_module_name)
43 : Get(module_name);
44 17 my @username_of : Field
45 : Set(_set_username)
46 : Get(username);
47 17 my @password_of : Field
48 : Set(_set_password)
49 : Get(password)
50 ;
51 17 my @logged_at_of : Field
52 : Set(_set_logged_at)
53 : Get(logged_at)
54 ;
55 17 my @commits_of : Field
56 : Set(_set_commits)
57 : Get(commits)
58 ;
59 17 my @ohloh_job_status_of : Field
60 : Set(_set_ohloh_job_status)
61 : Get(ohloh_job_status);
62 #>>>
63 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
64  
65 sub load_xml {
66 2 ▶ my ( $self, $dom ) = @_;
Subroutine load_xml: called CC=2 SCAR=6.9
Pod undocumented
67  
68 2 for my $f (@api_fields) {
69 18 my $m = "_set_$f";
70  
71 18 $self->$m( $dom->findvalue("$f/text()") );
72 }
73 }
74  
75 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
76  
77 sub _set_url {
78 2 ▶ my ( $self, $url ) = @_;
Subroutine _set_url: called CC=1 SCAR=0.0
79 2 $url_of[$$self] = URI->new($url);
80 }
81  
82 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
83  
84 sub as_xml {
85 1 ▶ my $self = shift;
Subroutine as_xml: called CC=2 SCAR=6.9
Pod documented
86 1 my $xml;
87 1 my $w = XML::Writer->new( OUTPUT => \$xml );
88  
89 1 $w->startTag('repository');
90  
91 1 $w->dataElement( $_ => $self->$_ ) for @api_fields;
92  
93 1 $w->endTag;
94  
95 1 return $xml;
96 }
97  
98 17 'end of WWW::Ohloh::API::Repository';
99  
100 __END__
101  
102 =head1 NAME
103  
104 WWW::Ohloh::API::Repository - A code repository
105  
106 =head1 SYNOPSIS
107  
108 use WWW::Ohloh::API;
109  
110 my $ohloh = WWW::Ohloh::API->new( api_key => $my_api_key );
111 my @enlistments = $ohloh->get_enlistments(
112 project_id => 12933,
113 );
114 my @repository = map { $_->repository } @enlistments;
115
116 =head1 DESCRIPTION
117  
118 W::O::A::Repository contains the information associated with
119 a code repository
120 as defined at http://www.ohloh.net/api/reference/repository.
121  
122 =head1 METHODS
123  
124 =head2 API Data Accessors
125  
126 =head3 id
127  
128 my $id = $repository->id;
129  
130 Return the id of the repository.
131  
132 =head3 type
133  
134 my $is_git = $repository->type eq 'GitRepository';
135  
136 Return the type of the repository, which can be
137 either C<SvnRepository>, C<CvsRepository> or
138 C<GitRepository>.
139  
140 =head3 url
141  
142 Return the repository's public url as a L<URI> object. If you
143 just want the url, don't be scared by that: URI objects are
144 stringified into what you expect. E.g.:
145  
146 my $url = $repository->url;
147 print $url; # will print a good ol' "http://..." string
148  
149 =head3 module_name
150  
151 my $module = $repository->module_name;
152  
153 For CVS repositories, return the name of the module.
154  
155 =head3 username, password
156  
157 my $user = $repository->username;
158 my $password = $repository->password;
159  
160 Return, if necessary, the username / password required to log to the repository.
161  
162 =head3 logged_at
163  
164 my $last = $repository->logged_at;
165  
166 Return the last time the Ohloh server successfully queried the repository.
167  
168 =head3 commits
169  
170 my $nbr = $repository->commits;
171  
172 Return the total number of commits downloaded by the Ohloh server.
173  
174 =head3 ohloh_job_status
175
176 my $ok = $repository->ohloh_job_status eq 'success';
177  
178 Return the result of the last attempt of the Ohloh server to read the
179 repository, which can be either C<success> or C<failed>.
180  
181 =head2 Other Methods
182  
183 =head3 as_xml
184  
185 Return the account information
186 as an XML string. Note that this is not the exact xml document as returned
187 by the Ohloh server.
188  
189 =head1 SEE ALSO
190  
191 =over
192  
193 =item *
194  
195 L<WWW::Ohloh::API>, L<WWW::Ohloh::API::KudoScore>,
196 L<WWW::Ohloh::API::ContributorFact>.
197  
198 =item *
199  
200 L<URI>.
201  
202 =item *
203  
204 Ohloh API reference: http://www.ohloh.net/api/getting_started
205  
206 =item *
207  
208 Ohloh Account API reference:
209 http://www.ohloh.net/api/reference/contributor_language_fact
210  
211 =back
212  
213 =head1 VERSION
214  
215 This document describes WWW::Ohloh::API::ContributorLanguageFact
216 version 0.0.6
217  
218 =head1 BUGS AND LIMITATIONS
219  
220 WWW::Ohloh::API is very extremely alpha quality. It'll improve,
221 but till then: I<Caveat emptor>.
222  
223 The C<as_xml()> method returns a re-encoding of the account data, which
224 can differ of the original xml document sent by the Ohloh server.
225  
226 Please report any bugs or feature requests to
227 C<bug-www-ohloh-api@rt.cpan.org>, or through the web interface at
228 L<http://rt.cpan.org>.
229  
230  
231 =head1 AUTHOR
232  
233 Yanick Champoux C<< <yanick@cpan.org> >>
234  
235 =head1 LICENCE AND COPYRIGHT
236  
237 Copyright (c) 2008, Yanick Champoux C<< <yanick@cpan.org> >>. All rights reserved.
238  
239 This module is free software; you can redistribute it and/or
240 modify it under the same terms as Perl itself. See L<perlartistic>.
241  
242  
243  
« blib/lib/WWW/Ohloh/API/ContributorLanguageFact.pm ↑ Summary blib/lib/WWW/Ohloh/API/Role/LoadXML.pm »