| WWW-Ohloh-API documentation | Contained in the WWW-Ohloh-API distribution. |
WWW::Ohloh::API::StackEntry - A project entry in a stack
use WWW::Ohloh::API;
my $ohloh = WWW::Ohloh::API->new( api_key => $my_api_key );
# from an account
my @entries = $ohloh->get_account_stack( $account_id )->stack_entries;
# from a project
my @stacks = $ohloh->get_project_stacks( $project_id );
my @entries = $stacks[0]->stack_entries;
W::O::A::StackEntry represents one project in a stack.
Returns the unique id for the stack entry.
Returns the time at which the project was added to the stack.
Returns the id of the stack containing the entry.
Returns the id of the project.
Returns the project as a WWW::Ohloh::API::Project object.
If the optional argument $retrieve is given and false, the project will not be queried from the Ohloh server if it's not already known, and the method will return nothing.
Return the stack entry as an XML string. Note that this is not the same xml document as returned by the Ohloh server.
Ohloh API reference: http://www.ohloh.net/api/getting_started
Ohloh Account API reference: http://www.ohloh.net/api/reference/stack_entry
This document describes WWW::Ohloh::API version 0.3.1
WWW::Ohloh::API is very extremely alpha quality. It'll improve, but till then: Caveat emptor.
Please report any bugs or feature requests to
bug-www-ohloh-api@rt.cpan.org, or through the web interface at
http://rt.cpan.org.
Yanick Champoux <yanick@cpan.org>
Copyright (c) 2008, Yanick Champoux <yanick@cpan.org>. All rights reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.
| WWW-Ohloh-API documentation | Contained in the WWW-Ohloh-API distribution. |
package WWW::Ohloh::API::StackEntry; use strict; use warnings; use Carp; use Object::InsideOut; use XML::LibXML; use Readonly; use List::MoreUtils qw/ any /; our $VERSION = '0.3.1'; my @ohloh_of : Field : Arg(ohloh); my @request_url_of : Field : Arg(request_url) : Get( request_url ); my @xml_of : Field : Arg(xml); my @api_fields = qw/ id created_at stack_id project_id /; __PACKAGE__->create_field( '%' . $_, ":Set(_set_$_)", ":Get($_)" ) for @api_fields; my @project : Field; #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ sub _init : Init { my $self = shift; my $dom = $xml_of[$$self] or return; for my $f (@api_fields) { my $method = "_set_$f"; $self->$method( $dom->findvalue("$f/text()") ); } if ( my ($project_xml) = $dom->findnodes('//project[1]') ) { $project[$$self] = WWW::Ohloh::API::Project->new( ohloh => $ohloh_of[$$self], xml => $project_xml, ); } return; } #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ sub as_xml { my $self = shift; my $xml; my $w = XML::Writer->new( OUTPUT => \$xml ); $w->startTag('stack_entry'); for my $f (@api_fields) { $w->dataElement( $f => $self->$f ); } if ( my $project = $project[$$self] ) { $xml .= $project->as_xml; } $w->endTag; return $xml; } #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ sub project { my $self = shift; my $retrieve = shift; $retrieve = 1 unless defined $retrieve; if ($retrieve) { $project[$$self] ||= $ohloh_of[$$self]->get_project( $self->project_id ); } return $project[$$self]; } 'end of WWW::Ohloh::API::StackEntry'; __END__