| 1 | package WWW::Ohloh::API::Factoid; | ||||||||||
| 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 | our $VERSION = '0.3.2'; | |||||||||
| 11 | |||||||||||
| 12 | 15 | my @request_url_of : Field : Arg(request_url) : Get( request_url ); | |||||||||
| 13 | 15 | my @xml_of : Field : Arg(xml); | |||||||||
| 14 | |||||||||||
| 15 | 15 | my @api_fields = qw/ | |||||||||
| 16 | id | ||||||||||
| 17 | analysis_id | ||||||||||
| 18 | type | ||||||||||
| 19 | description | ||||||||||
| 20 | severity | ||||||||||
| 21 | license_id | ||||||||||
| 22 | /; | ||||||||||
| 23 | |||||||||||
| 24 | 15 | my @id_of : Field : Set(_set_id) : Get(id); | |||||||||
| 25 | 15 | my @analysis_id_of : Field : Set(_set_analysis_id) : Get(analysis_id); | |||||||||
| 26 | 15 | my @type_of : Field : Set(_set_type) : Get(type); | |||||||||
| 27 | 15 | my @description_of : Field : Set(_set_description) : Get(description); | |||||||||
| 28 | 15 | my @severity_of : Field : Set(_set_severity) : Get(severity); | |||||||||
| 29 | 15 | my @license_id_of : Field : Set(_set_license_id) : Get(license_id); | |||||||||
| 30 | |||||||||||
| 31 | 15 | my @ohloh_of : Field : Arg(ohloh); | |||||||||
| 32 | |||||||||||
| 33 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||||||||||
| 34 | |||||||||||
| 35 | sub _init : Init { | ||||||||||
| 36 | 8 | ▶ | my $self = shift; | ||||||||
|
Subroutine
_init: called CC=2 SCAR=6.9
| |||||||||||
| 37 | |||||||||||
| 38 | 8 | ▶ | my $dom = $xml_of[$$self] or return; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 39 | |||||||||||
| 40 | 8 | $self->_set_id( $dom->findvalue("id/text()") ); | |||||||||
| 41 | 8 | $self->_set_analysis_id( $dom->findvalue("analysis_id/text()") ); | |||||||||
| 42 | 8 | $self->_set_type( $dom->findvalue("type/text()") ); | |||||||||
| 43 | 8 | $self->_set_description( $dom->findvalue("description/text()") ); | |||||||||
| 44 | 8 | $self->_set_severity( $dom->findvalue("severity/text()") ); | |||||||||
| 45 | 8 | $self->_set_license_id( $dom->findvalue("license_id/text()") ); | |||||||||
| 46 | |||||||||||
| 47 | 8 | return; | |||||||||
| 48 | 15 | ▶ | } | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 49 | |||||||||||
| 50 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||||||||||
| 51 | |||||||||||
| 52 | sub as_xml { | ||||||||||
| 53 | 1 | ▶ | my $self = shift; | ||||||||
|
Subroutine
as_xml: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 54 | 1 | my $xml; | |||||||||
| 55 | 1 | my $w = XML::Writer->new( OUTPUT => \$xml ); | |||||||||
| 56 | |||||||||||
| 57 | 1 | $w->startTag('factoid'); | |||||||||
| 58 | |||||||||||
| 59 | 1 | for my $e (@api_fields) { | |||||||||
| 60 | 6 | $w->dataElement( $e => $self->$e ); | |||||||||
| 61 | } | ||||||||||
| 62 | |||||||||||
| 63 | 1 | $w->endTag; | |||||||||
| 64 | |||||||||||
| 65 | 1 | return $xml; | |||||||||
| 66 | } | ||||||||||
| 67 | |||||||||||
| 68 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||||||||||
| 69 | |||||||||||
| 70 | 15 | 'end of WWW::Ohloh::API::Factoid'; | |||||||||
| 71 | |||||||||||
| 72 | __END__ | ||||||||||
| 73 | |||||||||||
| 74 | =head1 NAME | ||||||||||
| 75 | |||||||||||
| 76 | WWW::Ohloh::API::Factoid - A factoid about an Ohloh project | ||||||||||
| 77 | |||||||||||
| 78 | =head1 SYNOPSIS | ||||||||||
| 79 | |||||||||||
| 80 | use WWW::Ohloh::API; | ||||||||||
| 81 | |||||||||||
| 82 | my $ohloh = WWW::Ohloh::API->new( api_key => $my_api_key ); | ||||||||||
| 83 | my @factoids = $ohloh->get_factoids( $project_id ); | ||||||||||
| 84 | |||||||||||
| 85 | print join "\n", map { $_->type } @factoids; | ||||||||||
| 86 | |||||||||||
| 87 | =head1 DESCRIPTION | ||||||||||
| 88 | |||||||||||
| 89 | W::O::A::Factoid is a bit of information about a project. | ||||||||||
| 90 | |||||||||||
| 91 | =head1 METHODS | ||||||||||
| 92 | |||||||||||
| 93 | =head2 API Data Accessors | ||||||||||
| 94 | |||||||||||
| 95 | =head3 id | ||||||||||
| 96 | |||||||||||
| 97 | $id = $factoid->id; | ||||||||||
| 98 | |||||||||||
| 99 | Return the id of the factoid. Note that the ids change | ||||||||||
| 100 | every time that a project is reanalyzed. | ||||||||||
| 101 | |||||||||||
| 102 | =head3 analysis_id | ||||||||||
| 103 | |||||||||||
| 104 | $id = $factoid->analysis_id; | ||||||||||
| 105 | |||||||||||
| 106 | Return the id of the analysis used to create the factoid. | ||||||||||
| 107 | |||||||||||
| 108 | =head3 type | ||||||||||
| 109 | |||||||||||
| 110 | $type = $factoid->type; | ||||||||||
| 111 | |||||||||||
| 112 | Return the factoid type. | ||||||||||
| 113 | |||||||||||
| 114 | =head3 description | ||||||||||
| 115 | |||||||||||
| 116 | $desc = $factoid->description; | ||||||||||
| 117 | |||||||||||
| 118 | Return a description of the factoid type. | ||||||||||
| 119 | |||||||||||
| 120 | =head3 severity | ||||||||||
| 121 | |||||||||||
| 122 | $sev = $factoid->severity; | ||||||||||
| 123 | |||||||||||
| 124 | Return the factoid's severity (ranges between -3 and +3). | ||||||||||
| 125 | |||||||||||
| 126 | =head3 license_id | ||||||||||
| 127 | |||||||||||
| 128 | $license_id = $factoid->license_id; | ||||||||||
| 129 | |||||||||||
| 130 | If the factoid's type is B<FactoidGplConflict>, | ||||||||||
| 131 | return the id of the conflicting license. | ||||||||||
| 132 | |||||||||||
| 133 | =head2 Other Methods | ||||||||||
| 134 | |||||||||||
| 135 | =head3 as_xml | ||||||||||
| 136 | |||||||||||
| 137 | Return the activity fact information | ||||||||||
| 138 | as an XML string. Note that this is not the exact xml document as returned | ||||||||||
| 139 | by the Ohloh server. | ||||||||||
| 140 | |||||||||||
| 141 | =head1 SEE ALSO | ||||||||||
| 142 | |||||||||||
| 143 | =over | ||||||||||
| 144 | |||||||||||
| 145 | =item * | ||||||||||
| 146 | |||||||||||
| 147 | L<WWW::Ohloh::API>. | ||||||||||
| 148 | |||||||||||
| 149 | =item * | ||||||||||
| 150 | |||||||||||
| 151 | Ohloh API reference: http://www.ohloh.net/api/getting_started | ||||||||||
| 152 | |||||||||||
| 153 | =item * | ||||||||||
| 154 | |||||||||||
| 155 | Ohloh Account API reference: http://www.ohloh.net/api/reference/activity_fact | ||||||||||
| 156 | |||||||||||
| 157 | =back | ||||||||||
| 158 | |||||||||||
| 159 | =head1 VERSION | ||||||||||
| 160 | |||||||||||
| 161 | This document describes WWW::Ohloh::API version 0.3.2 | ||||||||||
| 162 | |||||||||||
| 163 | =head1 BUGS AND LIMITATIONS | ||||||||||
| 164 | |||||||||||
| 165 | WWW::Ohloh::API is very extremely alpha quality. It'll improve, | ||||||||||
| 166 | but till then: I<Caveat emptor>. | ||||||||||
| 167 | |||||||||||
| 168 | The C<as_xml()> method returns a re-encoding of the activity fact data, which | ||||||||||
| 169 | can differ of the original xml document sent by the Ohloh server. | ||||||||||
| 170 | |||||||||||
| 171 | Please report any bugs or feature requests to | ||||||||||
| 172 | C<bug-www-ohloh-api@rt.cpan.org>, or through the web interface at | ||||||||||
| 173 | L<http://rt.cpan.org>. | ||||||||||
| 174 | |||||||||||
| 175 | |||||||||||
| 176 | =head1 AUTHOR | ||||||||||
| 177 | |||||||||||
| 178 | Yanick Champoux C<< <yanick@cpan.org> >> | ||||||||||
| 179 | |||||||||||
| 180 | =head1 LICENCE AND COPYRIGHT | ||||||||||
| 181 | |||||||||||
| 182 | Copyright (c) 2008, Yanick Champoux C<< <yanick@cpan.org> >>. All rights reserved. | ||||||||||
| 183 | |||||||||||
| 184 | This module is free software; you can redistribute it and/or | ||||||||||
| 185 | modify it under the same terms as Perl itself. See L<perlartistic>. | ||||||||||
| 186 | |||||||||||
| 187 | =cut | ||||||||||
| 188 | |||||||||||
| 189 | |||||||||||