File Coverage

blib/lib/WWW/Wookie/User.pm
Criterion Covered Total %
statement 26 26 100.0
branch n/a
condition n/a
subroutine 9 9 100.0
pod n/a
total 35 35 100.0


line stmt bran cond sub pod time code
1             # -*- cperl; cperl-indent-level: 4 -*-
2             # Copyright (C) 2010-2021, Roland van Ipenburg
3             package WWW::Wookie::User v1.1.3;
4 4     4   32 use strict;
  4         10  
  4         141  
5 4     4   24 use warnings;
  4         21  
  4         168  
6              
7 4     4   24 use utf8;
  4         9  
  4         33  
8 4     4   159 use 5.020000;
  4         16  
9              
10 4     4   26 use Moose qw/around has/;
  4         9  
  4         26  
11 4     4   23460 use Moose::Util::TypeConstraints qw/as coerce from where subtype via/;
  4         11  
  4         34  
12 4     4   4065 use namespace::autoclean '-except' => 'meta', '-also' => qr/^_/sxm;
  4         10  
  4         46  
13              
14 4     4   412 use Readonly;
  4         42  
  4         1816  
15             ## no critic qw(ProhibitCallsToUnexportedSubs)
16             Readonly::Scalar my $EMPTY => q{};
17             Readonly::Scalar my $UNKNOWN => q{UNKNOWN};
18             Readonly::Scalar my $MORE_ARGS => 3;
19             ## use critic
20              
21             subtype 'Trimmed' => as 'Str' => where { m{(^$|(^\S|\S$))}gsmx };
22              
23             coerce 'Trimmed' => from 'Str' => via { s{^\s+(.*)\s+$}{$1}gsmx; $_ };
24              
25             has 'loginName' => (
26             'is' => 'rw',
27             'isa' => 'Trimmed',
28             'coerce' => 1,
29             'default' => $UNKNOWN,
30             'reader' => 'getLoginName',
31             'writer' => 'setLoginName',
32             );
33              
34             has 'screenName' => (
35             'is' => 'rw',
36             'isa' => 'Trimmed',
37             'coerce' => 1,
38             'default' => $UNKNOWN,
39             'reader' => 'getScreenName',
40             'writer' => 'setScreenName',
41             );
42              
43             has 'thumbnailUrl' => (
44             'is' => 'ro',
45             'isa' => 'Str',
46             'default' => $EMPTY,
47             'reader' => 'getThumbnailUrl',
48             'writer' => 'setThumbnailUrl',
49             );
50              
51             around 'BUILDARGS' => sub {
52             my $orig = shift;
53             my $class = shift;
54              
55             if ( 2 == @_ && !ref $_[0] ) {
56             push @_, $EMPTY;
57             }
58             if ( @_ == $MORE_ARGS && !ref $_[0] ) {
59             return $class->$orig(
60             'loginName' => $_[0],
61             'screenName' => $_[1],
62             'thumbnailUrl' => $_[2],
63             );
64             }
65             return $class->$orig(@_);
66             };
67              
68 4     4   35 no Moose;
  4         8  
  4         42  
69              
70             __PACKAGE__->meta->make_immutable;
71              
72             1;
73              
74             __END__
75              
76             =encoding utf8
77              
78             =for stopwords Bitbucket url Readonly Ipenburg login MERCHANTABILITY
79              
80             =head1 NAME
81              
82             WWW::Wookie::User - represent a possible user of a widget
83              
84             =head1 VERSION
85              
86             This document describes WWW::Wookie::User version C<v1.1.3>
87              
88             =head1 SYNOPSIS
89              
90             use WWW::Wookie::User;
91             $u = WWW::Wookie::User->new($login, $nick);
92              
93             =head1 DESCRIPTION
94              
95             A user represents a possible user of a widget. This class provides a standard
96             way of representing users in plugins for host environments.
97              
98             =head1 SUBROUTINES/METHODS
99              
100             =head2 C<new>
101              
102             Create a new user.
103              
104             =over
105              
106             =item 1. User login name as string
107              
108             =item 2. User display name as string
109              
110             =item 3. Optional thumbnail URL as string
111              
112             =back
113              
114             =head2 C<getLoginName>
115              
116             Get the login name for this user. Returns the user login name as string.
117              
118             =head2 C<getScreenName>
119              
120             Get the screen name for this user. This is the name that is intended to be
121             displayed on screen. In many cases it will be the same as the login name.
122             Returns the user display name as a string.
123              
124             =head2 C<setLoginName>
125              
126             Set the login name for this user. this is the value that is used by the user
127             to register on the system, it is guaranteed to be unique.
128              
129             =over
130              
131             =item 1. New login name as string
132              
133             =back
134              
135             =head2 C<setScreenName>
136              
137             Set the screen name for this user. This is the value that should be displayed
138             on screen. In many cases it will be the same as the login name.
139              
140             =over
141              
142             =item 1. New screen name as string
143              
144             =back
145              
146             =head2 C<getThumbnailUrl>
147              
148             Get the URL for a thumbnail representing this user. Returns the user thumbnail
149             icon url as string.
150              
151             =head2 C<setThumbnailUrl>
152              
153             Set the URL for a thumbnail representing this user.
154              
155             =over
156              
157             =item 1. New thumbnail URL as string
158              
159             =back
160              
161             =head1 CONFIGURATION AND ENVIRONMENT
162              
163             =head1 DEPENDENCIES
164              
165             =over 4
166              
167             =item * L<Moose|Moose>
168              
169             =item * L<Moose::Util::TypeConstraints|Moose::Util::TypeConstraints>
170              
171             =item * L<Readonly|Readonly>
172              
173             =item * L<namespace::autoclean|namespace::autoclean>
174              
175             =back
176              
177             =head1 INCOMPATIBILITIES
178              
179             =head1 DIAGNOSTICS
180              
181             =head1 BUGS AND LIMITATIONS
182              
183             Please report any bugs or feature requests at
184             L<Bitbucket|https://bitbucket.org/rolandvanipenburg/www-wookie/issues>.
185              
186             =head1 AUTHOR
187              
188             Roland van Ipenburg, E<lt>roland@rolandvanipenburg.comE<gt>
189              
190             =head1 LICENSE AND COPYRIGHT
191              
192             Copyright 2010-2021 by Roland van Ipenburg
193              
194             This library is free software; you can redistribute it and/or modify
195             it under the same terms as Perl itself, either Perl version 5.14.0 or,
196             at your option, any later version of Perl 5 you may have available.
197              
198             =head1 DISCLAIMER OF WARRANTY
199              
200             BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
201             FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
202             OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
203             PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
204             EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
205             WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE
206             ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH
207             YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL
208             NECESSARY SERVICING, REPAIR, OR CORRECTION.
209              
210             IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
211             WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
212             REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENSE, BE
213             LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL,
214             OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE
215             THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
216             RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
217             FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
218             SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
219             SUCH DAMAGES.
220              
221             =cut