Hubot/Message.pm

filter: Statementstmt 90.2% 74 / 82 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 77.7% 14 / 18 Podpod 0.0% 0 / 3 totaltotal 85.4% 88 / 103 CC 1 SCAR 2.0
CC
1
Cov
90%
finish
2.0
TO_JSON
2.0
match
2.0
CRAP 1.2
« Hubot/Adapter.pm ↑ Summary Hubot.pm »
1 package Hubot::Message;
2 6 $Hubot::Message::VERSION = '0.2.8';
3 6 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 6 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 6 has 'user' => ( is => 'ro', isa => 'Hubot::User', );
7  
8 6 has 'done' => ( is => 'rw', isa => 'Bool', default => 0, );
9  
10 0 ▶sub finish { shift->done(1) }
Subroutine finish: not called CC=1 SCAR=6.9
Pod undocumented
11  
12 0 ▶sub TO_JSON {
Subroutine TO_JSON: not called CC=1 SCAR=6.9
Pod undocumented
13 0 my $self = shift;
14 return {
15 ## prvent recursive call
16 ## Hubot::UserTO_JSON -> Hubot::Message::TO_JSON -> Hubot::User::TO_JSON
17 user => { name => $self->user->{name}, id => $self->user->{id}, },
18 0 done => $self->done,
19 };
20 }
21  
22 6 __PACKAGE__->meta->make_immutable;
23  
24 6 1;
25  
26 package Hubot::TextMessage;
27 6 $Hubot::TextMessage::VERSION = '0.2.8';
28 6 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
29 6 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
30  
31 6 extends 'Hubot::Message';
32  
33 6 has 'text' => ( is => 'ro', isa => 'Str', );
34  
35 0 ▶sub match {
Subroutine match: not called CC=1 SCAR=6.9
Pod undocumented
36 0 my ( $self, $regex ) = @_;
37 0 return $self->text =~ m/$regex/;
38 }
39  
40 0 ▶override 'TO_JSON' => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
41 0 my $self = shift;
42 0 return { %{ super() }, text => $self->text };
43 6 };
44  
45 6 __PACKAGE__->meta->make_immutable;
46  
47 6 1;
48  
49 package Hubot::EnterMessage;
50 6 $Hubot::EnterMessage::VERSION = '0.2.8';
51 6 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
52 6 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
53 6 extends 'Hubot::Message';
54 6 __PACKAGE__->meta->make_immutable;
55  
56 6 1;
57  
58 package Hubot::LeaveMessage;
59 6 $Hubot::LeaveMessage::VERSION = '0.2.8';
60 6 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
61 6 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
62 6 extends 'Hubot::Message';
63 6 __PACKAGE__->meta->make_immutable;
64  
65 6 1;
66  
67 package Hubot::WhisperMessage;
68 6 $Hubot::WhisperMessage::VERSION = '0.2.8';
69 6 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
70 6 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
71 6 extends 'Hubot::TextMessage';
72 6 __PACKAGE__->meta->make_immutable;
73  
74 6 1;
75  
76 package Hubot::NoticeMessage;
77 6 $Hubot::NoticeMessage::VERSION = '0.2.8';
78 6 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
79 6 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
80 6 extends 'Hubot::TextMessage';
81 6 __PACKAGE__->meta->make_immutable;
82  
83 6 1;
84  
85 package Hubot::CatchAllMessage;
86 6 $Hubot::CatchAllMessage::VERSION = '0.2.8';
87 6 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
88 6 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
89 6 extends 'Hubot::Message';
90  
91 6 has 'message' => ( is => 'ro', isa => 'Hubot::Message' );
92  
93 6 __PACKAGE__->meta->make_immutable;
94  
95 6 1;
96  
97 =pod
98  
99 =encoding utf-8
100  
101 =head1 NAME
102  
103 Hubot::Message
104  
105 =head1 VERSION
106  
107 version 0.2.8
108  
109 =head1 SYNOPSIS
110  
111 my $msg = Hubot::Message->new(
112 user => $user # $user is Hubot::User
113 );
114  
115 $msg = Hubot::TextMessage->new(
116 user => $user # $user is Hubot::User
117 text => 'hi'
118 );
119  
120 $msg->finish; # this message is processed.
121 # Hubot::Script::* will ignore this message.
122  
123 =head1 DESCRIPTION
124  
125 Hubot::Adapter::* will make L<Hubot::Message> stand on input.
126  
127 =head1 AUTHOR
128  
129 Hyungsuk Hong <hshong@perl.kr>
130  
131 =head1 COPYRIGHT AND LICENSE
132  
133 This software is copyright (c) 2012 by Hyungsuk Hong.
134  
135 This is free software; you can redistribute it and/or modify it under
136 the same terms as the Perl 5 programming language system itself.
137  
138 =cut
« Hubot/Adapter.pm ↑ Summary Hubot.pm »