Hubot/User.pm

filter: Statementstmt 84.6% 11 / 13 Branchbran n/a Conditioncond 66.6% 2 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 75.0% 3 / 4 Podpod 0.0% 0 / 2 totaltotal 66.6% 16 / 24 CC 2 SCAR 4.7
CC
2
Cov
81%
new
2.0
TO_JSON
2.0
BEGIN
1.0
CRAP 1.6
« Hubot/Response.pm ↑ Summary Hubot/TextListener.pm »
1 package Hubot::User;
2 6 $Hubot::User::VERSION = '0.2.8';
3 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 6 ▶sub new {
Subroutine new: called CC=2 SCAR=7.0
Pod undocumented
7 6 my ( $class, $ref ) = @_;
8 6 ▶ $ref->{name} ||= $ref->{id};
Condition66%2/3
$ref->{"name"} ||= $ref->{"id"}
l!l&&r!l&&!r
510
MC/DC0%0/2
$ref->{"name"} ||= $ref->{"id"}
$ref->{"name"} $ref->{"id"}
Truth table66%2/3
A ||= B
A= $ref->{"name"}B= $ref->{"id"}
ABresult
1X1
011
000
9 6 bless $ref, $class;
10 }
11  
12 0 ▶sub TO_JSON { return { %{ shift() } } }
Subroutine TO_JSON: not called CC=1 SCAR=6.9
Pod undocumented
13  
14 6 1;
15  
16 =pod
17  
18 =encoding utf-8
19  
20 =head1 NAME
21  
22 Hubot::User - storage object for hubot users.
23  
24 =head1 VERSION
25  
26 version 0.2.8
27  
28 =head1 SYNOPSIS
29  
30 my $user = Hubot::User->new(
31 id => '1234',
32 name => 'aanoaa',
33 );
34  
35 $user->{something} = 'awesome'; # if you using external storage for Hubot::Brain
36 # this will stored.
37  
38 =head1 DESCRIPTION
39  
40 L<Hubot::User> is a storage object to chat rooms user's data.
41  
42 L<Hubot::Robot> has L<Hubot::User> pool.
43  
44 $robot->userForId($id, $data); # make new user with $data if not found $id
45  
46 L<Hubot::Script::redisBrain> save users data to C<hubot:storage>.
47 so L<Hubot::Robot> can reuse it.
48  
49 $ redis-cli
50 redis 127.0.0.1:6379> get hubot:storage
51 ...
52  
53 =head1 SEE ALSO
54  
55 L<Hubot::Script::redisBrain>
56  
57 =head1 AUTHOR
58  
59 Hyungsuk Hong <hshong@perl.kr>
60  
61 =head1 COPYRIGHT AND LICENSE
62  
63 This software is copyright (c) 2012 by Hyungsuk Hong.
64  
65 This is free software; you can redistribute it and/or modify it under
66 the same terms as the Perl 5 programming language system itself.
67  
68 =cut
« Hubot/Response.pm ↑ Summary Hubot/TextListener.pm »