| 1 | package WWW::Ohloh::API::Message::Tag; | ||||||||||
| 2 | |||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 1 | use Object::InsideOut qw/ | |||||||||
| 7 | WWW::Ohloh::API::Role::Fetchable | ||||||||||
| 8 | WWW::Ohloh::API::Role::LoadXML | ||||||||||
| 9 | 1 | ▶ | /; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | |||||||||||
| 11 | 1 | ▶ | use Carp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | 1 | ▶ | use XML::LibXML; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | |||||||||||
| 14 | 1 | ▶ | use List::MoreUtils qw/ any /; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 15 | |||||||||||
| 16 | 1 | our $VERSION = '0.3.2'; | |||||||||
| 17 | |||||||||||
| 18 | 1 | my @type_of : Field : Set(set_type) : Get(type); | |||||||||
| 19 | 1 | my @uri_of : Field : Set(set_uri) : Get(uri); | |||||||||
| 20 | 1 | my @content_of : Field : Set(set_content) : Get(content); | |||||||||
| 21 | |||||||||||
| 22 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||||||||||
| 23 | |||||||||||
| 24 | sub load_xml { | ||||||||||
| 25 | 1 | ▶ | my $self = shift; | ||||||||
|
Subroutine
load_xml: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||
| 26 | 1 | my $dom = shift; | |||||||||
| 27 | |||||||||||
| 28 | 1 | my $type = $dom->nodeName; | |||||||||
| 29 | die "tag is of type $type, should be 'project' or 'account'" | ||||||||||
| 30 | 1 | ▶ | unless any { $_ eq $type } qw/ project account /; | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.2
Branch: 1 branch
| |||||||||||
| 31 | |||||||||||
| 32 | 1 | $self->set_type($type); | |||||||||
| 33 | 1 | $self->set_uri( $dom->getAttribute('uri') ); | |||||||||
| 34 | 1 | $self->set_content( $dom->findvalue('text()') ); | |||||||||
| 35 | } | ||||||||||
| 36 | |||||||||||
| 37 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||||||||||
| 38 | |||||||||||
| 39 | sub as_xml { | ||||||||||
| 40 | 0 | ▶ | my $self = shift; | ||||||||
|
Subroutine
as_xml: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 41 | 0 | my $xml; | |||||||||
| 42 | 0 | my $w = XML::Writer->new( OUTPUT => \$xml ); | |||||||||
| 43 | |||||||||||
| 44 | 0 | $w->dataElement( $self->type, $self->content, uri => $self->uri ); | |||||||||
| 45 | |||||||||||
| 46 | 0 | return $xml; | |||||||||
| 47 | } | ||||||||||
| 48 | |||||||||||
| 49 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||||||||||
| 50 | |||||||||||
| 51 | sub is_project { | ||||||||||
| 52 | 0 | ▶ | return $_[0]->type eq 'project'; | ||||||||
|
Subroutine
is_project: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 53 | } | ||||||||||
| 54 | |||||||||||
| 55 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||||||||||
| 56 | |||||||||||
| 57 | sub is_account { | ||||||||||
| 58 | 0 | ▶ | return $_[0]->type eq 'account'; | ||||||||
|
Subroutine
is_account: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 59 | } | ||||||||||
| 60 | |||||||||||
| 61 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||||||||||
| 62 | |||||||||||
| 63 | 1 | 'end of WWW::Ohloh::API::Message::Tag'; | |||||||||
| 64 | |||||||||||
| 65 | __END__ | ||||||||||
| 66 | |||||||||||
| 67 | =head1 NAME | ||||||||||
| 68 | |||||||||||
| 69 | WWW::Ohloh::API::Message::Tag - a tag associated to an Ohloh message | ||||||||||
| 70 | |||||||||||
| 71 | =head1 SYNOPSIS | ||||||||||
| 72 | |||||||||||
| 73 | use WWW::Ohloh::API; | ||||||||||
| 74 | |||||||||||
| 75 | my $ohloh = WWW::Ohloh::API->new( api_key => $my_api_key ); | ||||||||||
| 76 | my $messages = $ohloh->fetch_messages( account => $account ); | ||||||||||
| 77 | |||||||||||
| 78 | while ( my $msg = $messages->next ) { | ||||||||||
| 79 | print $msg->body, "\n"; | ||||||||||
| 80 | for my $tag ( $msg->tags ) { | ||||||||||
| 81 | print "\t", $tag->content, "\n"; | ||||||||||
| 82 | } | ||||||||||
| 83 | } | ||||||||||
| 84 | |||||||||||
| 85 | =head1 DESCRIPTION | ||||||||||
| 86 | |||||||||||
| 87 | W::O::A::Message::Tag contains the information of a tag associated with a | ||||||||||
| 88 | message. | ||||||||||
| 89 | |||||||||||
| 90 | =head1 METHODS | ||||||||||
| 91 | |||||||||||
| 92 | =head2 API Data Accessors | ||||||||||
| 93 | |||||||||||
| 94 | =head3 type | ||||||||||
| 95 | |||||||||||
| 96 | Returns the tag type, which can be 'account' or 'project'. | ||||||||||
| 97 | |||||||||||
| 98 | =head3 set_type( $type ) | ||||||||||
| 99 | |||||||||||
| 100 | Sets the tag type. Must be either 'account' or 'project'. | ||||||||||
| 101 | |||||||||||
| 102 | =head3 uri | ||||||||||
| 103 | |||||||||||
| 104 | Returns the tag uri. | ||||||||||
| 105 | |||||||||||
| 106 | =head3 set_uri( I<$uri> ) | ||||||||||
| 107 | |||||||||||
| 108 | Sets the tag uri. | ||||||||||
| 109 | |||||||||||
| 110 | =head3 content | ||||||||||
| 111 | |||||||||||
| 112 | Returns the content of the tag, which will either be the name of the | ||||||||||
| 113 | tagged project or account. | ||||||||||
| 114 | |||||||||||
| 115 | =head3 set_content( I<$name> ) | ||||||||||
| 116 | |||||||||||
| 117 | Sets the content of the tag to I<$name>. | ||||||||||
| 118 | |||||||||||
| 119 | |||||||||||
| 120 | =head2 Other Methods | ||||||||||
| 121 | |||||||||||
| 122 | =head3 as_xml | ||||||||||
| 123 | |||||||||||
| 124 | Returns the tag information | ||||||||||
| 125 | as an XML string. Note that this is not the exact xml document as returned | ||||||||||
| 126 | by the Ohloh server. | ||||||||||
| 127 | |||||||||||
| 128 | =head1 SEE ALSO | ||||||||||
| 129 | |||||||||||
| 130 | =over | ||||||||||
| 131 | |||||||||||
| 132 | =item * | ||||||||||
| 133 | |||||||||||
| 134 | L<WWW::Ohloh::API>, | ||||||||||
| 135 | L<WWW::Ohloh::API::Message>. | ||||||||||
| 136 | |||||||||||
| 137 | =item * | ||||||||||
| 138 | |||||||||||
| 139 | Ohloh API reference: http://www.ohloh.net/api/getting_started | ||||||||||
| 140 | |||||||||||
| 141 | =item * | ||||||||||
| 142 | |||||||||||
| 143 | Ohloh Account API reference: http://www.ohloh.net/api/reference/message | ||||||||||
| 144 | |||||||||||
| 145 | =back | ||||||||||
| 146 | |||||||||||
| 147 | =head1 VERSION | ||||||||||
| 148 | |||||||||||
| 149 | This document describes WWW::Ohloh::API version 0.3.2 | ||||||||||
| 150 | |||||||||||
| 151 | =head1 BUGS AND LIMITATIONS | ||||||||||
| 152 | |||||||||||
| 153 | WWW::Ohloh::API is very extremely alpha quality. It'll improve, | ||||||||||
| 154 | but till then: I<Caveat emptor>. | ||||||||||
| 155 | |||||||||||
| 156 | The C<as_xml()> method returns a re-encoding of the account data, which | ||||||||||
| 157 | can differ of the original xml document sent by the Ohloh server. | ||||||||||
| 158 | |||||||||||
| 159 | Please report any bugs or feature requests to | ||||||||||
| 160 | C<bug-www-ohloh-api@rt.cpan.org>, or through the web interface at | ||||||||||
| 161 | L<http://rt.cpan.org>. | ||||||||||
| 162 | |||||||||||
| 163 | |||||||||||
| 164 | =head1 AUTHOR | ||||||||||
| 165 | |||||||||||
| 166 | Yanick Champoux C<< <yanick@cpan.org> >> | ||||||||||
| 167 | |||||||||||
| 168 | =head1 LICENCE AND COPYRIGHT | ||||||||||
| 169 | |||||||||||
| 170 | Copyright (c) 2008, Yanick Champoux C<< <yanick@cpan.org> >>. All rights reserved. | ||||||||||
| 171 | |||||||||||
| 172 | This module is free software; you can redistribute it and/or | ||||||||||
| 173 | modify it under the same terms as Perl itself. See L<perlartistic>. | ||||||||||
| 174 | |||||||||||
| 175 | =cut | ||||||||||
| 176 | |||||||||||
| 177 | |||||||||||