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

filter: Statementstmt 100% 48 / 48 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 10 / 10 Podpod 100% 2 / 2 totaltotal 98.3% 61 / 62 CC 3 SCAR 2.9
CC
3
Cov
98%
_init
2.0
as_xml
2.0
BEGIN
1.0
CRAP 1.3
« blib/lib/WWW/Ohloh/API/Role/LoadXML.pm ↑ Summary blib/lib/WWW/Ohloh/API/KudoScore.pm »
1 package WWW::Ohloh::API::Enlistment;
2  
3 15 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 15 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 15 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 15 ▶use Object::InsideOut;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 15 ▶use XML::LibXML;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 15 ▶use WWW::Ohloh::API::Repository;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 15 our $VERSION = '0.3.2';
13  
14 15 my @ohloh_of : Field : Arg(ohloh) : Get(_ohloh);
15 15 my @request_url_of : Field : Arg(request_url) : Get( request_url );
16 15 my @xml_of : Field : Arg(xml);
17  
18 15 my @api_fields = qw/
19 id
20 project_id
21 repository_id
22 /;
23  
24 15 my @id_of : Field : Set(_set_id) : Get(id);
25 15 my @project_id_of : Field : Set(_set_project_id) : Get(project_id);
26 15 my @repository_id_of : Field : Set(_set_repository_id) : Get(repository_id);
27  
28 15 my @repository_of : Field;
29  
30 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
31  
32 sub _init : Init {
33 1 ▶ my $self = shift;
Subroutine _init: called CC=2 SCAR=7.0
34  
35 1 ▶ my $dom = $xml_of[$$self] or return;
Branch: 1 branch
BranchTrueFalseTotal
my $dom = $xml_of[$$self] or return 0 1 1
36  
37 1 $self->_set_id( $dom->findvalue("id/text()") );
38 1 $self->_set_project_id( $dom->findvalue("project_id/text()") );
39 1 $self->_set_repository_id( $dom->findvalue("repository_id/text()") );
40  
41 1 $repository_of[$$self] = WWW::Ohloh::API::Repository->new(
42 xml => $dom->findnodes('repository[1]'),
43 ohloh => $self->_ohloh,
44 );
45 15 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
46  
47 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
48  
49 sub repository {
50 1 ▶ my $self = shift;
Subroutine repository: called CC=1 SCAR=0.0
Pod documented
51  
52 1 return $repository_of[$$self];
53 }
54  
55 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
56  
57 sub as_xml {
58 1 ▶ my $self = shift;
Subroutine as_xml: called CC=2 SCAR=6.9
Pod documented
59 1 my $xml;
60 1 my $w = XML::Writer->new( OUTPUT => \$xml );
61  
62 1 $w->startTag('enlistment');
63  
64 1 for my $attr (@api_fields) {
65 3 $w->dataElement( $attr => $self->$attr );
66 }
67  
68 1 $xml .= $self->repository->as_xml;
69  
70 1 $w->endTag;
71  
72 1 return $xml;
73 }
74  
75 15 'end of WWW::Ohloh::API::Enlistment';
76  
77 __END__
78  
79 =head1 NAME
80  
81 WWW::Ohloh::API::Enlistment - an Ohloh enlistment
82  
83 =head1 SYNOPSIS
84  
85 use WWW::Ohloh::API;
86  
87 my $ohloh = WWW::Ohloh::API->new( api_key => $my_api_key );
88 my @enlistments = $ohloh->get_enlistments(
89 project_id => 12933,
90 );
91
92 =head1 DESCRIPTION
93  
94 W::O::A::Enlistment contains the information that join
95 a project with a repository
96 as defined at http://www.ohloh.net/api/reference/enlistment.
97 To be properly populated, it must be created via
98 the C<get_enlistments> method of a L<WWW::Ohloh::API> object.
99  
100 =head1 METHODS
101  
102 =head2 API Data Accessors
103  
104 =head3 id, project_id, repository_id
105  
106 my $id = $enlistment->id;
107 my $project_id = $enlistment->project_id;
108 my $repository_id = $enlistment->repository_id;
109  
110 Return the id of the enlistment / project / repository.
111  
112 =head3 repository
113  
114 my $repository = $enlistment->repository
115  
116 Return the repository associated with the enlistment
117 as a L<WWW::Ohloh::API::Repository> object.
118  
119 =head2 Other Methods
120  
121 =head3 as_xml
122  
123 Return the account information
124 as an XML string. Note that this is not the exact xml document as returned
125 by the Ohloh server.
126  
127 =head1 SEE ALSO
128  
129 =over
130  
131 =item *
132  
133 L<WWW::Ohloh::API>, L<WWW::Ohloh::API::KudoScore>,
134 L<WWW::Ohloh::API::ContributorFact>.
135  
136 =item *
137  
138 Ohloh API reference: http://www.ohloh.net/api/getting_started
139  
140 =item *
141  
142 Ohloh Account API reference:
143 http://www.ohloh.net/api/reference/contributor_language_fact
144  
145 =back
146  
147 =head1 VERSION
148  
149 This document describes WWW::Ohloh::API::ContributorLanguageFact
150 version 0.0.6
151  
152 =head1 BUGS AND LIMITATIONS
153  
154 WWW::Ohloh::API is very extremely alpha quality. It'll improve,
155 but till then: I<Caveat emptor>.
156  
157 The C<as_xml()> method returns a re-encoding of the account data, which
158 can differ of the original xml document sent by the Ohloh server.
159  
160 Please report any bugs or feature requests to
161 C<bug-www-ohloh-api@rt.cpan.org>, or through the web interface at
162 L<http://rt.cpan.org>.
163  
164  
165 =head1 AUTHOR
166  
167 Yanick Champoux C<< <yanick@cpan.org> >>
168  
169 =head1 LICENCE AND COPYRIGHT
170  
171 Copyright (c) 2008, Yanick Champoux C<< <yanick@cpan.org> >>. All rights reserved.
172  
173 This module is free software; you can redistribute it and/or
174 modify it under the same terms as Perl itself. See L<perlartistic>.
175  
176  
177  
« blib/lib/WWW/Ohloh/API/Role/LoadXML.pm ↑ Summary blib/lib/WWW/Ohloh/API/KudoScore.pm »