| 1 | package WWW::PGXN::User; | ||
| 2 | |||
| 3 | 9 | ▶ | use 5.8.1; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 9 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | |||
| 6 | 9 | our $VERSION = v0.12.4; | |
| 7 | |||
| 8 | BEGIN { | ||
| 9 | 9 | ▶ | for my $attr (qw( |
|
Subroutine
BEGIN: called CC=2 SCAR=6.9
| |||
| 10 | nickname | ||
| 11 | name | ||
| 12 | |||
| 13 | uri | ||
| 14 | |||
| 15 | )) { | ||
| 16 | 9 | ▶ | no strict 'refs'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 17 | 45 | ▶ | *{$attr} = sub { shift->{$attr} }; |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 18 | } | ||
| 19 | } | ||
| 20 | |||
| 21 | sub new { | ||
| 22 | 1 | ▶ | my ($class, $data) = @_; |
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||
| 23 | 1 | bless $data, $class; | |
| 24 | } | ||
| 25 | |||
| 26 | sub releases { | ||
| 27 | 1 | ▶ | +{ %{ shift->{releases} } } |
|
Subroutine
releases: called CC=1 SCAR=0.0
Pod
documented
| |||
| 28 | } | ||
| 29 | |||
| 30 | __END__ | ||
| 31 | |||
| 32 | =head1 Name | ||
| 33 | |||
| 34 | WWW::PGXN::User - User metadata fetched from PGXN | ||
| 35 | |||
| 36 | =head1 Synopsis | ||
| 37 | |||
| 38 | my $pgxn = WWW::PGXN->new( url => 'http://api.pgxn.org/' ); | ||
| 39 | my $user = $pgxn->get_user('theory'); | ||
| 40 | say $user->name, '<', $user->email, '>'; | ||
| 41 | |||
| 42 | |||
| 43 | =head1 Description | ||
| 44 | |||
| 45 | This module represents PGXN user metadata fetched from PGXN>. It is not | ||
| 46 | intended to be constructed directly, but via the L<WWW::PGXN/get_user> method | ||
| 47 | of L<WWW::PGXN>. | ||
| 48 | |||
| 49 | =head1 Interface | ||
| 50 | |||
| 51 | =begin private | ||
| 52 | |||
| 53 | =head2 Constructor | ||
| 54 | |||
| 55 | =head3 C<new> | ||
| 56 | |||
| 57 | my $user = WWW::PGXN::User->new($data); | ||
| 58 | |||
| 59 | Construct a new WWW::PGXN::User object. The argument must be the data | ||
| 60 | fetched. | ||
| 61 | |||
| 62 | =end private | ||
| 63 | |||
| 64 | =head2 Instance Accessors | ||
| 65 | |||
| 66 | =head3 C<nickname> | ||
| 67 | |||
| 68 | my $nickname = $user->nickname; | ||
| 69 | $user->nickname($nickname); | ||
| 70 | |||
| 71 | The user's nickname (also known as a user name). | ||
| 72 | |||
| 73 | =head3 C<name> | ||
| 74 | |||
| 75 | my $name = $user->name; | ||
| 76 | $user->name($name); | ||
| 77 | |||
| 78 | The full name of the user. | ||
| 79 | |||
| 80 | =head3 C<uri> | ||
| 81 | |||
| 82 | my $uri = $user->uri; | ||
| 83 | $user->uri($uri); | ||
| 84 | |||
| 85 | The URI for the user. May be C<undef> if the user has no URI. | ||
| 86 | |||
| 87 | =head3 C<email> | ||
| 88 | |||
| 89 | my $email = $user->email; | ||
| 90 | $user->email($email); | ||
| 91 | |||
| 92 | The user's email address. | ||
| 93 | |||
| 94 | =head3 C<twitter> | ||
| 95 | |||
| 96 | my $twitter = $user->twitter; | ||
| 97 | $user->twitter($twitter); | ||
| 98 | |||
| 99 | The user's Twitter nickname, if any. | ||
| 100 | |||
| 101 | =head3 C<releases> | ||
| 102 | |||
| 103 | my $releases = $user->releases; | ||
| 104 | |||
| 105 | Returns a hash reference describing all of the distributions ever released by | ||
| 106 | the user. The keys of are distribution names and the values are hash | ||
| 107 | references that may contain the following keys: | ||
| 108 | |||
| 109 | =over | ||
| 110 | |||
| 111 | =item C<stable> | ||
| 112 | |||
| 113 | =item C<testing> | ||
| 114 | |||
| 115 | =item C<unstable> | ||
| 116 | |||
| 117 | An array reference containing hashes of versions and release dates of all | ||
| 118 | releases of the distribution with the named release status, ordered from most | ||
| 119 | to least recent. | ||
| 120 | |||
| 121 | =item C<abstract> | ||
| 122 | |||
| 123 | A brief description of the distribution. Available only from the PGXN API, not | ||
| 124 | mirrors. | ||
| 125 | |||
| 126 | =back | ||
| 127 | |||
| 128 | Here's an example of the C<releases> data structure: | ||
| 129 | |||
| 130 | { | ||
| 131 | explanation => { | ||
| 132 | abstract => 'Turn an explain plan into a proximity tree', | ||
| 133 | stable => [ | ||
| 134 | { version => '0.2.0', date => '2011-02-21T20:14:56Z' } | ||
| 135 | ] | ||
| 136 | }, | ||
| 137 | pair => { | ||
| 138 | abstract => 'A key/value pair data type', | ||
| 139 | stable => [ | ||
| 140 | { version => '0.1.1', date => '2010-10-22T16:32:52Z' }, | ||
| 141 | { version => '0.1.0', date => '2010-10-19T03:59:54Z' } | ||
| 142 | ], | ||
| 143 | testing => [ | ||
| 144 | { version => '0.0.1', date => '2010-09-23T14:23:52Z' } | ||
| 145 | ] | ||
| 146 | }, | ||
| 147 | } | ||
| 148 | |||
| 149 | =head1 See Also | ||
| 150 | |||
| 151 | =over | ||
| 152 | |||
| 153 | =item * L<WWW::PGXN> | ||
| 154 | |||
| 155 | The main class to communicate with a PGXN mirror or API server. | ||
| 156 | |||
| 157 | =back | ||
| 158 | |||
| 159 | =head1 Support | ||
| 160 | |||
| 161 | This module is stored in an open L<GitHub | ||
| 162 | repository|http://github.com/theory/www-pgxn/>. Feel free to fork and | ||
| 163 | contribute! | ||
| 164 | |||
| 165 | Please file bug reports via L<GitHub | ||
| 166 | Issues|http://github.com/theory/www-pgxn/issues/> or by sending mail to | ||
| 167 | L<bug-WWW-PGXN@rt.cpan.org|mailto:bug-WWW-PGXN@rt.cpan.org>. | ||
| 168 | |||
| 169 | =head1 Author | ||
| 170 | |||
| 171 | David E. Wheeler <david@justatheory.com> | ||
| 172 | |||
| 173 | =head1 Copyright and License | ||
| 174 | |||
| 175 | Copyright (c) 2011 David E. Wheeler. Some Rights Reserved. | ||
| 176 | |||
| 177 | This module is free software; you can redistribute it and/or modify it under | ||
| 178 | the same terms as Perl itself. | ||
| 179 | |||
| 180 | =cut | ||