| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package WWW::SourceForge::User; | 
| 2 | 3 |  |  | 3 |  | 13565 | use strict; | 
|  | 3 |  |  |  |  | 3 |  | 
|  | 3 |  |  |  |  | 67 |  | 
| 3 | 3 |  |  | 3 |  | 301 | use WWW::SourceForge; | 
|  | 3 |  |  |  |  | 4 |  | 
|  | 3 |  |  |  |  | 60 |  | 
| 4 | 3 |  |  | 3 |  | 719 | use WWW::SourceForge::Project; | 
|  | 3 |  |  |  |  | 3 |  | 
|  | 3 |  |  |  |  | 768 |  | 
| 5 |  |  |  |  |  |  |  | 
| 6 |  |  |  |  |  |  | our $VERSION = '0.30'; | 
| 7 |  |  |  |  |  |  |  | 
| 8 |  |  |  |  |  |  | =head2 new | 
| 9 |  |  |  |  |  |  |  | 
| 10 |  |  |  |  |  |  | Usage: | 
| 11 |  |  |  |  |  |  |  | 
| 12 |  |  |  |  |  |  | my $user = new WWW::SourceForge::User( username => 'rbowen' ); | 
| 13 |  |  |  |  |  |  |  | 
| 14 |  |  |  |  |  |  | Returns: WWW::SourceForge::User object; | 
| 15 |  |  |  |  |  |  |  | 
| 16 |  |  |  |  |  |  | =cut | 
| 17 |  |  |  |  |  |  |  | 
| 18 |  |  |  |  |  |  | sub new { | 
| 19 |  |  |  |  |  |  |  | 
| 20 | 13 |  |  | 13 | 1 | 49 | my ( $class, %parameters ) = @_; | 
| 21 | 13 |  | 33 |  |  | 102 | my $self = bless( {}, ref($class) || $class ); | 
| 22 |  |  |  |  |  |  |  | 
| 23 | 13 |  |  |  |  | 81 | my $api = new WWW::SourceForge; | 
| 24 | 13 |  |  |  |  | 16 | my $json; | 
| 25 | 13 | 50 |  |  |  | 52 | if ( $parameters{id} ) { | 
|  |  | 50 |  |  |  |  |  | 
| 26 | 0 |  |  |  |  | 0 | warn("The Sourceforge API no longer understands user IDs."); | 
| 27 | 0 |  |  |  |  | 0 | return 0; | 
| 28 |  |  |  |  |  |  | } elsif ( $parameters{username} ) { | 
| 29 |  |  |  |  |  |  | $json = $api->call( | 
| 30 | 13 |  |  |  |  | 68 | uri => '/u/' . $parameters{username} . '/profile/', | 
| 31 |  |  |  |  |  |  | ); | 
| 32 |  |  |  |  |  |  | } else { | 
| 33 | 0 |  |  |  |  | 0 | warn('You must provide an id or username. Bad monkey.'); | 
| 34 | 0 |  |  |  |  | 0 | return 0; | 
| 35 |  |  |  |  |  |  | } | 
| 36 |  |  |  |  |  |  |  | 
| 37 | 13 |  |  |  |  | 56 | $self->{data} = $json; | 
| 38 | 13 |  |  |  |  | 119 | return $self; | 
| 39 |  |  |  |  |  |  |  | 
| 40 |  |  |  |  |  |  | } | 
| 41 |  |  |  |  |  |  |  | 
| 42 | 0 |  |  | 0 | 0 | 0 | sub email { return shift->sf_email(); } | 
| 43 |  |  |  |  |  |  |  | 
| 44 |  |  |  |  |  |  | =head2 projects | 
| 45 |  |  |  |  |  |  |  | 
| 46 |  |  |  |  |  |  | Returns an array of Project objects | 
| 47 |  |  |  |  |  |  |  | 
| 48 |  |  |  |  |  |  | =cut | 
| 49 |  |  |  |  |  |  |  | 
| 50 |  |  |  |  |  |  | sub projects { | 
| 51 | 0 |  |  | 0 | 1 | 0 | my $self = shift; | 
| 52 |  |  |  |  |  |  |  | 
| 53 | 0 | 0 |  |  |  | 0 | return @{ $self->{data}->{_projects} } if $self->{data}->{_projects}; | 
|  | 0 |  |  |  |  | 0 |  | 
| 54 | 0 |  |  |  |  | 0 | my $p_ref = $self->{data}->{projects}; | 
| 55 | 0 |  |  |  |  | 0 | my @projects; | 
| 56 |  |  |  |  |  |  |  | 
| 57 | 0 |  |  |  |  | 0 | foreach my $p ( @$p_ref ) { | 
| 58 | 0 |  |  |  |  | 0 | my $proj = new WWW::SourceForge::Project( id => $p->{id} ); | 
| 59 | 0 |  |  |  |  | 0 | push (@projects, $proj ); | 
| 60 |  |  |  |  |  |  | } | 
| 61 |  |  |  |  |  |  |  | 
| 62 | 0 |  |  |  |  | 0 | $self->{data}->{_projects} = \@projects; | 
| 63 | 0 |  |  |  |  | 0 | return @projects; | 
| 64 |  |  |  |  |  |  | } | 
| 65 |  |  |  |  |  |  |  | 
| 66 |  |  |  |  |  |  | =head2 Data access AUTOLOADER | 
| 67 |  |  |  |  |  |  |  | 
| 68 |  |  |  |  |  |  | Handles most of the data access for the Project object. Some parts of | 
| 69 |  |  |  |  |  |  | the data require special treatment. | 
| 70 |  |  |  |  |  |  |  | 
| 71 |  |  |  |  |  |  | =cut | 
| 72 |  |  |  |  |  |  |  | 
| 73 |  |  |  |  |  |  | sub AUTOLOAD { | 
| 74 | 3 |  |  | 3 |  | 493 | my $self = shift; | 
| 75 | 3 |  |  |  |  | 4 | our $AUTOLOAD; | 
| 76 | 3 |  |  |  |  | 5 | my $sub = $AUTOLOAD; | 
| 77 | 3 |  |  |  |  | 17 | $sub =~ s/^.*:://; | 
| 78 | 3 |  |  |  |  | 7 | ( my $method = $sub ) =~ s/.*:://; | 
| 79 | 3 |  |  |  |  | 19 | return $self->{data}->{$sub}; | 
| 80 |  |  |  |  |  |  | } | 
| 81 |  |  |  |  |  |  |  | 
| 82 |  |  |  |  |  |  | =head1 NAME | 
| 83 |  |  |  |  |  |  |  | 
| 84 |  |  |  |  |  |  | WWW::SourceForge::User - SourceForge user objects | 
| 85 |  |  |  |  |  |  |  | 
| 86 |  |  |  |  |  |  | =head1 SYNOPSIS | 
| 87 |  |  |  |  |  |  |  | 
| 88 |  |  |  |  |  |  | Uses the SourceForge API to load user details. This is a work in | 
| 89 |  |  |  |  |  |  | progress, and the interface will change. Mostly I'm just poking about to | 
| 90 |  |  |  |  |  |  | see what this needs to support. Please feel free to play along. | 
| 91 |  |  |  |  |  |  |  | 
| 92 |  |  |  |  |  |  | http://sf.net/projects/sfprojecttools/ | 
| 93 |  |  |  |  |  |  |  | 
| 94 |  |  |  |  |  |  | =head1 DESCRIPTION | 
| 95 |  |  |  |  |  |  |  | 
| 96 |  |  |  |  |  |  | Implements a Perl interface to SourceForge users. See http://sourceforge.net/p/forge/documentation/API/ | 
| 97 |  |  |  |  |  |  |  | 
| 98 |  |  |  |  |  |  | =head1 USAGE | 
| 99 |  |  |  |  |  |  |  | 
| 100 |  |  |  |  |  |  | use WWW::SourceForge::User; | 
| 101 |  |  |  |  |  |  | my $user = WWW::SourceForge::User->new( username => 'rbowen' ); | 
| 102 |  |  |  |  |  |  | print $user->timezone; | 
| 103 |  |  |  |  |  |  | print Dumper( $user->projects ); | 
| 104 |  |  |  |  |  |  |  | 
| 105 |  |  |  |  |  |  | =head1 BUGS | 
| 106 |  |  |  |  |  |  |  | 
| 107 |  |  |  |  |  |  | None | 
| 108 |  |  |  |  |  |  |  | 
| 109 |  |  |  |  |  |  | =head1 SUPPORT | 
| 110 |  |  |  |  |  |  |  | 
| 111 |  |  |  |  |  |  | http://sourceforge.net/p/sfprojecttools/tickets/ | 
| 112 |  |  |  |  |  |  |  | 
| 113 |  |  |  |  |  |  | =head1 AUTHOR | 
| 114 |  |  |  |  |  |  |  | 
| 115 |  |  |  |  |  |  | Rich Bowen | 
| 116 |  |  |  |  |  |  | CPAN ID: RBOW | 
| 117 |  |  |  |  |  |  | SourceForge | 
| 118 |  |  |  |  |  |  | rbowen@sourceforge.net | 
| 119 |  |  |  |  |  |  | http://sf.net | 
| 120 |  |  |  |  |  |  |  | 
| 121 |  |  |  |  |  |  | =head1 COPYRIGHT | 
| 122 |  |  |  |  |  |  |  | 
| 123 |  |  |  |  |  |  | This program is free software; you can redistribute | 
| 124 |  |  |  |  |  |  | it and/or modify it under the same terms as Perl itself. | 
| 125 |  |  |  |  |  |  |  | 
| 126 |  |  |  |  |  |  | The full text of the license can be found in the | 
| 127 |  |  |  |  |  |  | LICENSE file included with this module. | 
| 128 |  |  |  |  |  |  |  | 
| 129 |  |  |  |  |  |  |  | 
| 130 |  |  |  |  |  |  | =head1 SEE ALSO | 
| 131 |  |  |  |  |  |  |  | 
| 132 |  |  |  |  |  |  | perl(1). | 
| 133 |  |  |  |  |  |  |  | 
| 134 |  |  |  |  |  |  | =cut | 
| 135 |  |  |  |  |  |  |  | 
| 136 |  |  |  |  |  |  | #################### main pod documentation end ################### | 
| 137 |  |  |  |  |  |  |  | 
| 138 |  |  |  |  |  |  | 1; | 
| 139 |  |  |  |  |  |  |  |