App/Twirc/Plugin/SecondaryAccount.pm

filter: Statementstmt 97.2% 35 / 36 Branchbran 100% 6 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 85.7% 6 / 7 Podpod 0.0% 0 / 2 totaltotal 92.1% 47 / 51 CC 4 SCAR 5.9
CC
4
Cov
98%
cmd_post
3.0
BUILD
2.0
__ANON__
1.1
CRAP 1.8
« POE/Component/Server/Twirc/LogAppender.pm ↑ Summary POE/Component/Server/Twirc/State.pm »
1 package App::Twirc::Plugin::SecondaryAccount;
2 1 $App::Twirc::Plugin::SecondaryAccount::VERSION = '0.20';
3 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use Net::Twitter;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use POE::Component::Server::Twirc;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 0 ▶has net_twitter_options => ( isa => 'HashRef', is => 'ro', default => sub { {} } );
Subroutine __ANON__: not called CC=1 SCAR=1.2
8 1 has username => ( isa => 'Str', is => 'ro', required => 1 );
9 1 has password => ( isa => 'Str', is => 'ro', required => 1 );
10 1 has option => ( isa => 'Str', is => 'ro' );
11 1 has _twitter => ( isa => 'Net::Twitter', is => 'rw' );
12 1 has _option_regex => ( isa => 'Maybe[RegexpRef]', is => 'rw', default => undef );
13 1 has _useragent_class => ( isa => 'Str', is => 'ro', default => 'LWP::UserAgent::POE' );
14  
15 2 ▶sub BUILD {
Subroutine BUILD: called CC=2 SCAR=6.9
Pod undocumented
16 2 my $self = shift;
17  
18 $self->_twitter(Net::Twitter->new(
19 username => $self->username,
20 password => $self->password,
21 source => 'twircgw',
22 useragent => 'twirc/' . POE::Component::Server::Twirc->VERSION,
23 useragent_class => $self->_useragent_class,
24 2 %{$self->net_twitter_options},
25 ));
26  
27 2 ▶ if ( $self->option ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->option) 1 1 2
28 1 my $option = quotemeta $self->option;
29 1 $self->_option_regex(qr/^-$option(only)?\s+/);
30 }
31 }
32  
33 4 ▶sub cmd_post {
Subroutine cmd_post: called CC=3 SCAR=11.0
Pod undocumented
34 4 my ($self, $server, $channel, $nick, $textref) = @_;
35  
36 4 my $only;
37 4 ▶ if ( my $option_regex = $self->_option_regex ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $option_regex = $self->_option_regex) 3 1 4
38 3 ▶ $$textref =~ s/$option_regex// || return;
Branch: 1 branch
BranchTrueFalseTotal
$$textref =~ s/$option_regex// or return 2 1 3
39 2 $only = $1;
40 }
41  
42 3 $self->_twitter->update($$textref);
43 3 return $only; # return a true value to stop the processing chain
44 }
45  
46 1 ▶no Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
47  
48 1 __PACKAGE__->meta->make_immutable;
49  
50 1 1;
51  
52 __END__
« POE/Component/Server/Twirc/LogAppender.pm ↑ Summary POE/Component/Server/Twirc/State.pm »